There’s more than one way to write an IP address
ma.ttias.be
ma.ttias.be
After a while we noticed that a lot of them (around 30%) didn't work on the network. It took a while to figure out that some of the serial numbers got interpreted as octal IP addresses so pinging them didn't resolve through DNS but instead went straight to the (wrong) IP.
In hindsight this could have been predicted but it just shows that often a design that made sense when it was created can cause huge headaches later on. Now we prefix all serial numbers with some letters to make sure they don't get misinterpreted.
Do you actually use serial numbers anywhere else?
Why not generate a random name instead?
Instead of directing them to 192.168.0.1 I'd tell them to enter 3232235521 and it would get the same place. My supervisor called me into the office because someone heard me doing it while snooping a call and it freaked them out.
This is what the parent meant. IPv4 addresses are also syntactically valid host names.
Curious...from the philosophical intent supporting the normative language[1] (my emphasis added):
However, a valid host name can never have the dotted-decimal form #.#.#.#, since at least the highest-level component label will be alphabetic.
Also, to get a full view of DNS, the HTML view of the RFC links to all the updates to DNS over the years: https://tools.ietf.org/html/rfc1035
Which is pretty handy.
It's possible that it was a UK-specific convention that was borne from JANET but I don't know; I do know that PAD and CPAD addresses (from X.25) were more common on JANET than IP addresses, so that seems unlikely.
- 0000:0000:1:2::dead:beef
- ::1:2:0000:0000:dead:beef
- ::1:2:0:0:dead:beef
- ::1:2:0:0:222.173.190.239
- 0:0:1:2::222.173.190.239
- It's possible to stick "::" in many places
- It's possible to have :0000: before or after "::"
- leading zeros (:0001: is the same as :1:)
- "Text Representation of Special Addresses", so the ::192.168.0.1 representation
- hex uppercase vs hex lowercase
[::1:2:0:0:dead:beef]:443
And link-local addresses are mandatory and scoped per interface, so they need a zone id supplied as either an integer or interface name: fe80::1:2:0:0:dead:beef%eth0a.b.c.d, (a * 2^24) + (b * 2^16) + (c * 2^8) + (d * 2^0)
(the first time i did this was the first time I understood raising a constant to zero was one, so I left it there for myself)
The resultant number should be somewhere between 0 and (2^32)-1. It's a neat toy. I'm not sure what value it has in practice.
192 x 2^24 + 168 x 2^16 + 0 x 2^8 + 1 x 2^0 == 3232235521
ping 3232235521 PING 3232235521 (192.168.0.1): 56 data bytes Request timeout for icmp_seq 0 ^C
I've mostly done it to determine a "next" IP address from a large range - i.e, what IP comes after 10.0.0.255, and how can I bound it between 10.0.0.30 and 10.0.1.128?
It's much easier to increment an integer, compare it to other integers, and then convert it back to an string-format IP than it is to implement those operations by "parsing" IP addresses.
for (var i = 0; i < 2 ** 16; i++) {
work("10.0." + i);
}
as opposed to for (var i = 0; i < 2 ** 16; i++) {
work("10.0." + i / 256 + "." + i % 256);
}Here's a JS version:
> const ip2dec = ip => ip.split(".").reverse().reduce((acc, n, i) => acc + (parseInt(n) * (2 ** (i * 8))), 0)
> ip2dec("192.168.0.1")
3232235521
> ip2dec("192.168.1.1")
3232235777
> ip2dec("0xDE.0xAD.0xBE.0xEF")
3735928559Then come the joys of debugging someone's configuration because a tutorial told them to "connect to 0.0.0.0" instead of localhost...
I recall setting 192.168.0.0 as a valid address in windows XP a while ago.
I usually find people in the networking are (especially teachers) to quite stubbornly assume that things are always one way, while almost the entirety of networking is comprised of RFCs.
Sure, default configurations help in that you don't have to change a device's configuration, but I see no reason why I couldn't change my MAC, or set my broadcast address to 10.0.0.42, or the broadcast MAC to 01:02:03:04:05:06, and my gateway to 10.0.0.0 while I enjoy browsing the web on my 0.0.0.0-addressed computer...
Just not valid for a host, as it is a network address where "network" is specified as the whole internet. It's how you create services listening to connections from any address - technically you can setup a listening socket waiting for connections only from specific network, but I haven't tested it.
It's also why minimal compliant IPv4 network has 4 IP addresses: the network address, host 1, host 2, broadcast. There's an unratified RFC for allowing only host 1 and host 2, but I believe it works only on some combinations of gear/software.
Then of course you get systems accepting broken setups, like 192.168.0.0 host address with /24 or /16 netmask.
However, 192.168.1.0/23 is a valid address a host can have.
On a related note, does anyone have a good recommendations/blog post that explains how IP addressing, ports, subnetting, etc. all work?
This is one of these things where I know that I'm just working off of empirical knowledge without knowing the fundamentals.
connect(5, {sa_family=AF_INET, sin_port=htons(1025), sin_addr=inet_addr("0.0.0.0")}, 16) = 0
and then does
getsockname(5, {sa_family=AF_INET, sin_port=htons(56630), sin_addr=inet_addr("127.0.0.1")}, [16]) = 0
I don't see the reason in the documentation of either syscall.
I was thinking it might be due to its subnet being the biggest one one commonly has (/8), but I just set up a (/1), and it still used 127.0.0.1. Even if I set the lo interface down, it still tries 127.0.0.1 and just hangs until I bring it back up. I removed the 127.0.0.1/24 address from lo, and gave lo the address 128.0.0.1/1 with the same options 127.0.0.1/8 had, and that caused `ping 0` to return the error, "connect: Invalid argument". So, I don't know. At least I learned that the behavior seems to really be tied to the address and not the loopback interface, which I though was supposed to abstract the address.
Because it's special cased in ping. Because that's what a relevant RFC says to do.