How to bring a network interface up or down in Linux

Home > Search > How-to
  by

Before bringing an interface up or down, the ip addr or ifconfig commands can be used to determine if the interface is currently up or down. In this example, both interfaces are UP. 

[root@server1 ~]# ip addr
. . .
2: eth0:  <BROADCAST,MULTICAST,UP,LOWER_UP) mtu 1500 qdisc pfifo_fast state UP qlen 1000
. . .
3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP) mtu 1500 qdisc pfifo_fast state UP qlen 1000
. . .
[root@server1 ~]# ifconfig
eth0    Link encap:Ethernet  HWaddr 61:f3:b2:7b:21:1c
        UP BROADCAST MULTICAST MTU: 1500 Metric: 1
. . .
wlan0   Link encap:Ethernet  HWaddr 70:f3:c4:9c:53:2d
        UP BROADCAST RUNNING MULTICAST MTU: 1500 Metric: 1
. . .

 

If eth0 or wlan0 are not listed in /run/network/ifstate, STDERR "ifdown: interface xxxx not configured" will be displayed. "auto eth0" and "auto wlan0" must be listed in /etc/network/interfaces in order for /run/network/ifstate to have the following:

[root@server1 ~]# cat /run/network/ifstate
lo=lo
eth0=eth0
wlan0=wlan0

 

The ifup and ifdown commands can be used to bring up or bring down an interface. For example, to bring up or bring down the interface named eth0.

[root@server1 ~]# ifup eth0
[root@server1 ~]# ifdown eth0

 

The -a or --all option with ifup or ifdown will bring up or bring down every interface. If using /etc/network/interfaces, auto x (where x is the name of the interface) must be included.

[root@server1 ~]# ifup -a
[root@server1 ~]# ifdown -a

 

The ip link option can alsoi be used to bring an interface up or down.

[root@server1 ~]# ip link dev eth0 up
[root@server1 ~]# ip link dev eth0 down

 

The ifconfig command can also be used to bring an interface up or down.

[root@server1 ~]# ifconfig eth0 up
[root@server1 ~]# ifconfig eth0 down

 

The ifquery -l command can be used to list every interface. If using /etc/network/interfaces, auto x (where x is the name of the interface) must be included. Or, you could simply using cat /etc/network/interfaces.

[root@server1 ~]# ifquery -l

 



Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.




Please enter in the box below so that we can be sure you are a human.




Comments