On a LAN each computer is assigned a different IP address each morning. When I installed Kubuntu 12.10 the IP address assigned to the machine was 10.0.0.2
, but today it is 10.0.0.1
. When I try to connect to http://127.0.0.1
in Firefox I see in the status bar Connecting to 10.0.0.2
. However, there is no mention of that address in the /etc/hosts
file:
127.0.0.1 localhost
127.0.1.1 bruno
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
Note that setting the DHCP server to assign the same IP address per MAC address cannot be done as the router is unplugged each evening (electrical issues in the building) and loses the settings.
If
http://127.0.0.1
gets redirected tohttp://10.0.0.2
then it means that the web server listening on127.0.0.1:80
is doing such redirect.So the fault is not of the TCP stack implementation of Linux, nor is there anything wrong with
/etc/hosts
. (Do not confuse host names with IP addresses: host names are resolved, IP addresses are not. In other words, there is no way to make127.0.0.1
"resolve" to10.0.0.2
without using a high-level protocol such as HTTP, which allows redirection from one IP address to another.)Try using
wget
which will give you many useful details. You should see something like the following.Of course, the exact output will vary depending on the situation. However, if you see a similar output, it is evidence that a web server is doing the redirect.
Therefore, to solve the problem, you should look into your web server configuration.
The previous IP address was 10.0.0.2 and now it is 10.0.0.1. If Firefox is now trying to connect to 10.0.0.2 then it must have previously cached that address. Clear Firefox's cache; whatever mechanism previously redirected Firefox from 127.0.0.1 to 10.0.0.2 should now redirect Firefox to 10.0.0.1.