What this tool does
This IP address converter shows one address in every notation that reaches it. Paste an IPv4 address and you get the dotted quad, the single decimal integer, hexadecimal both as one word and octet by octet, the binary, the octal, the reverse DNS name and the IPv6-mapped form. Paste an IPv6 address and you get the compressed and fully expanded spellings, its nibble-reversed ip6.arpa name and the IPv4 address it carries, when it carries one.
It also accepts the odd inputs, on purpose: 0x7F000001, 0177.0.0.1, 127.1 and 2130706433 are
all read, converted, and annotated with a note explaining how they were read.
An address is a number, not four numbers
An IPv4 address is a single unsigned 32-bit integer. The dots are punctuation for humans: they split the integer into four bytes so it can be read aloud. 192.168.1.1 is 3232235777, and both spellings mean the same 32 bits.
That is why the arithmetic works out the way it does. The first octet is the top eight bits, so a number above 2147483647 has a first octet above 127. A /24 is the block where the top 24 bits are fixed, which is why it holds 256 addresses — the eight loose bits at the bottom.
The four spellings that break URL filters
The parser here follows inet_aton, the C library function that Berkeley Unix shipped in 1983 and that browsers, curl and most HTTP client libraries inherited. It accepts far more than the dotted quad:
- A single integer.
http://2130706433/ishttp://127.0.0.1/. - Fewer than four parts. The last part fills the remaining octets, so
127.1is 127.0.0.1 — the form that madeping 10.1work on every machine you have ever used. - Octal, by leading zero.
0177.0.0.1is 127.0.0.1.010is 8, not 10. - Hexadecimal, by 0x.
0x7F000001is 127.0.0.1 as well.
This is the reason server-side request forgery keeps being found in code that already checks the
destination. A blocklist written as a regular expression against 127\. or 169\.254\. matches
none of the above, while the HTTP client resolves all of them to the address the check meant to
refuse. The lesson is not to write a better regular expression: it is to parse the address into its
32 bits first, decide against the number, and only then let the request go — which is what the
Decimal row here is for.
Mixed forms compose too. 0x7f.1 is valid, and so is 192.168.0x101. Every one of those produces a
note under the results saying which base was used and what the part came to.
IPv6, written the way RFC 5952 asks
IPv6 gives you 128 bits in eight groups of four hex digits, and it allows several spellings of the
same address. RFC 5952 picks one so that two systems logging the same address produce the same
string: lowercase, no leading zeros in a group, :: over the longest run of zero groups only, the
first such run when two tie, and never for a single zero group.
The tool shows both the canonical short form and the full 39-character expansion, which is the one
to use when you are sorting addresses as text or building a reverse zone. If the address ends in
::ffff: plus 32 bits, it is an IPv4 address inside an IPv6 socket, and the embedded address is
reported separately.
Working out how much of an address a prefix covers is the CIDR calculator next door. For the same numbers in bases that have nothing to do with addressing, use the number base converter.