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:
- ifconfig command
- nmcli command
- systemctl command
- nmtui command
- Ip command
- 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:
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:
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:
Now, check the status of the network interface by typing the below-given command:
or
To enable or activate the specified network interface through the ifconfig utility, use the following command:
Verify the bring up the status of “enp0s3” by executing the following command:
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:
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:
The following output appears on the terminal:
Using the following nmcli command, you can also display the current status network interface device:
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:
Display the status by running the following command:
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:
To re-enable it, run the below-mentioned command:
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:
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:
To enable or reactivate it, use the following command:
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:
To enable the network interface, use the following command:
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.