How to Enable/Disable Network Interface Port in Linux

Estimated reading: 4 minutes 249 views

In servers, physical or virtual network interfaces can be enabled or disabled by running some commands.

If any change is performed in NIC due to which the interface is down, the interface can be brought up through multiple ways but we would like to suggest the six best methods as mentioned below:

Commands as follows:

  • ifconfig command: ifconfig command is used to configure a network interface. It provides a lot of information about NIC.
  • ifdown/ifup Command: The ifdown command brings the network interface down whereas the ifup command brings the network interface up.
  • ip Command: The ip command is used to manage NIC. It is a replacement of the old and deprecated ifconfig command. It is similar to the ifconfig command but has many powerful features that are unavailable with the ifconfig command.
  • nmcli Command: nmcli is a command-line tool for controlling the Network Manager and reporting network status.
  • systemctl command: the systemctl command is a tool that is responsible for controlling the systemd system and service manager.
  • nmtui Command: nmtui is a curses‐based TUI application that interacts with the network manager.

ip command shows the available network interface card information in the Linux system. According to the below output, network interfaces (eth0) are up and running in the system

1. Bring UP/Down the Network Interface, using the ifconfig command

ifconfig runs at boot time to set up network interfaces and provides a lot of information about the NIC. In this example, let us see, how to bring up and down the interface using the ifconfig command.

Common Syntax for ifconfig:

# ifconfig [NIC_NAME] Down/Up

Run the following command to bring down the eth0 interface in the system. Please remember to enter the interface name of your system, instead of “eth0” as mentioned in this example.

# ifconfig eth0 down

As per the following output, the eth0 interface is down

Please run the following command to bring up the eth0 interface

# ifconfig eth0 up

“eth0 ” interface status can be further verified by running the following command

2. Enable and disable the Network Interface using the ifdown/ifup command

The ‘ifdown’ command brings the Network interface down whereas the ‘ifup’ command brings the Network interface up.

Note: These commands does not work on new interface device bearing the names enpXXX.

Common Syntax for ifdown/ifup:

# ifdown [NIC_NAME]

# ifup [NIC_NAME]

Run the following command to bring down the eth0 interface

# ifdown eth0

Run the following command to bring up the eth0 interface

# ifup eth0

As mentioned earlier, ifup and ifdown do not support the latest interface device bearing names such as enpXXX. An unknown interface message will appear when executed.

# ifdown enp0s8
Unknown interface enp0s8

3. Bringing UP/Down Network Interface using ip command

In this example, let us discuss how to bring Up/Down the Network interface using the ip command.

Common Syntax for ip:

# ip link set  Down/Up

Run the following command to bring down the eth0 interface

# ip link set eth0 down

Run the following command to bring up the eth0 interface

# ip link set eth0 up

4. Bringing UP/Down Network Interface using systemctl command

The ‘systemctl’ command can be used to apply a new configuration for the network service which brings down and brings up all the Network Interface Cards (NICs) to load the new configuration

To disable Network Service use the command

# systemctl stop NetworkManager.service

# systemctl disable NetworkManager.service

To enable Network Service use the command

# systemctl start NetworkManager.service
# systemctl enable NetworkManager.service

To restart Network Service use the command

# systemctl restart network
or
# systemctl restart network.service

5. Bringing UP/Down Network Interface using the nmtui tool

nmtui is a curses-based TUI application used for interacting with Network Manager.

It allows us to easily configure the network interfaces on Linux systems using GUI.

Run the following command to launch the nmtui interface. Select “Activate a connection” and hit “OK”

# nmtui

Select the desired interface to bring down and then hit the “Deactivate” button.

For activation, please perform the same procedure as above.

Conclusion

We have discussed and implemented two simple methods to disable, and then enable the network interfaces in  Linux System. Make sure to not miss any step while implementing these methods on your server Linux system for best results.

Good Luck!

Share this Doc

How to Enable/Disable Network Interface Port in Linux

Or copy link

CONTENTS