In this article, I will show you how to configure the network easily and restart them properly on Debian Linux. Let’s get started.
Restarting Networking on Debian 8 Wheezy and Older:
On Debian Linux, the network configuration is stored in /etc/network/interfaces file. On older version of Debian, when you make changes to /etc/network/interfaces file, you can restart networking with the following command:
The network service should be restarted. But on Debian 9 Stretch, that no longer works due to a bug.
Installing Network Manager on Debian 9 Stretch:
You can directly configure a network interface using /etc/network/interfaces file manually if you like. But the good news is, you don’t have to do that. On recent Linux distributions such as Debian 9 Stretch, networking can be managed by the Network Manager. It makes configuring a network really easy. Network Manager has command line utilities for network configuration.
If you have minimal server version of Debian 9 Stretch installed, you may not have Network Manager installed. In that case, you have to install Network Manager.
First update the package repository cache with the following command
The package repository cache should be updated.
Now install Network Manager with the following command:
Press y and then press <Enter> to continue.
Network Manager should be installed.
Using Network Manager to Configure Networking:
Network Manager has nmtui terminal based interactive tool that you can use to configure networking on Debian 9 Stretch.
To start nmtui, run the following command:
You should see the following window. From here you can set hostname, edit/add network connection, and active/deactivate network connections that you created.
To create a connection, go to Edit a connection. Then press <Tab> to select <Add> and then press <Enter>.
Now select your connection method. I am going for Ethernet as I have a wired connection. Now press <Tab> and select <Create> and then press <Enter>.
Now type in a Profile name. It can be anything you want. I recommend you make it short and easy. Now type in a Device identified. I have only one physical Ethernet cable connected to my computer and is recognized as ens33, so I typed that. You can run ip link show command to find out your Device identifier.
If you want to use DHCP to get the IP address for this network interface, then that’s pretty much everything you need to do. But if you want to assign a static IPv4 or IPv6 address, then you have to press <Tab> to go to <Show> for IPv4 CONFIGURATION or IPv6 CONFIGURATION or both depending on your need. Then press <Enter>. Then you should see something like this. Type in your IP Address, Gateway, DNS servers information, Routing and other information.
Once you’re done, scroll down using the <Down Arrow Key> and go to <OK> and then press <Enter>.
Your connection should be created and activated.
NOTE: Network Manager do not manage interfaces defined in /etc/network/interfaces file. So if the interface you’re configuring with Network Manager is also configured using the /etc/network/interfaces file, then be sure to comment it out or remove it from the /etc/network/interfaces file for Network Manager to work with that interface.
Restarting a Single Connection Using Network Manager:
In the earlier section, I showed you how to create a connection using Network Manager. In this section I will show you how to restart the connection.
When you edit a connection, you must restart the connection for the changes to take effect.
You can use the nmtui utility to restart a connection using the Terminal based user interface.
Run nmtui and go to Activate a connection.
Now select your Connection from the list, in my case the Home Router, then press <Tab>.
Now while <Deactivate> is selected, press <Enter> to deactivate the connection first.
Now while <Activate> is selected, press <Enter> to activate the connection again. Your changes should be applied.
You can do the same thing from the terminal using the nmcli command.
Deactivate the Home Router connection with the following command:
To Activate the Home Router connection again, run the following command:
You can also Restart the connection with a single command:
Restarting Network Manager:
If you have a lot of connection, which may take a lot of time to restart one by one, then you can just restart the Network Manager service with the following command:
The Network Manager service should restart.
That’s how you Restart Networking Properly on Debian Linux. Thanks for reading this article.