# Networkmanager fails to set correct hostname

## Princess Nell

I recently noticed that networkmanager changes the hostname when I'm connecting wirelessly.

Back in the day, I set the hostname in NetworkManager.conf via the keyfile plugin, but this is now deprecated. According to the Gentoo wiki, if networkmanager was built with USE=dhclient, the hostname can be set via /etc/dhcp/dhclient.conf. I have all that and the hostname still gets changed to "myhostname-6205". In fact, the NM-created config file for dhclient under /var/lib/NetworkManager shows that the "send host-name" option has been merged correctly.

nmcli show for the wireless connection says ipv4.dhcp-send-hostname = yes, but ipv4.dhcp-hostname is unset, so I went ahead and explicitly set ipv4.dhcp-hostname for this connection. This is being ignored.

With the current, 1.4 version of NM, what is a correct and working method to lock down the hostname? I find it really annoying that I need to set the hostname in many different places because NM doesn't play nice with the Gentoo default of /etc/conf.d/hostname.

----------

## Fitzcarraldo

I am using NetworkManager 1.4.0-r1 with dhclient on my laptop running Gentoo Stable, and the hostname is specified in the following files:

```
# cat /etc/NetworkManager/NetworkManager.conf 

[main]

plugins=keyfile

rc-manager=none

dhcp=dhclient

no-auto-default=*

[keyfile]

hostname=myhostname
```

```
# cat /etc/hosts

127.0.0.1 myhostname localhost

::1 myhostname localhost
```

```
# cat /etc/dhcp/dhclient.conf

send host-name "myhostname";

supersede host-name "myhostname";
```

This works fine.

----------

## Princess Nell

Check out NetworkManager.conf(5). The hostname key is deprecated and has no effect. Your setup works because of the settings in dhclient.conf (https://wiki.gentoo.org/wiki/NetworkManager).

I fixed my problem, it was caused by the dhcp server config. It only became a problem when the hostname key got deprecated. I'm guessing this happened in 1.2.

----------

