Turn off a specific interface

In Linux, sometimes it is not desireable to turn off all your interfaces or restart the service completely. It is possible to turn off a specific interface. First, obtain a listing of interfaces on your system using ifconfig

computer@computer:~$ sudo su -
[sudo] password for computer:
root@computer:~# ifconfig -a
eth0      Link encap:Ethernet  HWaddr 08:00:27:88:92:50
          inet addr:192.168.1.11  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fe88:9250/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:123039 errors:0 dropped:0 overruns:0 frame:0
          TX packets:42301 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:132161504 (132.1 MB)  TX bytes:4126769 (4.1 MB)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:92 errors:0 dropped:0 overruns:0 frame:0
          TX packets:92 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:16226 (16.2 KB)  TX bytes:16226 (16.2 KB)

From this list we can turn off a specific interface. Once again, the ifconfig command can be utilized, but this time we will want to specify the interface and the action to perform

root@computer:~# ifconfig eth0 down

To turn the interface on one can use

root@computer:~# ifconfig eth0 up

This will bring the interface up. Verify with ifconfig to make sure an address is assigned to the correct interface.

Be the first to comment

Leave a Reply