Ubuntu 16.04 reboots with a different ip address then the static one assigned in /etc/network/interfaces

时间:2016-10-20 20:11:25

标签: networking ip-address ubuntu-16.04 ifconfig

When my server reboots the ip address for eth0 is 192.168.1.2 when it should be 192.168.1.100 per the static ip address settings in /etc/network/interfaces. After boot if I run service networking restart it will assigning 192.168.1.100 to eth0. Also I don't know if this matters but the hostname displayed in my router is different the the hostname displayed in /etc/hosts.

/etc/network/interfaces

auto lo eth0
iface lo inet loopback

# IPv4 address
auto eth0
iface eth0 inet static
        address 192.168.1.100
        netmask 255.255.255.0
        broadcast 192.168.1.255
        network 192.168.1.0

ip a

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
   valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
   valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether a4:1f:72:7c:61:8d brd ff:ff:ff:ff:ff:ff
inet 192.168.1.100/24 brd 192.168.1.255 scope global eth0
   valid_lft forever preferred_lft forever
inet 192.168.1.2/24 brd 192.168.1.255 scope global secondary dynamic eth0
   valid_lft 85312sec preferred_lft 85312sec

ip route show

10.8.0.0/24 dev tun0  proto kernel  scope link  src 10.8.0.1
169.254.0.0/16 dev eth0  scope link  metric 1000
192.168.1.0/24 dev eth0  proto kernel  scope link  src 192.168.1.100
192.168.1.1 dev eth0  proto dhcp  scope link  src 192.168.1.2  metric 1024

2 个答案:

答案 0 :(得分:0)

我不知道16.04,但在以前的版本中,您有网络管理器守护程序设置IP。使用applet&#39; nm-applet&#39;设置静态地址。右键单击它并转到“编辑连接”。

https://help.ubuntu.com/community/NetworkManager

答案 1 :(得分:0)

我解决了部分问题,就像将文件更改为下面的参数大纲一样简单。

的/ etc /网络/接口

# IPv4 address
iface eth0 inet static
   address 192.168.1.100
   netmask 255.255.255.0
   gateway 192.168.1.1
   dns-nameservers 8.8.8.8

现在,当服务器启动时,它将自动分配192.168.1.100,尽管它仍然会分配192.168.1.2。如果我找到一种让它停止分配第二个IP地址的方法,我会更新我的答案。感谢