Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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.

share|improve this question
    
Which web browser are you using? Please add that information to your question. –  jdthood Jan 9 '13 at 10:38
    
@jdthood: Thanks, I added that the web browser is Firefox. –  dotancohen Jan 9 '13 at 10:40
1  
I don't know why Firefox is trying to connect to 10.* when you type in 127.0.0.1. But you may be able to work around the problem of it connecting to the wrong IP address by making Firefox clear its cache. –  jdthood Jan 9 '13 at 10:47
    
Thanks, jdhood. I've forced the IP address back to 10.0.0.2 so that I could work so I cannot test now, but I think that you're right. Please post your comment an answer so that I could accept it. I will test this later when less fires are burning. –  dotancohen Jan 9 '13 at 10:58
    
Well, we're not sure that the solution works yet. Report back here and I'll craft a suitable answer. :) Also, the more interesting question is, indeed, why trying to connect to 127.0.0.1 results in "connecting to 10.0...". –  jdthood Jan 9 '13 at 11:01

2 Answers 2

up vote 2 down vote accepted

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.

share|improve this answer

If http://127.0.0.1 gets redirected to http://10.0.0.2 then it means that the web server listening on 127.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 make 127.0.0.1 "resolve" to 10.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.

$ wget http://127.0.0.1
--2013-01-09 15:55:38--  http://127.0.0.1
Connecting to 127.0.0.1:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: http://10.0.0.2 [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.

share|improve this answer
    
Thank you, I see via wget that there is no redirect. However, recursively grepping /etc/apache2/ for the string 10.0.0.2 produces no results, either. –  dotancohen Jan 9 '13 at 16:40
    
Does wget work correctly (i.e. which IP address does it use)? The reason I'm asking is this: if wget works correctly, then the problem may be in your web browser (and if this is the case, clearing the cache should help). Please, would you kindly paste the output of wget in your question and also specify which browser are you using? Thanks! –  Andrea Corbellini Jan 9 '13 at 16:46
    
Oops, sorry. I just noticed that the web browser is already specified in your question. –  Andrea Corbellini Jan 9 '13 at 16:47
    
I do agree that the web browser is the issue. I've worked around the issue to get some work done today, but I'm pretty sure that jdthood's comment regarding the browser cache may be right. He won't post it as an answer for me to accept until I test it, though, and I don't know when I'll have opportune to mess up this LAN on purpose! –  dotancohen Jan 9 '13 at 17:40

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.