Ubuntu – How to change the network configuration on Ubuntu 14.04 server

14.04networkingserver

I just installed an Ubuntu 14.04 server, and I've discovered that there is no way to make any changes to the network configuration except by rebooting the server. This is on a stock install of Ubuntu 14.04 server, installed last week, with no changes made to it, and no new packages installed (since I can't reach apt-get).

ifconfig up/down seems to read from some kind of cache; at least, it ignores any changes I make to /etc/network/interfaces. I tried using it to change from DCHP to static for eth1, and nothing happened; eth1 continued to get its address from DHCP.

/etc/init.d/networking stop/restart/force-reload all fail with no error message.

How is this supposed to work on Ubuntu Server? Right now, it seems like network changes only take effect with a reboot.

(and please don't give me answers which involve network-manager; this is a headless server with no GUI. Thanks).

ADDING INFORMATION REQUESTED BELOW:

/etc/network/interfaces originally was:

# The primary network interface
auto eth1
iface eth1 inet dhcp

… this wasn't picking up gateway information from DHCP, even though my Ubuntu laptop picks it up just fine.

So I changed it to:

# The primary network interface
auto eth1
iface eth1 inet static
address 172.47.23.106
netmask 255.255.255.0
gateway 172.47.23.1

However, after doing ifconfig down/up, the IP address of eth1 did not change and the gateway did not get added to the route table. On a full restart of the system, the eth1 configuration was picked up just fine.

So it seems that ifconfig up ignores changes to /etc/network/interfaces.

Best Answer

The correct way to get the system to re-read and use the changed /etc/network/interfaces file is:

sudo ifdown eth1 && sudo ifup -v eth1

The '-v' for verbose should produce output to judge if the changes were made successfully. Check:

ifconfig
ping -c3 www.google.com
Related Question