Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

When I down the loopback interface and try to ping my own IP, it's showing 100% packet loss, even when my eth0 is up. Why is this?

Here's what I did:

root@faisal-desktop# ifconfig lo down
root@faisal-desktop# ping -I eth0 172.16.10.112 -c 2
PING 172.16.10.112 (172.16.10.112) from 172.16.10.112 eth0: 56(84) bytes of data.

--- 172.16.10.112 ping statistics ---
2 packets transmitted, 0 received, 100% packet loss, time 1007ms

root@faisal-desktop# ifconfig
eth0     Link encap:Ethernet  HWaddr 6c:f0:49:f6:82:03  
         inet addr:172.16.10.112  Bcast:172.16.10.255  Mask:255.255.255.0
         inet6 addr: fe80::6ef0:49ff:fef6:8203/64 Scope:Link
                          .
                          .

Check the ifconfig TX packets count

root@faisal-desktop# ifconfig 
eth0  Link encap:Ethernet  HWaddr 6c:f0:49:f6:82:03  
      inet addr:172.16.10.112  Bcast:172.16.10.255  Mask:255.255.255.0
      inet6 addr: fe80::6ef0:49ff:fef6:8203/64 Scope:Link
      UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
      RX packets:25822 errors:0 dropped:0 overruns:0 frame:0
      TX packets:24825 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:1000 
      RX bytes:19581301 (19.5 MB)  TX bytes:4013322 (4.0 MB)
      Interrupt:26 Base address:0x6000 

root@faisal-desktop# ping -c 1 -I eth0 172.16.10.112
PING 172.16.10.112 (172.16.10.112) from 172.16.10.112 eth0: 56(84) bytes of data.

--- 172.16.10.112 ping statistics ---
1 packets transmitted, 0 received, 100% packet loss, time 0ms

root@faisal-desktop# ifconfig 
eth0  Link encap:Ethernet  HWaddr 6c:f0:49:f6:82:03  
      inet addr:172.16.10.112  Bcast:172.16.10.255  Mask:255.255.255.0
      inet6 addr: fe80::6ef0:49ff:fef6:8203/64 Scope:Link
      UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
      RX packets:25840 errors:0 dropped:0 overruns:0 frame:0
      TX packets:24845 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:1000 
      RX bytes:19588641 (19.5 MB)  TX bytes:4017338 (4.0 MB)
      Interrupt:26 Base address:0x6000
share|improve this question

migrated from stackoverflow.com Aug 12 '11 at 11:18

This question came from our site for professional and enthusiast programmers.

3 Answers 3

up vote 3 down vote accepted

I got the answer
Pinging to same interface uses loopback interface only. Check here
And one doubt, in which function/module does the ip checking and replacing with loopback?

Loopback

share|improve this answer
    
It doesn't say "pinging to the same interface." it says "Anything sent to one of the host's own IP addresses is sent to the loopback interface." It also says "a loopback interface [...] allows a client and server on the same host to communicate with each other using TCP/IP." The implication is that without a loopback interface this is not possible. –  RedGrittyBrick Aug 16 '11 at 9:31
    
Yea thats it. I have a doubt, do you know in which module / function that comparison happens? –  Faisal Aug 16 '11 at 10:05
    
Alright, but i couldn't find it. Can anyone point out the file/function which is responsible for comparing packets(sending out) destination ip with interfaces ip, and changing to loopback !!. –  Faisal Aug 17 '11 at 6:27
    
I doubt its in $(KERNEL_SOURCE)/net/ipv4/route.c –  Faisal Aug 17 '11 at 12:38

Why does ping to the same interface fail when loop-back is down?

Because you don't ping an interface you ping an IP-address.

Your operating system works out which interface is the most appropriate one to use based on the target IP-address. If the target IP-address is your own, the most appropriate interface to use is the loopback interface as it has the lowest overheads.

share|improve this answer
    
Agreed but now there is no loopback interface, so it should use other appropriate one. But it is not even calling the driver start_xmit function. –  Faisal Aug 16 '11 at 4:49

Yep, it's simply verify ("via dev lo"):

# ifconfig eth0
eth0      Link encap:Ethernet  HWaddr 08:00:27:8b:38:0c
          inet addr:10.0.2.15  Bcast:10.0.2.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fe8b:380c/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:539 errors:0 dropped:0 overruns:0 frame:0
          TX packets:550 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:60478 (59.0 KiB)  TX bytes:38274 (37.3 KiB)

# ip ro get 10.0.2.15
local 10.0.2.15 dev lo src 10.0.2.15
    cache 
share|improve this answer

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.