Correct way of bringing network interface down in linux

For example:

$ ifconfig dummy0 up
$ ifconfig dummy0 "192.168.1.190 netmask 255.255.255.0"

Calling ifconfig with no parameters shows the interface

dummy0    Link encap:Ethernet  HWaddr b6:1f:f3:92:6d:20  
      inet addr:192.168.1.190  Bcast:192.168.1.255  Mask:255.255.255.0
      inet6 addr: fe80::b41f:f3ff:fe92:6d20/64 Scope:Link
      UP BROADCAST RUNNING NOARP  MTU:1500  Metric:1
      RX packets:0 errors:0 dropped:0 overruns:0 frame:0
      TX packets:15 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:0 
      RX bytes:0 (0.0 B)  TX bytes:1050 (1.0 KiB)

How can I bring the interface down so that it doesn't show up in

  • ifconfig
  • ifconfig -a
  • ifconfig dummy0

without rmmod dummy

because dummy is used just for example purposes.

If there is no way to do that, what "throw-away" IP could I set to it and be safe from any trouble?

like

$ ifconfig dummy0 down
$ ifconfig dummy0 0.0.0.0

Flush the ip:

root@foo:~# ifconfig dummy0 192.168.55.1 netmask 255.255.255.0
root@foo:~# ifconfig dummy0 
dummy0    Link encap:Ethernet  HWaddr 5b:72:32:4f:92:c8  
          inet addr:192.168.55.1  Bcast:192.168.55.255  Mask:255.255.255.0
          UP BROADCAST RUNNING NOARP  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

root@foo:~# ip address flush dev dummy0
root@foo:~# ifconfig dummy0 down
root@foo:~# ifconfig dummy0 
dummy0    Link encap:Ethernet  HWaddr 5b:72:32:4f:92:c8
          BROADCAST NOARP  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

there is usually a ifdown script on the root shell.

/sbin/ifdown

Throw away IP addresses are out of question.
Unused interfaces should be shutdown.


I used this command to show all interfaces

ip a s

To disable dummy I use two commands (RHEL is so "fascinating")):

ifconfig dummy0 down

ip addr del "your ip" dev dummy0

That worked for me.


to bring interface dummy0 down

ip link set dummy0 down

to bring it up

ip link set dummy0 up