Probable DNS resolution bug with IP with 0 on the leading edge

I noticed a curious thing when performing operations on IPv4 by prefixing one of its components with a 0, which forces it to be interpreted as MAC, IPv6, or DNS. For example "ping 1.1.1.1" is equal to ping "1.1.1.01" when compare numbers "01" and "1" are equals, but:


I've noticed this behavior in versions 7.18 and 7.20. I haven't validated it in versions 6.x.

I should note that Linux ping implementations are able to discard the leading 0 and correctly interpret the address.

On windows also hex numbers are accepted (good):

C:\test>ping 1.1.1.0xA

Esecuzione di Ping 1.1.1.10 con 32 byte di dati:

Risposta da 1.1.1.10: byte=32 durata=49ms TTL=54
Risposta da 1.1.1.10: byte=32 durata=49ms TTL=54
Risposta da 1.1.1.10: byte=32 durata=49ms TTL=54
Risposta da 1.1.1.10: byte=32 durata=49ms TTL=54

BUT even octal numbers are, which can create confusion:

C:\test>ping 1.1.1.011

Esecuzione di Ping 1.1.1.9 con 32 byte di dati:

Risposta da 1.1.1.9: byte=32 durata=48ms TTL=54
Risposta da 1.1.1.9: byte=32 durata=47ms TTL=54
Risposta da 1.1.1.9: byte=32 durata=47ms TTL=54
Risposta da 1.1.1.9: byte=32 durata=47ms TTL=54

So that Mikrotik strictly requires a "proper" decimal without leading zero(es) doesn't seem to me like a bad idea.

I see that Linux also interprets a component preceded by 0 as octal, which I understand doesn't apply since IPv4 is written as four decimal parts separated by ".", but that's a matter of interpretation.

I tried normalizing with "toip" but that also fails:

image

Funny facts also ping and some browsers also accept just a integer:

@ldelabarra
Your 01 (up to 07) are valid octals and they are the same as 1-7, so there are no issues.

In Windows (you could try in Linux to see what happens, if different), BOTH:
ping 1.1.1.08
AND
ping 1.1.1.010
come out as pinging 1.1.1.8

and as well
ping 1.1.1.09
and
ping 1.1.1.011
both ping 1.1.1.9

Probably, since 08 and 09 are not valid octal numbers, they are parsed as decimal by simply removing the leading 0, but then 010 is converted (correctly) to 8, 011 to 9, etc.

Under Linux both the ping tools from Coreutils and BusyBox (it's only a symlink to busybox) reject the .08 and .09 addresses.