I have an OpenVZ host and running several services on it (mongodb, bitcoind). I only intend to connect to them locally. They all seem to bind to 127.0.0.2 - the venet interface. When I try to access a service at 127.0.0.1 (the default for the clients), I get get no response. However connecting on 127.0.0.2 works fine. I didn't realize it was possible for there to be a difference between the two. What's happening here?
Here's an output of ifconfig:
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:199957 errors:0 dropped:0 overruns:0 frame:0
TX packets:199957 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:15822725 (15.8 MB) TX bytes:15822725 (15.8 MB)
venet0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
inet addr:127.0.0.2 P-t-P:127.0.0.2 Bcast:0.0.0.0 Mask:255.255.255.255
inet6 addr: 2a00:1dc0:2003::adb9:ca98/128 Scope:Global
inet6 addr: 2a00:1dc0:2003::a59d:5802/128 Scope:Global
inet6 addr: 2a00:1dc0:2003::8d9f:638b/128 Scope:Global
inet6 addr: 2a00:1dc0:2003::8638:9f63/128 Scope:Global
inet6 addr: 2a00:1dc0:2003::daef:a10a/128 Scope:Global
inet6 addr: 2a00:1dc0:2003::92b9:5c2a/128 Scope:Global
UP BROADCAST POINTOPOINT RUNNING NOARP MTU:1500 Metric:1
RX packets:389890 errors:0 dropped:0 overruns:0 frame:0
TX packets:341645 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:367108643 (367.1 MB) TX bytes:98312087 (98.3 MB)
venet0:0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
inet addr:178.17.169.91 P-t-P:178.17.169.91 Bcast:178.17.169.91 Mask:255.255.255.255
UP BROADCAST POINTOPOINT RUNNING NOARP MTU:1500 Metric:1
Here's my /etc/hosts file:
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
127.0.0.2 localhost.localdomain localhost
# Auto-generated hostname. Please do not remove this comment.
178.17.169.91 btslots.com btslots
::1 localhost ip6-localhost ip6-loopback
I changed localhost to have it point to 127.0.0.2. I'm surprised that it's possible for two addresses that are in the 127.0.0.1/8 subnet to give different results. All addresses besides 127.0.0.1 act the same (and as expected).
/etc/hostsfile? You may be able to convince it to use 127.0.0.1 by mucking about with the order of lines, names and addresses in there (or you might make a total mess of things, so make a copy first)