I have a few virtualized (ubuntu 14.04 LTS) servers under KVM that I'm trying to move to an ip block other than the one reserved for servers under dhcp (the 10.10.2.0/24 block). I change the ip and then run this command:
sudo ifdown -a && sudo ifup -a
And the whole setup on the new ip works for a little while. Then, after a few minutes, it all of a sudden switches back to wrong ip, even though my /etc/network/interfaces
file is unchanged. Here it is:
# Interface lo
auto lo
iface lo inet loopback
# Interface eth0
auto eth0
iface eth0 inet static
address 10.10.28.4
netmask 255.255.0.0
network 10.10.0.0
broadcast 10.10.255.255
dns-nameservers 10.10.85.2 10.10.85.71 8.8.8.8
dns-search lan
gateway 10.10.85.2
But my ifconfig is changed. I can repeat this over and over, but every time it switches ips (after I do nothing on the server for a bit) and my ssh connection just closes. Any thoughts? What other information might you need to help? Thanks in advance! This is super frustrating!
Edit: Just in case it does help, here's the two ifconfig outputs. After I set the static ip:
eth0 Link encap:Ethernet HWaddr 52:54:00:51:b8:76
inet addr:10.10.28.4 Bcast:10.10.255.255 Mask:255.255.0.0
inet6 addr: fe80::5054:ff:fe51:b876/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:102914 errors:0 dropped:4 overruns:0 frame:0
TX packets:31863 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:148249682 (148.2 MB) TX bytes:4566351 (4.5 MB)
And after it switches back:
eth0 Link encap:Ethernet HWaddr 52:54:00:51:b8:76
inet addr:10.10.2.98 Bcast:10.10.255.255 Mask:255.255.0.0
inet6 addr: fe80::5054:ff:fe51:b876/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:96960 errors:0 dropped:4 overruns:0 frame:0
TX packets:29960 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:147748205 (147.7 MB) TX bytes:4315514 (4.3 MB)
It sounds like network-manager is reverting the interface back to dhcp because it's not aware of the config change.
Rather than doing
ifup
/ifdown
restart the network-manager service:If network-manager isn't installed check to see if dhclient is still running. If it is stop it and try restarting the interface again.