Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm running the example in hiredis, which is using "127.0.0.2" as the redis server IP, and it is running properly. Actually, the redis server is running on the same machine. I know that "127.0.0.1" is the IP address of "lo", but how about "127.0.0.2"? Is it the same as "127.0.0.1"?

share|improve this question

migrated from stackoverflow.com Feb 24 '12 at 18:03

This question came from our site for professional and enthusiast programmers.

1 Answer 1

Yes:

The most commonly used IP address on the loopback device is 127.0.0.1 for IPv4, although any address in the range 127.0.0.0 to 127.255.255.255 is mapped to it.

or from the RFC itself:

127.0.0.0/8 - This block is assigned for use as the Internet host loopback address. A datagram sent by a higher level protocol to an address anywhere within this block should loop back inside the host. This is ordinarily implemented using only 127.0.0.1/32 for loopback, but no addresses within this block should ever appear on any network anywhere [RFC1700, page 5].

For fun, try by pinging:

$ ping 127.127.127.127
PING 127.127.127.127 (127.127.127.127) 56(84) bytes of data.
64 bytes from 127.127.127.127: icmp_req=1 ttl=64 time=0.110 ms
64 bytes from 127.127.127.127: icmp_req=2 ttl=64 time=0.065 ms
^C
--- 127.127.127.127 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 999ms
rtt min/avg/max/mdev = 0.065/0.087/0.110/0.024 ms
share|improve this answer
    
The Wikipedia page has since changed, and now says "although any address in the range 127.0.0.1 to 127.255.255.254 is mapped to it", rendering the gist of this answer in direct conflict with Wikipedia. –  SilverSkin Sep 18 '12 at 12:06
3  
@SilverSkin Would you mind explaining what you mean? The only difference between what's in answer and what's in Wikipedia now is that they (correctly) excluded 127.0.0.0 and 127.255.255.255, which are network / broadcast addresses. The gist is still the same - 127.x.x.x == 127.0.0.1 (except for 127.0.0.0 and 127.255.255.255, which is expected on any /8 network). –  icyrock.com Sep 20 '12 at 1:17
    
So there's no difference between binding to 127.0.0.1 versus binding to 127.0.0.124? So why does the hiredis bother with 127.0.0.2, if it's the just the same address? Also what happens if you did send a message to 127.0.0.0? –  CMCDragonkai Jun 14 at 5:30

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.