Robert Nichols
2015-Apr-27 01:19 UTC
[CentOS] Prevent network setup from changing the hostname
On 04/26/2015 07:57 PM, Peter Larsen wrote:> On 04/26/2015 08:25 PM, Robert Nichols wrote: >> On 04/26/2015 06:31 PM, Peter Larsen wrote: >>> On 04/26/2015 07:26 PM, Robert Nichols wrote: >>>> How can I block network setup (via NetworkManager) from changing >>>> the machine's hostname whenever the network configuration changes? >>> >>> Make it a system connection instead of a user connection. Or give the >>> host a static name on install and don't allow dhcp to override it. >> > > If you move networks and you are slaving your hostname to the DHCP > offered name, then yes. But why do that? In /etc/dhcp/dhclient.conf you > can configure exactly what you want and don't want from the server. > There's a lot of options (man dhclient.conf is very helpful) but here's > an example:NetworkManager invokes dhclient with a generated config file that ignores /etc/dhcp/dhclient.conf: dhclient ... -cf /var/run/nm-dhclient-wlan0.conf ... I ran across another report that suggests setting HOSTNAME to something other than "localhost.localdomain" in /etc/sysconfig/network would fix the problem. For the moment, that seems to be working. -- Bob Nichols "NOSPAM" is really part of my email address. Do NOT delete it.
Peter Larsen
2015-Apr-27 01:28 UTC
[CentOS] Prevent network setup from changing the hostname
On 04/26/2015 09:19 PM, Robert Nichols wrote:> On 04/26/2015 07:57 PM, Peter Larsen wrote: >> On 04/26/2015 08:25 PM, Robert Nichols wrote: >>> On 04/26/2015 06:31 PM, Peter Larsen wrote: >>>> On 04/26/2015 07:26 PM, Robert Nichols wrote: >>>>> How can I block network setup (via NetworkManager) from changing >>>>> the machine's hostname whenever the network configuration changes? >>>> >>>> Make it a system connection instead of a user connection. Or give the >>>> host a static name on install and don't allow dhcp to override it. >>> >> >> If you move networks and you are slaving your hostname to the DHCP >> offered name, then yes. But why do that? In /etc/dhcp/dhclient.conf you >> can configure exactly what you want and don't want from the server. >> There's a lot of options (man dhclient.conf is very helpful) but here's >> an example: > > NetworkManager invokes dhclient with a generated config file that > ignores /etc/dhcp/dhclient.conf: > > dhclient ... -cf /var/run/nm-dhclient-wlan0.conf ...Well, true to a degree. Put the file in /etc/dhcp/dhclient.d and it'll be executed. Just make sure the script out-puts to stdout what goes into the dhclient configuration file used by NetworkManager.> > I ran across another report that suggests setting HOSTNAME to > something other than "localhost.localdomain" in > /etc/sysconfig/network would fix the problem. For the moment, > that seems to be working. >Strange - you may have a dhcp server that accepts host names from the clients - which of course would fit your use case. Just realize that not all dhcp servers are setup to be that "lenient" when it comes to preserving the host name picked by a client. But I am happy you got it working. -- Regards Peter Larsen
Robert Nichols
2015-Apr-28 17:34 UTC
[CentOS] Prevent network setup from changing the hostname
On 04/26/2015 08:28 PM, Peter Larsen wrote:> Strange - you may have a dhcp server that accepts host names from the > clients - which of course would fit your use case. Just realize that not > all dhcp servers are setup to be that "lenient" when it comes to > preserving the host name picked by a client.I can see in Wireshark that the client is not requesting any hostname in the DHCP Request and is ignoring the hostname that is returned in the DHCP ACK in favor of the one specified in /etc/sysconfig/network as long as the latter is _not_ "localhost.localdomain". -- Bob Nichols "NOSPAM" is really part of my email address. Do NOT delete it.