7

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
leeand00
  • 23,552
Praveen
  • 71

2 Answers2

5

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.

user1793963
  • 213
  • 1
  • 3
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.

Aldrik
  • 1