Ubuntu

Ubuntu Enable and Disable the Network Interface

When you work as a Linux administrator, all system’s network configuration management is also included in your job. In Linux servers, the interface goes down due to performing any changes on the Network interface card. The network interfaces are either physically or virtually present, you can easily enable the network interface by using several methods that we will discuss in this article.

We will talk about how to enable and disable the network interfaces using various methods in Ubuntu distribution. We have executed all commands on the latest available Ubuntu distribution Ubuntu 20.04 LTS. Let’s start with the details!

Methods to Enable and Disable the Network Interface in Ubuntu 20.04

There are the following different methods are available that can be used to enable and disable your network interface in Ubuntu:

  1. ifconfig command
  2. nmcli command
  3. systemctl command
  4. nmtui command
  5. Ip command
  6. ifdown/ifup

First, you must know about network interface information on your system. The “ip command” can be used for this task. This command shows the network interface card information that is used on your Linux system. To get the information about the network interface card on your Ubuntu system, open the terminal by pressing ‘Ctrl+Alt+t’ and then type the following command on it:

$ ip a

According to the above-displayed output, one network interface ‘enp0s3’ is enabled (up) and working on this system.

Method 01: Enabling/Disabling the Network Interfaces through the ifconfig Command

To run the ifconfig command-line utility, you need to install some required “net-tools” on your Ubuntu system. Therefore, install the following required tools by executing the command given below:

$ sudo apt install net-tools

Now, you can execute the ifconfig command on your Ubuntu system. To disable or down the running network interface, mention the network interface, as shown in the following example:

$ ifconfig enp0s3 down

Now, check the status of the network interface by typing the below-given command:

$ ip a

or

$ ip a | grep -A 1 "enp0s3:"

To enable or activate the specified network interface through the ifconfig utility, use the following command:

$ ifconfig enp0s3 up

Verify the bring up the status of “enp0s3” by executing the following command:

$ ip a

Method 2: Enable/Disable Network Interface Using the nmcli Command

The nmcli is a command-line utility that is used as a replacement for other graphical clients or nm-applet. Using the nmcli utility, you can display, create, update, remove, activate, and deactivate your system network connections. Through this command, you can also display and control the status of all network devices.

The nmcli command displays the “profile name” instead of the device name. So to show the network interface card information, execute the below-mentioned command on the terminal:

$ nmcli con show

Bring Down or Disable the Network Interface Through the nmcli Command

To bring down the displayed network interface, just type the profile name as follows:

$ nmcli con down ‘Wired connection 1

The following output appears on the terminal:

Using the following nmcli command, you can also display the current status network interface device:

$ nmcli dev status

As you can see from the above-displayed result, “Wired connection 1” is deactivated on this system.

Enable or Bring Up the Network Interface Through the nmcli Command

To reactivate or enable the network interface “enp0s3”, type the below-given command:

$ nmcli con up 'Wired connection 1'

Display the status by running the following command:

$ nmcli dev status

Now, the “Wired connection 1” is enabled and running on this system.

Method 3: Enable/Disable Network Interface Using the systemctl Command

The “systemctl” command uses the network manager to set the new configuration for your network to enable and disable the Network Interface Cards. Therefore, if you want to disable or bring down the “enp0s3” interface on your system using the network manager service, you can do so by doing as follows:

$ sudo systemctl disable NetworkManager.service

To re-enable it, run the below-mentioned command:

$ sudo systemctl enable NetworkManager.service

Method 4: Enable/Disable the Network Interface Using the nmtui Command

The nmtui is a text-based user interface mainly used to interact with the Network Manager services. It allows you to configure the network interfaces using the simple text user interface environment.

To display the interface of nmtui, type the following terminal command:

$ nmtui

The following window appears in the terminal through which you can easily manage the network interface configurations. If the network connection is not enabled on your system, then select the following option to activate a connection:

Select the “deactivate” and then choose “OK” to disable the ‘Wired connection 1’ interface on your system.

To enable the network interface, select “Activate” and then “OK”.

Method 5: Bring Up / Down the Network Interface Through the IP Command

Using the IP command, the network interface can be enabled or disabled on your system. To disable or bring down the network interface, execute the below-given command:

$ ip link set enp0s3 down

To enable or reactivate it, use the following command:

$ ip link set enp0s3 up

Method 6: Enable/Disable Network Interface Using ifdown and ifup Command

The ifdown and ifup command does not support the new network interface devices. But if you want to use it for older network devices, then use the following command to bring up and down the network interface device, respectively.

To disable or bring down the network interface status, use the command which is given below:

$ ifdown <network-device-name>

To enable the network interface, use the following command:

$ ifup <network-device-name>

Conclusion

We have seen in this tutorial how to enable and disable the network interfaces on your Ubuntu Linux system using different methods. Use one of the above methods from all based on your need.

About the author

Samreena Aslam

Samreena Aslam holds a master’s degree in Software Engineering. Currently, she's working as a Freelancer & Technical writer. She's a Linux enthusiast and has written various articles on Computer programming, different Linux flavors including Ubuntu, Debian, CentOS, and Mint.