There’s more than one way to write an IP address

Mattias Geniar, Tuesday, July 9, 2019

Most of us write our IP addresses the way we've been taught, a long time ago:,, ... but that gets boring after a while, doesn't it?

Luckily, there's a couple of ways to write an IP address, so you can mess with coworkers, clients or use it as a security measure to bypass certain (input) filters.

Not all behaviour is equal

I first learned about the different ways of writing an IP address by this little trick.

On Linux:

$ ping 0
PING 0 ( 56(84) bytes of data.
64 bytes from icmp_seq=1 ttl=64 time=0.053 ms
64 bytes from icmp_seq=2 ttl=64 time=0.037 ms

This translates the 0 to However, on a Mac:

$ ping 0
PING 0 ( 56 data bytes
ping: sendto: No route to host
ping: sendto: No route to host

Here, it translates 0 to a null-route

Zeroes are optional

Just like in IPv6 addresses, some zeroes (0) are optional in the IP address.

$ ping 127.1
PING 127.1 ( 56 data bytes
64 bytes from icmp_seq=0 ttl=64 time=0.033 ms
64 bytes from icmp_seq=1 ttl=64 time=0.085 ms

Note though, a computer can't just "guess" where it needs to fill in the zeroes. Take this one for example:

$ ping 10.50.1
PING 10.50.1 ( 56 data bytes
Request timeout for icmp_seq 0

It translates 10.50.1 to, adding the necessary zeroes before the last digit.

Overflowing the IP address

Here's another neat trick. You can overflow a digit.

For instance:

$ ping 10.0.513
PING 10.0.513 ( 56 data bytes
64 bytes from icmp_seq=0 ttl=61 time=10.189 ms
64 bytes from icmp_seq=1 ttl=61 time=58.119 ms

We ping 10.0.513, which translates to The last digit can be interpreted as 2x 256 + 1. It shifts the values to the left.

Decimal IP notation

We can use a decimal representation of our IP address.

$ ping 167772673
PING 167772673 ( 56 data bytes
64 bytes from icmp_seq=0 ttl=61 time=15.441 ms
64 bytes from icmp_seq=1 ttl=61 time=4.627 ms

This translates 167772673 to

Hex IP notation

Well, if decimal notation worked, HEX should work too -- right? Of course it does!

$ ping 0xA000201
PING 0xA000201 ( 56 data bytes
64 bytes from icmp_seq=0 ttl=61 time=7.329 ms
64 bytes from icmp_seq=1 ttl=61 time=18.350 ms

The hex value A000201 translates to By prefixing the value with 0x, we indicate that what follows, should be interpreted as a hexadecimal value.

Octal IP notation

Take this one for example.

$ ping
PING ( 56 data bytes

Notice how that last .010 octet gets translated to .8?

Using sipcalc to find these values

There's a useful command line IP calculator called sipcalc you can use for the decimal & hex conversions.

Hi! My name is Mattias Geniar. I'm a Support Manager at Nucleus Hosting in Belgium, a general web geek & public speaker. Currently working on DNS Spy & Oh Dear!. Follow me on Twitter as @mattiasgeniar.

Share this post

Did you like this post? Will you help me share it on social media? Thanks!


worstenbrood Tuesday, July 9, 2019 at 14:22 - Reply

You forgot octal !

name Tuesday, July 9, 2019 at 14:47 - Reply

You forgot Octal. try this:

Mattias Geniar Tuesday, July 9, 2019 at 15:07 - Reply

Ha nice, forgot about that one – updated the post with the octal representation. Thanks!

Mathias Bynens Tuesday, July 9, 2019 at 15:18 - Reply

My all-time favorite is `ping 4.8` which is my go-to for debugging connection issues. Is there a shorter way to ping a live IP?

yes Tuesday, July 9, 2019 at 15:27 - Reply

1.1 responds to ping as well and is even faster to type!

p_l Tuesday, July 9, 2019 at 15:40 - Reply

ping 0 I believe still goes to on Linux – it might have just resolved to, as it’s the equivalent of “connect me to anything”.

Recently I encountered a lot of tutorials/guides/etc that tell people to use as address when connecting to localhost, and sometimes I have to fix it when people encounter the fact that it doesn’t have to resolve to localhost…

Andre Tuesday, July 9, 2019 at 21:01 - Reply

You didn’t even consider representing your v4 address using IPv4 mapped IPv6 address format. example ::ffff: Most networking stacks will recognize you’re talking about an IPv4 address, and will send an IPv4 packet to using your ethernet’s local IPv4 source…even if the destination looks like IPv6.

With this, you could equivalently use variants of like:

Leave a Reply

Your email address will not be published. Required fields are marked *

Inbound links