4

When I do a ping to the broadcast address, I get reply from self-loopback 127.0.0.1. Is this scenario correct or should I get reply from the longest-prefix IP?

ping 255.255.255.255
PING 255.255.255.255 (255.255.255.255): 40 data bytes

68 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=2 ms
68 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=1 ms
68 bytes from 127.0.0.1: icmp_seq=3 ttl=64 time=1 ms
68 bytes from 127.0.0.1: icmp_seq=4 ttl=64 time=2 ms
68 bytes from 127.0.0.1: icmp_seq=5 ttl=64 time=1 ms
--- 255.255.255.255 ping statistics ---
5 packets transmitted, 5 packets received, 0% packet loss round-trip min/avg/max/stddev = 1/1/2/<1
4

255.255.255.255 is a broadcast address, you are sending a ping to every device on your local network and you will get a reply from every device. The ping command is only showing the first reply it gets, in your case your own PC (127.0.0.1 is loopback) was the quickest. If you use a packet sniffer (like Wireshark) you will be able to see all replies.

Some devices will reply to a normal ping but will not reply to a ping sent to a broadcast address. This is to prevent an exploit called a Smurf attack.

255.255.255.255 will also broadcast to every device on the internet. For obvious reason this is blocked, the message will not leave your local network.

  • Hi... I am doing the ping 255.255.255.255 on a stand alone router and I have configured nothing but the management IP to the router.. Could you tell me where will the reply to ping come from in this case..!! – Praveen May 15 '14 at 10:24
  • If the only device connected to the network is the router then only the router will reply. Whether it will reply using a loopback address or another address depends on which interface is the quickest (probably the loopback). It should not send multiple replies even if it has multiple addresses – user1793963 May 15 '14 at 11:40
0

short answer : This behaviour could be considered as okay, this only reflect how the route table is setup.

longer answer : You have an order notion in routing table, in order to have more relevant decision you should set first the longest prefix. If you do that the same ping of your example will reflect external IP on your system.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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