2

I spent far too long figuring this out, and wanted to share.

Simple task: Add a static IP address to the 2nd of 4 NICs on my server.

To start, I followed the instructions here under Static IP Address Assignment: https://help.ubuntu.com/14.04/serverguide/network-configuration.html

interfaces file:

$ cat /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto em1
iface em1 inet dhcp


auto em2
iface em2 inet static
address 172.24.0.9
netmask 255.255.0.0

Then I run sudo ifup em2, as per the instructions.

At first, it appeared to work. ifconfig showed the interface properly, and I was able to ping devices on the network. HOWEVER, after about a minute or so, the assigned static IP address vanished. The address is lost and the machine is unreachable. This happens over and over no matter how often I bring the interface up or down. Why is this happening?

0
5

The issue was Network Manager. NM is supposed to ignore explicit interfaces in the /etc/network/interfaces file. However, it appears you need to RESTART the service:

$ sudo service network-manager restart
$
$ nmcli dev status
DEVICE     TYPE              STATE        
p1p2       802-3-ethernet    unavailable  
p1p1       802-3-ethernet    unavailable  
em4        802-3-ethernet    unavailable  
em3        802-3-ethernet    unavailable  
em2        802-3-ethernet    unmanaged    
em1        802-3-ethernet    unmanaged 

And now the static IP is not being overwritten by Network Manager. The "unmanaged" state of the 2nd interface (or whatever interface you may be working on) is what we are looking for.

tl;dr: After adding an interface to the interfaces file, restart the network-manager service.

1

Just get rid of the two "if...fi" blocks in pre-start and post-stop in /etc/init/networking.conf so that "service networking restart" to work again.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.