News for hackers. Stuff that matters.
Re:This is a valid ipv4 address by nwh on Sunday October 20, 2013 @01:47PM (#6580697)
The decoded URL for this submission is http://184.172.10.74/ — the server for Hacker News.

Here's some other encodings you can use for the same address, they're all valid and recognised by most browsers and other software:

http://3098282570/

http://7393249866/

http://0xb8.0xac.0x0a.0x4a/

http://0270.0254.0012.0112/

The source for this comment is an XSS filtering bypass tool by RSnake — http://ha.ckers.org/xsscalc.html

Re:This is a valid ipv4 address by bdarnell on Sunday October 20, 2013 @02:29PM (#6580876)
More weird formats (which at least work in chrome/mac, and the mac implementation of getaddrinfo()):

http://184.11274826/ http://184.172.2634/

The rule here is that the last (but apparently only the last) numeric component may encode multiple bytes.

Re:This is a valid ipv4 address by phaker on Sunday October 20, 2013 @03:31PM (#6581155)
I use this one all the time:

127.0.0.1 == 127.1

10.0.0.1 == 10.1

192.168.0.1 == 192.168.1

Re:This is a valid ipv4 address by nwh on Sunday October 20, 2013 @03:34PM (#6581164)
I wasn't aware of that shortcut, that's very useful.
Re:This is a valid ipv4 address by kbenson on Monday October 21, 2013 @01:20AM (#6583514)
It's especially useful for some IPv6 addresses.
Re:This is a valid ipv4 address by ordinary on Monday October 21, 2013 @06:34AM (#6584548)
IPv6 has a different representation format, where one (and only one) sequence of fields containing only 0 bytes may be replaced by a single '::', turning '2001:0:0:1:0:2' into '2001::1:0:2'.

I never quite understood why they chose to reuse the colon as a separator character, because this is problematic when you want to append a port number. '2001::1:0:2:8080' could either be '2001:0:0:1:0:2 on port 8080', or '2001:0:1:0:2:8080 on the default port'. The following (ugly) syntax is used to resolve that ambiguity: [2001::1:0:2]:8080.

Re:This is a valid ipv4 address by peterwwillis on Monday October 21, 2013 @10:44AM (#6585876)
More IPv6 hackery: When using a link-local address (every interface has a link-local IPv6 address), you can append a zone index to the address in the brackets as routing information of where to send the link local request. For windows it's the interface number, for Unixes it's the interface name.

To test this out, first find a link-local address on your network. To find all link-local addresses on eth0, use this command to ping the all-nodes link-local multicast group:

  ping6 -I eth0 -c 2 ff02::1
Now append the percent sign and zone index to the address and connect to the host on a port that is probably open.

  lynx https://[fe80::21e:67ff:fe08:d500%eth0]:443/
Re:This is a valid ipv4 address by SneManden on Monday October 21, 2013 @02:07AM (#6583649)
I often use 0 == 0.0.0.0 == localhost
Re:This is a valid ipv4 address by ClashTheBunny on Monday October 21, 2013 @03:47AM (#6583985)
This is not true. 0.0.0.0 may end up at localhost for you, but it's not localhost. I just get: PING 0.0.0.0 (0.0.0.0): 56 data bytes ping: sendto: No route to host

Which system do you use that this works on?

Re:This is a valid ipv4 address by reidrac on Monday October 21, 2013 @05:35AM (#6584383)
I don't know about the OP, but in Ubuntu Precise "ping 0" pings to 127.0.0.1.

I can't explain why.

Re:This is a valid ipv4 address by ordinary on Monday October 21, 2013 @06:45AM (#6584580)
From what I can tell, the use of '0' or '0.0.0.0' as a destination address is not official. It should only be used as a source address. From RFC 5735 - Special USe IPv4 Addresses:

   0.0.0.0/8 - Addresses in this block refer to source hosts on "this"
   network.  Address 0.0.0.0/32 may be used as a source address for this
   host on this network; other addresses within 0.0.0.0/8 may be used to
   refer to specified hosts on this network.
Support for it looks to be flaky. 'ping 0' and 'ping 0.0.0.0' work for me on various Linuxes ("64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.026 ms"), but not on Windows 7 ("sendto: Cannot assign requested address") or Windows Server 2003 ("Destination specified is invalid").
Re:This is a valid ipv4 address by reidrac on Monday October 21, 2013 @07:11AM (#6584667)
IPv6 behaviour seems to be the same: "ping6 ::" pings to ::1: (localhost).

This is intriguing, really :)

EDIT: oh, you already pointed to the RFC :)

Re:This is a valid ipv4 address by laumars on Monday October 21, 2013 @09:59AM (#6585542)
My understanding is that 0.0.0.0 is the opposite of localhost as binding a daemon to 0 would bind that service to every interface and on any available IP. This means if you have MySQL (for example) listening on 0, it's not just listening on your localhost address but also on any WAN / LAN IPs you have as well.
Re:This is a valid ipv4 address by pahans on Monday October 21, 2013 @06:29AM (#6584539)
aha. i didnt know this. thanks
Re:This is a valid ipv4 address by lcedp on Sunday October 20, 2013 @02:06PM (#6580784)
I didn't use bypass tool you've mentioned.

This small ruby script

    #!/usr/bin/ruby
    a, b, c, d = $*[0].split('.').map(&:to_i)
    i = a * 256**3 + b * 256**2 + c * 256 + d
    puts "dec: http://#{i}"
    puts "hex: http://0x#{i.to_s(16)}"
    puts "oct: http://0#{i.to_s(8)}"
..yields the following:

    % ip2dword 184.172.10.74
    dec: http://3098282570
    hex: http://0xb8ac0a4a
    oct: http://027053005112
Re:This is a valid ipv4 address by nwh on Sunday October 20, 2013 @02:20PM (#6580845)
My apologies, I've removed that line.
Re:This is a valid ipv4 address by bskap on Sunday October 20, 2013 @02:44PM (#6580939)
Looks like Internet Explorer recognizes them all as the same address (when I hover over the link, it shows the link target in dotted decimal). Chrome does the same thing for 1, 3, and 4 but doesn't like the number > INT_MAX. Firefox thinks they're all different.
Re:This is a valid ipv4 address by ColinDabritz on Sunday October 20, 2013 @01:53PM (#6580724)
I recognize the other formats, but what format is "http://7393249866/"? It opens about:blank in chrome. How is it distinguished from the format above it?
Re:This is a valid ipv4 address by agwa on Sunday October 20, 2013 @01:57PM (#6580745)
7393249866 mod 2^32 is 3098282570. I'm not convinced you can do that - although it works in Firefox, telnet and ping don't like it.

Edit: I highly doubt that this is standard behavior. I suspect that implementations that permit this are storing the number in a 32 bit integer and not checking to see that it was truncated.

Re:This is a valid ipv4 address by nwh on Sunday October 20, 2013 @02:00PM (#6580760)
ping and other command line tools don't mind it for me on OSX, I don't know what the distinction between them would be though.

    $ ping 7393249866
    PING 7393249866 (184.172.10.74): 56 data bytes
    64 bytes from 184.172.10.74: icmp_seq=0 ttl=47 time=259.042 ms
Re:This is a valid ipv4 address by ColinDabritz on Sunday October 20, 2013 @02:06PM (#6580785)
It seems to work in Safari as well. I sort of understand the dword format, but why would this be useful, or a standard?
Re:This is a valid ipv4 address by somejan on Sunday October 20, 2013 @05:47PM (#6581658)
Funny. http://7393249866/ resolves to http://255.255.255.255/ in Opera (on linux), it appears to do saturating math for the overflow.
Re:This is a valid ipv4 address by Vektorweg on Sunday October 20, 2013 @08:26PM (#6582289)
It works fine in my Opera 12.16 for Linux (amd64).
Re:This is a valid ipv4 address by laumars on Monday October 21, 2013 @10:01AM (#6585550)
Same here:

    $ uname -a
    Linux GFMPC-056 3.11.2-1-ARCH #1 SMP PREEMPT Fri Sep 27 07:35:36 CEST 2013 x86_64 GNU/Linux
Re:This is a valid ipv4 address by Dylan16807 on Sunday October 20, 2013 @02:12PM (#6580812)
You can also mix and match octal, decimal, and hex on the different octets.
Re:This is a valid ipv4 address by p4bl0 on Sunday October 20, 2013 @06:35PM (#6581850)
Hexa addresses can be in one single number too:

http://0xb8ac0a4a/

Re:This is a valid ipv4 address by thaumasiotes on Sunday October 20, 2013 @07:48PM (#6582126)
What? It's bothered me for years that IP addresses aren't just bitfields. Why would you use a format other than this?
Re:This is a valid ipv4 address by zheng on Sunday October 20, 2013 @08:57PM (#6582433)
10.0.0.1 or 0x0a000001?

4.2.2.1 or 0x04020201?

Mostly readability and speed of typing, I would think.

Re:This is a valid ipv4 address by tyilo on Sunday October 20, 2013 @01:56PM (#6580740)
http://7393249866/ doesn't seem to work in chrome as it doesn't believe it's a link. Entering it directly in the URL-bar doesn't work either. All of the others is shown as `184.172.10.74` on mouse-over.
Re:This is a valid ipv4 address by bloometal on Sunday October 20, 2013 @05:07PM (#6581489)
Went to RSnake's website and encoded the address of Facebook to post on my wall. Facebook does not let me post it. After 3 or 4 tries, it blocked my account.

Does anyone know why Facebook does that?

Re:This is a valid ipv4 address by icedchai on Sunday October 20, 2013 @05:20PM (#6581547)
Probably because this "trick" is often used by spammers to obfuscate URLs.
Re:This is a valid ipv4 address by throwawaykf on Monday October 21, 2013 @01:05AM (#6583462)
More encodings:

http://[0:0:0:0:0:ffff:b8ac:a4a]

http://asdf:qwerty@3098282570/

http://asdf:qwerty@[0:0:0:0:0:ffff:b8ac:a4a]:80

(Might get a security/phishing warning on the last two links in some browsers.)

Re:This is a valid ipv4 address by throwawaykf on Monday October 21, 2013 @09:04AM (#6585176)
And another way of doing the first one:

http://[0::0:ffff:b8ac:a4a]/

Re:This is a valid ipv4 address by icoder on Monday October 21, 2013 @05:39AM (#6584398)
No warnings in Chrome