by derefr · 4y ago · 0 comments
> IPv4 addresses may be represented in any notation expressing a 32-bit integer value.
I remember reading a man page that explained this really succinctly but I cannot remember which one it was. A tool like ping I believe.
Wow, it actually works: http://127.65530
TIL
https://www.freebsd.org/cgi/man.cgi?query=inet_aton&sektion=...
TL;DR: the second "1" in "1.1" is treated as a 24-bit integer.
Longer explanation: https://blog.dave.tf/post/ip-addr-parsing/
Of course, nobody actually does that anymore. But the parser behavior is still out there because there's the possibility that someone is still using it...
% curl 'http://1.1/'
error code: 1003
while curl 7.85.0 (Release-Date: 2022-08-31, on FreeBSD) says: % curl 'http://1.1/'
<html>
<head><title>301 Moved Permanently</title></head>
<body>
<center><h1>301 Moved Permanently</h1></center>
<hr><center>cloudflare</center>
</body>
</html>If you want to full details, see [0]
[0] https://daniel.haxx.se/blog/2021/04/19/curl-those-funny-ipv4...
I get the same behavior from other nonstandard ways of specifying 1.0.0.1, like "curl http://01.00.00.01/"
% curl --dump-header /dev/tty 'http://1.1/'
HTTP/1.1 403 Forbidden
Date: Sun, 11 Sep 2022 19:01:53 GMT
Content-Type: text/plain; charset=UTF-8
Content-Length: 16
Connection: close
X-Frame-Options: SAMEORIGIN
Referrer-Policy: same-origin
Cache-Control: private, max-age=0, no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Expires: Thu, 01 Jan 1970 00:00:01 GMT
Server: cloudflare
CF-RAY: 7492a7924b2bd895-CPH
error code: 1003
(Note that curl 'https://1.0.0.1/' works just fine, so it's not like curl is blocked by the server on general principle.)With 7.85.0:
% curl --dump-header /dev/tty 'http://1.1/'
HTTP/1.1 301 Moved Permanently
Server: cloudflare
Date: Sun, 11 Sep 2022 19:03:09 GMT
Content-Type: text/html
Content-Length: 167
Connection: keep-alive
Location: https://1.0.0.1/
CF-RAY: 7492a96a181df18a-PIT
<html>
<head><title>301 Moved Permanently</title></head>
<body>
<center><h1>301 Moved Permanently</h1></center>
<hr><center>cloudflare</center>
</body>
</html>[0] https://github.com/curl/curl/commit/56a037cc0ad1b2a770d0c08d...
I suspect you are confused by n.n.n.0/24 being a network address in a /24 network which is obviously very common. However there are way more networks of other sizes that have .0 addresses in them.
It only requires changes within the LAN to accomplish this, since distant hosts are already not supposed to assume anything about how networks are or are not subnetted. (For instance, they don't know whether you're on a /24 or not.)
You can find some addresses ending a lot of zeroes that already work within