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

Asked by johnnynyquist

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
coral
$ ## re-acquire DHCP lease using NetworkManager
$ hostname
linux.local
$ cat /etc/hostname
coral
$ cat /etc/hosts
127.0.0.1 linux.local localhost.localdomain localhost
127.0.1.1 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
coral
$

Question information

Language:
English Edit question
Status:
Answered
For:
Ubuntu network-manager Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
actionparsnip (andrew-woodhead666) said :
#1

In /etc/hosts

change:
127.0.0.1 linux.local localhost.localdomain localhost

to:
127.0.0.1 coral localhost.localdomain localhost

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

Revision history for this message
johnnynyquist (johnnynyquist) said :
#2

change:
127.0.0.1 linux.local localhost.localdomain localhost

to:
127.0.0.1 coral localhost.localdomain localhost

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

Revision history for this message
johnnynyquist (johnnynyquist) said :
#3

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.

Revision history for this message
freedomrun (freedomrun) said :
#4

Please specify your new hostname also in:

sudo nano /etc/hostname

Revision history for this message
johnnynyquist (johnnynyquist) said :
#5

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

Revision history for this message
Sam_ (and-sam) said :
#6

~$ cat /etc/hosts
127.0.0.1 localhost
127.0.1.1 coral

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

Since 12.04 local dns cache is running there -> 127.0.0.1 dnsmasq
http://www.stgraber.org/2012/02/24/dns-in-ubuntu-12-04/

Revision history for this message
johnnynyquist (johnnynyquist) said :
#7

@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
127.0.0.1 localhost.localdomain localhost
127.0.1.1 coral

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

b@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.

Revision history for this message
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?
/etc/NetworkManager/NetworkManager.conf

http://wiki.debian.org/NetworkManager
http://wiki.debian.org/NetworkConfiguration

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

Revision history for this message
actionparsnip (andrew-woodhead666) said :
#9

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

Revision history for this message
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:
[keyfile]
hostname={hostname}

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.