Why does NetworkManager change my hostname to "linux.local"?

Asked by johnnynyquist on 2012-06-24

My computer's hostname is 'coral'. However, whenever I acquire a Wifi connection and DHCP lease with NetworkManager, the hostname gets reset to "linux.local" and I have to reset it manually. Why?

$ hostname
$ ## re-acquire DHCP lease using NetworkManager
$ hostname
$ cat /etc/hostname
$ cat /etc/hosts linux.local localhost.localdomain localhost coral

# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
$ sudo hostname coral
$ hostname

Question information

English Edit question
Ubuntu network-manager Edit question
No assignee Edit question
Last query:
Last reply:

In /etc/hosts

change: linux.local localhost.localdomain localhost

to: coral localhost.localdomain localhost

Did you by any chance, change your hostname a little while ago?

change: linux.local localhost.localdomain localhost

to: coral localhost.localdomain localhost

I tried that-- the file gets re-written. This is very frustrating. I feel like NetworkManager is overreaching a bit :)

What I did recently was change my DNS server from a proper gateway to a consumer wifi hub. But apparently the problem has always been there.

freedomrun (freedomrun) said : #4

Please specify your new hostname also in:

sudo nano /etc/hostname

@freedomrun - it is there, in my original post I cat /etc/hostname

Sam_ (and-sam) said : #6

~$ cat /etc/hosts localhost coral

should be sufficient. (of course incl. ipv6 lines)

Since 12.04 local dns cache is running there -> dnsmasq

@Sam_(and-sam), thanks for the suggestion (I am running 10.04 LTS anyway) but it still does not solve the underlying problem, which seems to be: that NetworkManager is rewriting /etc/hosts and confusing the kernel as to the computer's hostname. This happens every time I ask NetworkManager to acquire an IP address. It doesn't matter WLAN or ethernet, or which network I connect to. Here's a sample transcript:

b@coral:~$ sudo hostname coral
b@coral:~$ cat /etc/hosts localhost.localdomain localhost coral

b@coral:~$ hostname
b@coral:~$ ## plug in ethernet cable
b@coral:~$ hostname
b@coral:~$ cat /etc/hosts localhost.localdomain localhost coral


Now, strangely, "linux.local" doesn't even show up in /etc/hosts and yet still my computer thinks its hostname is "linux.local". /etc/hostname still reads "coral". I don't know where else to look.

Sam_ (and-sam) said : #8

What if hosts only contents localhost as shown in #6?

Where does network-manager get the idea of linux.local from? Is it an entry somewhere in a leftover file?
Or since this is 10.04 it also allows to change computer name in a GUI, iirc system administration menu, personal data or something like that, did you change hostname there?

Is ifupdown managed true or false?


## Sigh, since ipv6 launch lp drives me nuts with timeouts and loops.

Do you have your hostname set by the DHCP server at all?

Jon Grossart (jon-grossart) said : #10

Found this old question with no answer and had a similar problem. You can set a persistent hostname in NetworkManager config file.

In fail/etc/NetworkManager/nm-system-settings.conf add lines:

Can you help with this problem?

Provide an answer of your own, or ask johnnynyquist for more information if necessary.

To post a message you must log in.