-2

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
Mark M
  • 11
  • 3

2 Answers2

0

I don't know about 16.04 but in previous versions you have Network Manager daemon setting the IPs. Use the applet 'nm-applet' to set up your static address. Right click it and go for 'edit connections'.

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

  • Thanks for the reply. This is a headless server and I am doing everything from the terminal. In my original question I have added the results from ip route show. This extra information might help. Could it be a dhcp issue? – Mark M Oct 21 '16 at 14:13
  • I believe the file you are editing is incompatible with Network Manager. According to the document above, you should comment out all lines except for the loopback interface. You may wish to disable Network Manager instead. If you decide to stick with it, edit the files in this folder: `/etc/NetworkManager/system-connections` I used the graphical interface that writes to these files and for a static connection the file looks like this: http://pastebin.com/Rm5Mpq19 – Boris the Bullet Dodger Oct 21 '16 at 20:11
  • In case you need more help consider posting the question in http://serverfault.com/ – Boris the Bullet Dodger Oct 21 '16 at 20:19
0

I fixed part of the problem it was as simple as changing the file to the parameters outline below.

/etc/network/interfaces

# 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

Now when the server boots up it will auto assigning 192.168.1.100 although it will also still assigning 192.168.1.2. If I find a way to have it stop assigning the 2nd ip address I will update my answer. Thanks

Mark M
  • 11
  • 3