I recently set up an IPv6 interface on a remote Ubuntu server. In order to finish this change, I needed to restart the interface. A while back, I would have used sudo service networking restart
, but that doesn’t work very well any more:
[chris@server ~]$ sudo service networking restart stop: Job failed while stopping start: Job is already running: networking [chris@server ~]$
After doing some more reading, I found that restarting the networking service can have some bad side effects in Ubuntu, so they more or less prevented this from working. The correct way is to manually bring the interface that needs to be restarted down and back up.
The interface that I’m working with is named eth0
. Your interface could be named eth1
, em1
, or many other names. So, when following my examples, make sure to replace eth0
with the name of your interface.
If the /etc/network/interfaces
file was updated when making your network changes, you can run the following to run a basic syntax check on the file. It won’t tell you if you made a mistake on the IP address or other configuration details specific to your network setup, but it can catch simple syntax errors.
[chris@server ~]$ sudo ifup -n eth0 ifup: interface eth0 already configured [chris@server ~]$
The -n
tells ifup
to not actually take any actions, thus allowing for a quick syntax check of the /etc/network/interfaces
file. The “interface eth0 already configured” message indicates that no configuration issues were found. The following shows what happens when a configuration error was found.
[chris@server ~]$ sudo ifup -n eth0 /etc/network/interfaces:20: unknown address type ifup: couldn't read interfaces file "/etc/network/interfaces" [chris@server ~]$
This indicates that a problem was found on line 20 of the configuration file. In this specific instance, I accidentally put “int6” instead of “inet6”.
Now that we know that the config file doesn’t have any syntax issues, the following one-liner takes the eth0 interface down and then back up:
[chris@server ~]$ sudo ifdown eth0 && sudo ifup eth0 Waiting for DAD... Done [chris@server ~]$
And with that, the interface now has the new config.
Did I help you?