Once you make changes in the network interface, they affect the network services manager of your system. To enable the system or machine to connect to the network, one needs to restart the network interface to apply the changes without rebooting your server.
This article will guide you on restarting the network interface in various Linux distributions.
Note: When running SSH/ VNC or other remote-based sessions, you should take precautions since restarting the network interface or service can result in network disconnectivity, resulting in connection loss.
We will handle the following topics.
- What is a Network Interface?
- How to List Network Interfaces on Linux
- How to Turn ‘ON’ or ‘OFF’ Network Interfaces
- How to Restart Network Interfaces on Linux
- How to Check the Status of Network Services in Linux
What is a network interface?
A network interface refers to the point of connection between a computer and the network. It can be either software (especially with Virtual machines) or a hardware component. When dealing with network interfaces, there is one term that you will likely come across – NIC (Network Interface Card).
A Network Interface Card is a circuit board chip inserted/ soldered on the motherboard allowing your computer to connect to the internet. If you have worked with many earlier Desktop computers (even some today), you know that most cannot connect to a WiFi network, and that’s because they don’t have a wireless NIC. You are advised to purchase a USB Network Adapter that will act as your wireless interface connection in such a situation.
How to list network interfaces on Linux
You can use different ways to see all the available network interfaces on your system. You can use the GUI or the Command-line (CLI). In this post, we highly recommend using the Terminal (CLI) since the GUI settings app might not list specific interfaces.
We will use the following commands to list network interfaces on our system.
- ifconfig
- ip
- netstat
- nmcli
1. The ifconfig command
This command has long been used to list and configure network interfaces on Linux. Unfortunately, this command is marked as ‘deprecated’ and does not come pre-installed in certain distributions like recent Debian and Kali Linux releases.
To list network interfaces using ifconfig, execute the command below.
ifconfig -a
Tip: If you get an error like ‘ifconfig command not found,‘ install the ifconfig utility with the command below.
sudo apt install net-tools
In other systems like Debian, you will still get the error since the ifconfig will install in the /sbin path. Therefore, you will need to execute ifconfig with the syntax below.
/sbin/ifconfig -a
2. The IP command
The IP command is the successor of the ifconfig command. You can use it to list network interfaces and configure routing and tunnels. This utility comes pre-installed in all Linux distributions.
To list network interfaces with the IP command, execute the command below.
ip link show
3. The netstat command
Another utility you can use to list all network interfaces on your system is netstat. Execute the command below.
netstat -i
4. The nmcli command
nmcli is a command-line utility that you can use to list and configure network interfaces. Execute the command below to list all interfaces present on your system.
nmcli device status or nmcli connection show
How to Turn ‘ON’ or ‘OFF’ Network Interfaces
To turn on or off your network interface, we will use the ifconfig commands as shown below.
Note: Turning OFF an interface connection will disrupt/ close any active SSH connections.
Before executing any of the commands below, identify the network interface you want to turn ON or OFF. Use any commands discussed in the previous section to list the network interfaces on your system.
For example, our computer is connected to the internet via ethernet, which is listed as enp0s25.
- Turn ON a network interface.
sudo ifconfig <interface-name> up e.g sudo ifconfig enp0s25 up
The enp0s25 is the network interface.
- To turn OFF the network interface, we will use the following command.
sudo ifconfig <interface-name> down e.g sudo ifconfig enp0s25 down
The enp0s25 is the network interface.
How to restart network interfaces on Linux
The following are methods on how to restart network interfaces in different distributions.
1. Debian /Ubuntu
To restart the network interface in Debian-based distributions using ‘init.d,’ execute the commands below.
sudo /etc/init.d/network-manager restart
To stop or start using the below commands.
sudo /etc/init.d/network-manager stop sudo /etc/init.d/network-manager start
To restart the network interface in Debian using systemctl, execute the command below.
sudo systemctl restart NetworkManager
2. RHEL-based OS (centos, Fedora, etc.)
To restart a network interface in RHEL-based operating systems, you can use systemctl or the nmcli utility.
Run the commands below to start and stop the network interface using nmcli.
sudo nmcli networking off sudo nmcli networking on
Use the following commands to restart the network interface in RHEL-based distributions using the systemctl command.
sudo systemctl restart NetworkManager.service
3. Slackware Linux
To restart the network interface in Slackware Linux use.
sudo /etc/rc.d/rc.inet1 restart
4. Gentoo
Type the command below to restart the network interface in Gentoo for a particular network interface.
/etc/init.d/net.eth0 restart
5. Alpine Linux
To restart the network interface in Alpine Linux, run the following commands.
service networking restart or /etc/init.d/networking restart
6. Arch Linux
To restart the network interface in Arch Linux, type the command below.
sudo systemctl restart systemd-networkd.service
How to check the status of network services in Linux
Different Linux distributions have varying commands for checking network services. This article will explore some of the commands used to check the status of network services in various Linux distributions.
1. Debian/Ubuntu
Run the command below to check for network services status in Debian/ Ubuntu.
sudo service NetworkManager status
2. RHEL-based OS (centos, Fedora, etc.)
Use the command below to check the network service status in RHEL-based operating systems.
sudo systemctl status NetworkManager
3. Suse/OpenSUSE
To check the network service in OpenSUSE, run the command below.
systemctl status network
4. Alpine Linux
Run the following command to check the network service status on Alpine Linux.
service networking status
Conclusion
This article has given you a step-by-step guide on how to restart and list the network interfaces on your system. We have tried to cover all the most popular Linux distributions. Is there any Linux distribution that you feel we left out? Or is there any command that throws an error on your system? Please, don’t hesitate to notify us in the comments below, and we will do our best to assist you.