Skip to Content

Top 3 ways to restart Network Interfaces in Linux

In the world of Linux system administration, the ability to manage and troubleshoot network interfaces is a fundamental skill.

There are situations where you might encounter connectivity issues, need to apply configuration changes, or simply want to reset a network interface to its default state.

In such scenarios, the knowledge of how to gracefully restart a network interface becomes invaluable.

We’ll explore the various methods to achieve this, from using standard Linux utilities like ifdown, ip, and nmcli, to restarting network services and diving into the intricacies of network configuration files. 

Boost Your Website Speed!

If you want your website to run as fast as ours, consider trying Cloudways. Their powerful cloud infrastructure and optimized stack deliver exceptional performance. Free migration!

So, let’s embark on this journey to master the art of restarting network interfaces in Linux, ensuring that your systems stay connected and your network flows smoothly.

  • ifdown <interface_name>
    ifup <interface_name>
  • ip link set <interface_name> down
    ip link set <interface_name> up
  • nmcli connection down <interface_name>
    nmcli connection up <interface_name>
  • nmcli device reapply <interface_name>
    systemctl restart NetworkManager
  • nmcli networking off && nmcli networking on

 

Restart network interface in Linux using the ifdown and ifup command

To restart a network interface in Linux using the ifdown and ifup commands, you can follow these steps:

Identify the Network Interface:

First, you need to determine the name of the network interface you want to restart. You can use the ifconfig or ip command to list all network interfaces:

Using ifconfig (older method, but still available on some systems):

ifconfig -a

Using ip (modern method):

ip link show

Look for the name of the network interface you want to restart, such as “eth0” or “wlan0.”

Disable the Network Interface:

Use the ifdown command to disable the network interface. Replace <interface_name> with the name of the interface you want to restart:

sudo ifdown <interface_name>

For example, if you want to restart “eth0,” you would use:

sudo ifdown eth0

Enable the Network Interface:

After disabling the network interface, use the ifup command to enable it again:

sudo ifup <interface_name>

For example, to enable “eth0,” you would use:

sudo ifup eth0

Verify the Network Interface Status:

You can check the status of the network interface to confirm that it has been restarted and is up and running:

ip link show <interface_name>

If the interface is up and running without any issues, you should see its status information.

By following these steps, you can effectively restart a specific network interface on your Linux system using the ifdown and ifup commands.

Restart network interfaces with ip link set command in Linux

ip link set <interface_name> down
ip link set <interface_name> up

The ip link set command is a versatile and powerful networking command in Linux used for managing network interfaces.

It allows you to configure various aspects of network interfaces, including enabling or disabling them, changing their state, modifying their attributes, and more.

The basic structure of the ip link set command is as follows:

ip link set <interface_name> <action>

  • <interface_name>: This is the name of the network interface you want to modify or configure, such as “eth0” or “wlan0.”
  • <action>: This specifies the action you want to perform on the network interface. It can include setting the interface up or down, changing its attributes, renaming it, and more.

 

Common Actions and Use Cases:

1. Setting the Interface State:

  • up: Enable (bring up) the network interface.
  • down: Disable (bring down) the network interface.

 

Example:

ip link set eth0 up
ip link set wlan0 down

2. Changing Interface Attributes:

You can use the ip link set command to modify various attributes of a network interface, such as its MAC address, MTU (Maximum Transmission Unit), and more.

Example:

ip link set eth0 address 00:11:22:33:44:55
ip link set eth0 mtu 1500

The ip link set command is a fundamental tool for network administrators and system administrators for managing and configuring network interfaces in a Linux environment. It provides flexibility and control over network interface settings, making it an essential part of Linux networking administration.

Restart network interfaces with nmcli command in Linux

nmcli connection down <interface_name>
nmcli connection up <interface_name>

nmcli is a command-line tool for managing NetworkManager, a popular network connection management software used in many Linux distributions. The nmcli tool allows you to interact with NetworkManager to control network connections, view network status, and configure various network-related settings.

The nmcli connection down command is used to bring down (disable) a specific network connection managed by NetworkManager.

Before bringing a connection down, you can use the nmcli connection show command to list all active network connections and their statuses. This can help you identify the connection you want to disconnect.

The basic structure of the nmcli connection down command is as follows:

nmcli connection down <connection_name>

<connection_name>: This is the name or identifier of the network connection you want to bring down. It corresponds to the name of the connection profile defined in NetworkManager.

The nmcli connection down command is commonly used in scenarios where you want to disconnect a specific network connection, such as:

1. Disconnecting ens192:

You can use this command to disconnect ens192 connection. For example:

nmcli connection down ens192

2. Disconnecting VPN Connections:

If you have a VPN connection configured through NetworkManager, you can use nmcli to bring down the VPN connection, terminating the VPN tunnel.

nmcli connection down "My VPN Connection"

We can also use the following ways to reapply the change of network interface.

nmcli device reapply <interface_name>
systemctl restart NetworkManager

The nmcli device reapply <interface_name> command is used in NetworkManager’s nmcli command-line tool to reapply settings to a specific network device (interface).

It can be useful in situations where you want to ensure that any changes made to the device’s configuration are applied immediately without restarting the network or NetworkManager.

The basic structure of the nmcli device reapply command is as follows:

nmcli device reapply <interface_name>

This can include:

IP Address Configuration: If you’ve manually configured IP addresses, subnet masks, or routes for a network interface, you can use nmcli device reapply to ensure that the changes are applied without needing to restart the network.

nmcli device reapply eth0

Immediate Effect:

Unlike some changes to network settings that might require a network service restart or system reboot, nmcli device reapply is designed to have an immediate effect, making it a convenient option for applying changes quickly.

nmcli networking off && nmcli networking on

The nmcli networking off and nmcli networking on commands are used in NetworkManager’s nmcli command-line tool to control the networking state on a Linux system.

They allow you to disable and enable network connectivity. Here’s an introduction to these commands:

nmcli networking off:

When you execute nmcli networking off, it will disconnect all active network connections and prevent new ones from being established.

This command is useful in situations where you want to isolate a system from the network temporarily or perform network maintenance tasks without interruptions from active network connections.

nmcli networking on:

This command is used to turn on networking on the system, enabling network connectivity. This command is typically used after nmcli networking off to re-enable network connectivity.

tohe

Tuesday 5th of September 2023

David,

I learned a lot from your article. Keep up the good work. Thanks.

Henai

Monday 4th of September 2023

Thanks a lot for the info. It is very helpful.