First, it’s important to identify which network management tool your Ubuntu system is using, as different versions rely on different utilities. This determines the correct method to restart or reconfigure your network.
For example, Ubuntu 18.04 uses Netplan as its default network configuration tool. Netplan acts as a unified interface to manage network settings by generating backend configurations for either NetworkManager or systemd-networkd. Understanding which backend is active will help you apply the appropriate commands to restart the network service properly.
In earlier Ubuntu versions, tools like ifupdown or directly managing NetworkManager were common. Knowing your system’s network manager ensures that network restarts and changes are executed correctly without disrupting connectivity.
What is Netplan used for?
Netplan is a modern command-line network configuration tool introduced in Ubuntu starting from version 17.10. It simplifies network management by allowing you to define network interface settings using an easy-to-read YAML format. Netplan acts as an abstraction layer and works with backend network daemons such as NetworkManager and systemd-networkd (called "renderers"), which directly interact with the operating system kernel. Users can choose which renderer to use for applying and managing their network configurations.
It reads network configuration described in /etc/netplan/*.yaml and you can store configurations for all your network interfaces in these files.
So the first thing to do is to check what configuration files do we have in /etc/netplan/
We can check this out by using the command:
Here we can see configuration file called “50-cloud-init.yaml”.
Now we need to read it to see configuration:
In the Renderer we can see the “NetworkManager” – that’s our active network manager.
To restart it simply run:
And then to see it’s status run:
As we can see it’s active and running.
If you see “networkd” in the Renderer in the netplan configuration file you need to restart it with the command:
And then to see it’s status run:
That’s all, network is restarted.
Conclusion
Restarting the network service on Ubuntu requires first identifying the network management tool your system uses, as different Ubuntu versions rely on different utilities such as Netplan, NetworkManager, or systemd-networkd. By checking your Netplan configuration files, you can determine the active renderer and use the appropriate commands to restart the network service safely. Properly restarting the network ensures minimal downtime and stable connectivity, making it easier to apply configuration changes or troubleshoot network issues on your Ubuntu system.
FAQ
- Q: How do I check which network manager Ubuntu is using?
A: You can check the renderer specified in the Netplan configuration files located in /etc/netplan/ using cat /etc/netplan/*.yaml. The renderer will be either NetworkManager or networkd (systemd-networkd). - Q: How do I restart the network on Ubuntu 18.04 using Netplan?
A: After identifying the renderer, use sudo service network-manager restart if the renderer is NetworkManager, or sudo systemctl restart systemd-networkd if it is networkd. - Q: What command shows the status of the network service?
A: Use sudo service network-manager status for NetworkManager or sudo systemctl status systemd-networkd for systemd-networkd. - Q: What if my Ubuntu version uses ifupdown instead of Netplan?
A: Older versions of Ubuntu use ifupdown. You can restart networking with sudo /etc/init.d/networking restart or by bringing interfaces down and up using ifdown and ifup. - Q: Why is it important to restart the correct network manager?
A: Restarting the wrong service may cause network disruptions or fail to apply changes, so identifying and restarting the correct network manager ensures network stability and proper configuration.