I know that it is possible to write IPs in IPv4 as an integer e.g. 2130706433
instead of 127.0.0.1
.
What is the reason for this possibility
An IPv4 address is just a 32bit number. You could represent it in any way you can represent such a number (decimal, hex, octal). The dotted notation a.b.c.d
is just much more practical.
You can do the same thing with IPv6 addresses, except that those are 128bit numbers - even harder to grok in decimal form.
The usual tools will only deal with usual notations. Decimal isn't one of those.
IPv4 addresses can be represented in multiple ways. For example the default loopback IP can be one of:
The first notation (full 8-bit decimal dotted) is in wide usage, the remaining ones are seldom used but allowed by the inet_addr POSIX standard function. Only the first familiar notation has been retained in the newer inet_ntop/inet_pton POSIX standard functions which process both IPv4 and IPv6 addresses.
With IPv6, 16-bit hexadecimal dotted notation with an optional decimal dotted trailer (for embedded IPv4) and also an optional zero compression is what the standard defines.
eg:
There are then still multiple representations of a single address. To avoid the resulting confusion RFC 5952 recommends a canonical form that allows a unique notation.