after updating to Ubuntu 10.10, the hostname settings are no longer correct. The content of the /etc/hosts is modified at each startup to something like:       mariusbotis     localhost.localdomain   localhost
::1     mariusbotis     localhost6.localdomain6 localhost6      mariusbotis     mariusbotis.office

Do you have any idea how to get rid of the first two lines? Just editing them will not help: after the next restart, the lines are back there. The problem is that the network now resolve my hostname to, instead of the

~:$ ping mariusbotis
PING mariusbotis ( 56(84) bytes of data.
64 bytes from mariusbotis ( icmp_req=1 ttl=64 time=0.022 ms
64 bytes from mariusbotis ( icmp_req=2 ttl=64 time=0.023 ms
64 bytes from mariusbotis ( icmp_req=3 ttl=64 time=0.021 ms
64 bytes from mariusbotis ( icmp_req=4 ttl=64 time=0.022 ms

To add to the discussion, I just upgraded from Ubuntu 10.04 to Ubuntu 10.10 and I'm having a similar problem as botismarius. I'm developing web applications on my laptop and I'm using aliases in the /etc/hosts file that are used by apache2 as the virtual hostname.

The /etc/hosts file was not overwritten in 10.04 but it is now being overwritten in 10.10. I simply want to paste "test1.local" to the end of the localhost line but it gets lost every time I reboot.

Update: I figured out how to keep NetworkManager from overwriting the changes. Don't add aliases to the localhost line, add them to the " your-machine-name" line.


|improve this answer|||||
  • interesting. I wonder why in this case a ping to your-machine-name does not respond from (IP address that is from loopback interface too) – botismarius Oct 14 '10 at 19:27
  • NetworkManager is adding an entry at the top of the file with the DHCP assigned address and associates it with the host name. I'm assuming it picks up the first one it finds. – James Royer Oct 15 '10 at 18:17

This is actually expected and intended behavior. You do want to have connections from your own host to yourself go through the loopback interface (the interface connected to your own host) which by default has IP (in IPv4) and ::1 (in IPv6). If your external network were down, you could not reach services on your own machine anymore and this includes, among others, also the X server and other daemons.

Note that the /etc/hosts file is only used on you own machine. If you have hosts files (or DNS) setup on other hosts in your network you will still reach your machine under the name "mariusbotis".

Maybe you could clarify why mariusbotis resolving to is a problem for you.

[1] http://en.wikipedia.org/wiki/Hosts_file

|improve this answer|||||
  • The loopback (localhost) should be resolved to I have an application that just does not work because of these settings, I am not sure yet why. Anyway, 127.x.y.z should be only the loopback address. – botismarius Oct 12 '10 at 15:24
  • 1
    It might be that your application is explicitly only listening on and the associated network interface. You might be able to change the settings and make it listen on all interfaces instead. Can you share which application causes you trouble? – Tronic Oct 12 '10 at 15:28
  • My application finds the hostname, resolve it to an IP and listens on that address (in my case, the application will listen to which clearly will not be reachable from other computers). Unfortunately, I cannot change the behavior of the application... – botismarius Oct 12 '10 at 15:28
  • Do I understand correctly that the application finds the hostname automatically and does also the lookup of the IP by itself? Just some ideas: try not removing the whole line but just your hostname "mariusbotis" from the first line. If you use DHCP, that might rewrite the file -> change to static IP. But again, I would consider these hacks/workarounds.. – Tronic Oct 12 '10 at 16:03
  • Well, it is very strange that by default Ubuntu does this. Try on your machine to ping your hostname, does respond to the request or another IP? In case something does not work as expected, the solution -if any- shouldn't be considered a hack. – botismarius Oct 14 '10 at 7:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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