如何从shell在Ubuntu中设置静态IP

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了如何从shell在Ubuntu中设置静态IP相关的知识,希望对你有一定的参考价值。

Seen here: http://textsnippets.com/posts/show/319
  1. ### Edit /etc/network/interfaces (in this example setup I will use the IP address 192.168.178.50 for eth0):
  2.  
  3.  
  4. # This file describes the network interfaces available on your system
  5. # and how to activate them. For more information, see interfaces(5).
  6.  
  7. # The loopback network interface
  8. auto lo
  9. iface lo inet loopback
  10.  
  11. # This is a list of hotpluggable network interfaces.
  12. # They will be activated automatically by the hotplug subsystem.
  13. mapping hotplug
  14. script grep
  15. map eth0
  16.  
  17. # The primary network interface
  18. auto eth0
  19. iface eth0 inet static
  20. address 192.168.178.50
  21. netmask 255.255.255.0
  22. network 192.168.178.0
  23. broadcast 192.168.178.255
  24. gateway 192.168.178.1
  25. #optional
  26. #dns-nameserver 102.168.178.1
  27.  
  28.  
  29.  
  30. ### You can also edit /etc/resolv.conf to configure a dns-server to use:
  31.  
  32. nameserver 192.168.178.1

以上是关于如何从shell在Ubuntu中设置静态IP的主要内容,如果未能解决你的问题,请参考以下文章

Ubuntu中设置静态IP和DNS(转载)

如何在linux系统中设置静态ip地址

如何在linux系统中设置静态ip地址

如何在linux系统中设置静态ip地址

如何在linux系统中设置静态IP?在系统管理一项中没有网络选项,所以无法找到网络连接选项----

如何在 Docker 容器中设置静态 IP 地址?