• Many RHEL8 machines, running a default NetworkManager config.
  • Two main networks: on both, DHCP supplies usual info including hostname.
  • Most hosts are single-homed on either one network or the other; a few are dual-homed on both.
  • Using config. management (CFEngine) across all hosts.

Problem: For single-homed machines things work well, including the hostname being received and set via DHCP. But the dual-homed machines receive a hostname twice: once from each interface. These names are slightly different: "foo.net1.[...]" and "foo.net2.[...]". The machine sets its fully-qualified hostname from these, and it seems to be "last one wins".

On dual-homed machines we would like to be able to configure NetworkManager (or similar) so that the hostname is set from a specified interface (and so that hostnames arriving on other interfaces are ignored).

It is not obvious how to do this. Any pointers, please?

(Config.mgmt. notes. It would be useful if this can be done via a config file with, for example, a "keyword=value" that could be interrogated and set. Or perhaps with commands that could query and (if not set) then set.)

1 Answer 1


See the [hostname] setting in man nm-settings.

In particular, you can configure whether a hostname for the interface/profile should be automatically obtained (either DHCP and/or DNS reverse lookup), and also the priority in case multiple interfaces/profiles can obtain a hostname.

That means, you need to configure the connection profiles in NetworkManager.

You can modify a profile either with nmcli connection modify or by editing the profiles on disk (keyfiles in /etc/NetworkManager/system-connections). How to do that in details with the configuration management, depends a lot on what you currently are doing...

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .