Jack wrote:
--- Gerald Combs [email protected] wrote:
What happens when you run
ping 0x7f.1
and why?
Same thing that happens if you ping 127.1 or 127.0.0.1 or 12.1 or 0xc.1 or 0x7c.0xf1 or ...
ping translates it as x.0.0.y and runs the query.
I would say that this is a bug in ping, that it would allow x.y to be evaluated as a complete ip address. But what is going on is that ping is calculating the address based on the first and last dot numbers and fills in the blanks with zeros. if you want the RFC explanation for it, I'd have to look it up. I don'ty keep that kind of trivia in my head, hell I have a hard enough time keeping in the important stuff. ;')
The behavior is on purpose, and happens when ping passes the address to the inet_aton() function. inet_aton() tries its best to convert anything you hand it to an IP address -- if the bytes are decimal, hexadecimal, or octal it will convert them accordingly. If there are bytes missing, e.g. 127.1, it will fill the middle bytes with zeroes. If there is just one value (no dots), it will convert it to an unsigned 32-bit integer. As far as inet_aton() is concerned, these are all equivalent:
127.0.0.1 0x7f000001 0177.1
The man page has more information (under "Internet Addresses"):
http://www.freebsd.org/cgi/man.cgi?query=inet_aton&sektion=3