I have been trying to ban an IP address in iptables that starts with 047, but it would change it to 039.
iptables -v -w -I INPUT 1 -s 047.75.162.122 -j DROP
But the IP address would be banned as 39.75.162.122!
Why do you think this is happening?
This is what is happening:
047
in octal is39
in decimal.You just need to drop the leading
0
.At a guess, this is happening because something in iptables is splitting IPv4 addresses into 4 decimal numbers so it can convert the IP string representation to a long. But that's conjecture.
inet_aton
also accepts a couple of other less usual forms (the manual actually even describes them):They're likely to work on web browsers too.
Prefixing octal numbers with a zero, and hexadecimal numbers with
0x
is at least as old as the C language.