Incomplete IP address filled with zeros

I realized that on Linux (RHEL and Debian) an incomplete IPv4 address in dotted notation is filled with internal zeros. For example, I typed 172.30.122 instead of 172.30.0.122, but Linux fixed 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 - missing internal bytes are not needed:

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

This is mistake? Do these standards comply?

Thanx in advance

+4
source share
1 answer

This is a recurring question, as it was answered, perhaps a few more studies, and you will find the answer: D

There is a question about a stack overflow with a question about something like this ( this post ).

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

+1
source

Source: https://habr.com/ru/post/1492874/


All Articles