Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.
deathstar> ifconfig eth0 down
deathstar> ifconfig -a
eth0      Link encap:Ethernet  HWaddr 00:23:ae:24:f6:76  
          inet addr:192.168.1.30  Bcast:192.168.1.255  Mask:255.255.255.0
          BROADCAST MULTICAST  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:1000 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
          Interrupt:18 

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:70 errors:0 dropped:0 overruns:0 frame:0
          TX packets:70 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:5688 (5.5 KiB)  TX bytes:5688 (5.5 KiB)

wlan0     Link encap:Ethernet  HWaddr 00:22:5f:7c:e7:cc  
          inet addr:192.168.1.37  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::222:5fff:fe7c:e7cc/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:2057 errors:0 dropped:0 overruns:0 frame:6775
          TX packets:2457 errors:1 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:1139421 (1.0 MiB)  TX bytes:346358 (338.2 KiB)
          Interrupt:17 Base address:0xc000


deathstar> iptables -L -n
Chain INPUT (policy ACCEPT)
target     prot opt source               destination         

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination         
deathstar> route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.1.1     0.0.0.0         UG    0      0        0 wlan0
192.168.1.0     0.0.0.0         255.255.255.0   U     0      0        0 wlan0
deathstar> arp -a
D-Link.Home (192.168.1.1) at 1c:7e:e5:b4:e1:6b [ether] on wlan0
deathstar> ping 192.168.1.30 -c 1
PING 192.168.1.30 (192.168.1.30) 56(84) bytes of data.
64 bytes from 192.168.1.30: icmp_req=1 ttl=64 time=0.048 ms

--- 192.168.1.30 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.048/0.048/0.048/0.000 ms

EDIT - IP addr/ip route info

deathstar> ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast state DOWN qlen 1000
    link/ether 00:23:ae:24:f6:76 brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.30/24 brd 192.168.1.255 scope global eth0
15: wlan0: <BROADCAST,ALLMULTI,PROMISC,NOTRAILERS,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
    link/ether 00:22:5f:7c:e7:cc brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.37/24 brd 192.168.1.255 scope global wlan0
    inet6 fe80::222:5fff:fe7c:e7cc/64 scope link 
       valid_lft forever preferred_lft forever


deathstar> ip route show table all
default via 192.168.1.1 dev wlan0 
192.168.1.0/24 dev wlan0  proto kernel  scope link  src 192.168.1.37 
broadcast 127.0.0.0 dev lo  table local  proto kernel  scope link  src 127.0.0.1 
local 127.0.0.0/8 dev lo  table local  proto kernel  scope host  src 127.0.0.1 
local 127.0.0.1 dev lo  table local  proto kernel  scope host  src 127.0.0.1 
broadcast 127.255.255.255 dev lo  table local  proto kernel  scope link  src 127.0.0.1 
broadcast 192.168.1.0 dev wlan0  table local  proto kernel  scope link  src 192.168.1.37 
local 192.168.1.30 dev eth0  table local  proto kernel  scope host  src 192.168.1.30 
local 192.168.1.37 dev wlan0  table local  proto kernel  scope host  src 192.168.1.37 
broadcast 192.168.1.255 dev wlan0  table local  proto kernel  scope link  src 192.168.1.37 
fe80::/64 dev wlan0  proto kernel  metric 256 
unreachable default dev lo  table unspec  proto kernel  metric 4294967295  error -101
local ::1 via :: dev lo  table local  proto none  metric 0 
local fe80::222:5fff:fe7c:e7cc via :: dev lo  table local  proto none  metric 0 
ff00::/8 dev wlan0  table local  metric 256 
unreachable default dev lo  table unspec  proto kernel  metric 4294967295  error -101
share|improve this question
    
What OS is this? Is NetworkManager controlling that device? –  slm Mar 2 at 2:12
    
wheezy - debian wheezy –  Vek.M1234 Mar 2 at 12:45
    
Did you confirm if NetworkManager was managing this device? –  slm Mar 2 at 13:08
    
I did a tcpdump -i lo and can see ping pkts to 192.168.1.30 –  Vek.M1234 Mar 2 at 13:32
    
Are you root when you ran the command ifconfig eth0 down? I just checked this and I was able to down/up the eth0 dev even when managed by NetworkManager. –  slm Mar 2 at 14:38

2 Answers 2

up vote 3 down vote accepted

As you can see from the additional information you provided (the ip route output), the system still has a routing rule for 192.168.1.30:

local 192.168.1.30 dev eth0  table local  proto kernel  scope host  src 192.168.1.30 

The route -n command does not show any of the local routes, it only shows the "main" routing table (equivalent of ip route show table main). The ifconfig and route commands are legacy utilities that aren't updated any more. As such they're missing a lot of functionality present in other tools like the IProute2 suite (which provides the ip utility).

But basically this route means that any traffic to 192.168.1.30 will go directly to the local address.


There is this relevant bit from the Documentation/networking/operstates.txt:

IF_OPER_DOWN (2): Interface is unable to transfer data on L1, f.e. ethernet is not plugged or interface is ADMIN down.

Linux differentiates interface state from IP state. Marking the interface as down simply means that interface cannot communicate with external hosts ("L1" above referring to OSI network model layer 1). The IP itself is still present on the system and can be used.

share|improve this answer
    
via the loopback - which is why i see pkts on that iface –  Vek.M1234 Mar 3 at 4:30

If the network device is being managed by NetworkManager then youmight not be able to use the up/down scripts to manually manage the device. You can confirm if NetworkManager is in charge like so from a command line:

$ nmcli device
DEVICE     TYPE              STATE        
wlp3s0     802-11-wireless   connected    
em1        802-3-ethernet    unavailable  

NOTE: My eth0 device is em1, in this example. Also you can give nmcli short commands, device would be equivalent to d.

Disconnecting

You can tell NetworkManager to disconnect any device that it's managing. You can do so through its GUI or via command line.

disconnect

$ nmcli device disconnect iface wlp3s0
$

check

$ nmcli d
DEVICE     TYPE              STATE        
wlp3s0     802-11-wireless   disconnected 
em1        802-3-ethernet    unavailable  

Repeating your tests in Debian

Just to confirm I di the following in Debian 7.0 in a VirtualBox VM.

$ ifconfig eth0
eth0      Link encap:Ethernet  HWaddr 08:00:27:b6:5f:2e  
          inet addr:10.0.2.15  Bcast:10.0.2.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:feb6:5f2e/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:35 errors:0 dropped:0 overruns:0 frame:0
          TX packets:207 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:5885 (5.7 KiB)  TX bytes:30739 (30.0 KiB)

take device down

$ ifconfig eth0 down
$

confirm

$ ifconfig eth0
eth0      Link encap:Ethernet  HWaddr 08:00:27:b6:5f:2e  
          BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:35 errors:0 dropped:0 overruns:0 frame:0
          TX packets:207 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:5885 (5.7 KiB)  TX bytes:30739 (30.0 KiB)

I had to wait a second for the device to go down. I believe this delay was because NetworkManager was managing the device.

$ cat /etc/debian_version 
7.3
share|improve this answer
    
nope no network-manager: deathstar> dpkg -l|grep network-manager deathstar> –  Vek.M1234 Mar 2 at 13:29
    
did you try ping'ing the IP once the device went down? –  Vek.M1234 Mar 3 at 3:27
    
@paleywiener - no but that shouldn't matter. Why is that what you're doing? –  slm Mar 3 at 3:29
    
if the device (eth0) has an IP mapped to it (in this case 192.168.1.30) and you do: ifconfig eth0 down; surely, the IP is no longer accessible, in which case ping should fail - the trouble here is that ping succeeds. –  Vek.M1234 Mar 3 at 3:37
    
@paleywiener - yes but your issue is the device isn't releasing the IP and isn't going into a down state. That's the root issue. When you run ifconfig eth0 it still reports that it has an IP, right? –  slm Mar 3 at 3:46

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.