75

restart the network service:

service networking restart

When I give the above command I get something like

stop: Unknown instance:
networking stop/waiting

I would like to know if the network services has restarted or is it showing some errors. if it is an error how to rectify it?

2
  • @DavidFoerster this post has been nearly 3x times as that one, and the answers there seem to be of similar quality, so why close this one instead of that?
    – muru
    Oct 25, 2017 at 3:46
  • @muru: All the answers given here also exist on the linked question. We could also merge the questions which is what I requested through a mod flag. Oct 25, 2017 at 9:32

2 Answers 2

80

After editing /etc/network/interfaces, the usual way to get the system to re-read the file and use the changes is to do:

sudo ifdown wlan0 && sudo ifup wlan0

Of course, substitute the relevant interface if it's not wlan0.

I assume Network Manager is not present on this system. If it is, you are better off to make your changes there rather than /etc/network/interfaces.

7
  • If within a local network managed by a firewall like shorewall, then most likely your network cards, eth0 and eth1, will have internal ip addresses, so will look something like: sudo ifdown eth0 && sudo ifup eth0 Jul 14, 2014 at 22:32
  • NetworkManager isn't always could help. I.e. for unknown reasons my NetworkManager just ignores even a network existence(a network doesn't react on any change in the NetworkManager). Also I had a negative experience with NetworkManager in the fact that if a network was broken(relatively often thing in the case of my ISP), it doesn't even tell a reason. When I am configure manually I at least know that I can peek at a log file.
    – Hi-Angel
    Aug 31, 2014 at 7:59
  • 1
    sudo ifdown eth0 && sudo ifup eth0 /etc/network ifdown: interface eth0 not configured RTNETLINK answers: File exists Failed to bring up eth0. Jun 29, 2017 at 8:28
  • 1
    @DavidOkwii Please start your own new question and include your details.
    – chili555
    Jun 29, 2017 at 13:42
  • 1
    @Timo In 20.04 the /etc/network/interfaces process is deprecated in favor of netplan. Please see the templates here: /usr/share/doc/netplan/examples If you need further guidance, please post your own new question.
    – chili555
    Jun 8, 2021 at 13:09
29

Please be aware that starting with Ubuntu Server 16.04, you need to use the ip command to flush the interface address before restarting networking, otherwise changes in the interfaces file will not take effect.

IMPORTANT: If you are doing this through an SSH connection, it's important that you chain the commands together as shown below, because you may lose the connection to the server immediately after you flush the network interface.

sudo ip addr flush interface-name && sudo systemctl restart networking

(Source)

1
  • In Ubuntu 20.04 it seems that it should now be sudo ip addr flush $ifname && sudo systemctl restart network-manager.service Dec 16, 2021 at 23:17

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