Question

I have realized that in Linux (RHEL and Debian) incomplete IPv4 address in dot notation are filled with inner zeroes. For example I typed 172.30.122 instead of 172.30.0.122 but Linux corrected and used 172.30.0.122

# ping 172.30.107  

PING 172.30.107 (172.30.0.107) 56(84) bytes of data.  
64 bytes from 172.30.0.107: icmp_seq=1 ttl=62 time=2.19 ms  
64 bytes from 172.30.0.107: icmp_seq=2 ttl=62 time=1.18 ms

At least two bytes are required -- the missing inner bytes are not needed:

# ping 172.107  
PING 172.107 (172.0.0.107) 56(84) bytes of data.

Is this a bug? Does the standards allow that?

Thanx in advance

Was it helpful?

Solution

This is a duplicate question since it was answered before, maybe some more research and you would find the answer :D

There's a Stack Overflow question asking something similar (this post).

The main reason is how inet_aton() (man page) converts the octets into the binary address.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top