mastodon.me.uk is one of the many independent Mastodon servers you can use to participate in the fediverse.
Open, user-supported, corporation-free social media for the UK.

Administered by:

Server stats:

504
active users

Coworker: ...and the IP address are compared with a string match.
Me: grinning manically
Coworker: Why are you looking at me like that?
Me: Open up a terminal and type ping 4.2.514 and hit enter.
Coworker: ...what's the fourth number?
Me: grin widens Just hit enter.
Coworker: WTF!?

Chloe Kelly fan account

@ryanc

`ping 8.8.2056`

WTF how am just finding out about this today?

@uastronomer @ryanc

I mean... 2056 is 8*256 + 8, the maths makes sense, but WTFFFFFF?

@pikesley @ryanc Oh.... oh okay, I see!

WOW!

'cos a standard format IPv4 address is technically a 4 digit base256 number, so this is all just base conversions gone screwy 🤣🤣🤣

@uastronomer @ryanc yeah, it's completely cursed

`ping 134744072`

@uastronomer @ryanc

```
>>> (8 * pow(256, 3)) + (8 * pow(256, 2)) + (8 * pow(256, 1)) + (8 * pow(256, 0))
134744072
```

@uastronomer @ryanc

or

```
sum(8 * pow(256, n) for n in range(4))
```

OK stepping away from the Python console now

@pikesley@mastodon.me.uk @uastronomer @ryanc huh, that's not too different from a phone number

@pikesley @uastronomer @ryanc Way back in the 90s I made someone angry with me when I gave the URL for a web site as http://[long number here]/whatever.html. Those were fun times.

@leitzke @pikesley @ryanc @uastronomer Oh, I'm sorry to bring you the bad news.

Here's hoping we live long enough to see him fix his heart or die.

@pikesley @uastronomer @ryanc It’s actually really great, because it’s incredibly painful to do math with dotted decimal strings, especially when the netmasks don’t line up to a byte boundary. It’s much, much easier to convert them to a number and do math on the number.

For example, you can convert an interface’s IP number to an integer, convert its mask to an integer, and do a bitwise AND to get the lowest address. You can then bitwise NOT the mask integer and do a bitwise OR with the lowest address to get the highest address. And you can feed integers to seq or a for loop or whatever.

@uastronomer

>'cos a standard format IPv4 address is technically a 4 digit base256 number,<

not exactly. if you ping 192.1 (example from below), the pinged address ist not 0.0.192.1, but (strangely) 192.0.0.1

but yes, there's some similarity. probably depending on how ping parses this numbers.

@pikesley @ryanc
@Infoseepage

@DanKen @uastronomer @ryanc @Infoseepage

Yeah, `ping` is doing some parsing that other tools... aren't:

```
➜ ping 3107303990
PING 3107303990 (185.53.178.54): 56 data bytes
64 bytes from 185.53.178.54: icmp_seq=0 ttl=51 time=30.992 ms

➜ whois 3107303990
% IANA WHOIS server
% for more information on IANA, visit iana.org
% This query returned 1 object

as-block: 402333-4199999999
organisation: Unallocated
```

www.iana.orgInternet Assigned Numbers Authority

@pikesley @DanKen @uastronomer @Infoseepage I regret to inform you that inet_aton is a very popular dumpster fire.

@pikesley @DanKen @uastronomer @ryanc @Infoseepage

I would not trust whois in all scenarios.

It depends upon which server you ask.

@SpaceLifeForm @DanKen @uastronomer @ryanc @Infoseepage ok, fine, but the client doesn't know how to parse that number into an ipv4 address

@pikesley @DanKen @uastronomer @ryanc @Infoseepage

It could be coded to enforce octets and return an error, but it is lazy coding. Fixing it now could create breakage.

Pick your poison.

@uastronomer @pikesley @ryanc technically an IP address is just a 32bit integer. The dotted quad is just a mind hack because we can more easily remember strings of smaller numbers.

@uastronomer @ryanc

```
>>> IP="185.53.178.54"
>>> sum(int(n) * pow(256, index) for index, n in enumerate(reversed(IP.split("."))))
3107303990
```

Thought about this all over lunchtime

@uastronomer
That's it. I'm just going to document things in Confluence with calculated IPs like 'ping 168433938'

@pikesley @ryanc

@pikesley
Like, when I saw the resulting ping, it made sense... Even though it's insanity.

@uastronomer @ryanc

@pikesley @ryanc makes sense but didn't know either 😯 thanks

@pikesley @ryanc I guess the structure of IPv4 addresses has gone the opposite way to features like this.

eg. datatracker.ietf.org/doc/html/ -- if I have an AUTODIN II address of 5000, it makes sense to write 26.5000 as an IP address, rather than 26.0.19.136

The trend has been the other way: now networks separate out that last octet into multiple fields by putting a subnet boundary there, and there are maybe conceptually *more* than 4 fields?

IETF DatatrackerRFC 796: Address mappings

@pikesley @ryanc eg. I have a subnet 81.2.122.168/29 but a sort of similar use case would be if I could talk about those 8 addresses as:

81.2.122.168.0
...
81.2.122.168.7

without having to fiddle with the last octet myself.

@benc @ryanc I mean maybe, but this all feels like fiddling with the Lament Configuration tbh

@pikesley @ryanc the rfc796 world was a different place, I guess: someone else is allocating their numbers and then they're being *embedded* into the IP address space. That basically doesn't happen any more, so that usecase is gone.

and my subnet proposal was more a "if we were fiddling with the address format" rather than a serious proposal: ipv6 address notation "should"/SHOULD deal with this much better