How to Disable and Enable Network Interface in Linux

This guide will go through how to disable and enable network interface in Linux. As a Linux user or system admin, you are required to be conversant with how to enable or disable network interface so as to fix some of the network issues that may occur while you are using Linux. Let’s dive in and look at most of the common commands used to disable or enable network interfaces.

How to Disable and Enable Network Interface in Linux

  • Start by getting your network interface information by using the command below.
ip a

Sample output

1: lo:  mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: ens33:  mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 00:0c:29:c3:bb:0f brd ff:ff:ff:ff:ff:ff
    altname enp2s1
    inet 192.168.171.144/24 brd 192.168.171.255 scope global dynamic noprefixroute ens33
       valid_lft 1326sec preferred_lft 1326sec
    inet6 fe80::b75c:74e1:9a32:d195/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever

The network interface on the above sample output is ens33

Disable and Enable Network Interface using ifconfig Command

  • Install net-tools on your system, in the example below we will use Debian based system.
sudo apt install net-tools
  • Next, disable your network using the following command. Note, replace ens33 with your interface name.
sudo ifconfig ens33 down
  • You can check your network interface status to confirm it’s down using the command below.
ip a

Sample output

1: lo:  mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: ens33:  mtu 1500 qdisc fq_codel state DOWN group default qlen 1000
    link/ether 00:0c:29:c3:bb:0f brd ff:ff:ff:ff:ff:ff
    altname enp2s1
  • To enable your network interface using ifconfig run the following command.
sudo ifconfig ens33 up
  • Check its status again to confirm it’s up.
ip a

Sample output

1: lo:  mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: ens33:  mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 00:0c:29:c3:bb:0f brd ff:ff:ff:ff:ff:ff
    altname enp2s1
    inet 192.168.171.144/24 brd 192.168.171.255 scope global dynamic noprefixroute ens33
       valid_lft 1769sec preferred_lft 1769sec
    inet6 fe80::b75c:74e1:9a32:d195/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever

Disable and Enable Network Interface using nmcli Command

  • The nmcli Command uses name instead of device. Use the nmcli command below to show your network info.
nmcli con show

Sample output

NAME                UUID                                  TYPE      DEVICE 
Wired connection 1  c848fb7a-225a-3c00-b9d4-6cc2f5f29e47  ethernet  ens33 
  • To disable your network interface, use the following command.
sudo nmcli con down 'Wired connection 1'

Sample output

Connection 'Wired connection 1' successfully deactivated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/2)
  • Check interface status.
nmcli dev status

Sample output

DEVICE  TYPE      STATE         CONNECTION 
ens33   ethernet  disconnected  --         
lo      loopback  unmanaged     -- 
  • Enable network interface using nmcli Command.
sudo nmcli con up 'Wired connection 1'

Sample output

Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/3)

Disable and Enable Network Interface using IP Command

  • To disable the network interface run the command below.
sudo ip link set ens33 down
  • To enable the network interface run the following command.
sudo ip link set ens33 up
  • You have made it to the end of our article on how to disable and enable network interface in Linux.

Read more about network interface commands

Other Tutorials

How to find path to a command in Linux

How to kill a process in Linux

How to find a file in Linux

System administrator | Software Developer | DevOps

Leave a Comment