Robert Nichols
2015-Apr-27 00:25 UTC
[CentOS] Prevent network setup from changing the hostname
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.Making my wireless connection a system connection increases the exposure of my WPA key and doesn't solve the problem of the network configuration changing, perhaps because I connected or disconnected an ethernet cable or the machine went to sleep on one WLAN and woke up on another. Do you know of a place I can set a static name that NetworkManager won't override? That would be ideal. I just doesn't make sense that the machine's internal relationships would depend on its external connections. -- Bob Nichols "NOSPAM" is really part of my email address. Do NOT delete it.
On Sun, 26 Apr 2015 19:25:27 -0500 Robert Nichols wrote:> Do you know of a place I can set a static name that NetworkManager > won't override?What about this: hostnamectl set-hostname whateveryouwant -- MELVILLE THEATRE ~ Real D 3D Digital Cinema ~ www.melvilletheatre.com
Peter Larsen
2015-Apr-27 00:57 UTC
[CentOS] Prevent network setup from changing the hostname
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: send dhcp-client-identifier = hardware; request subnet-mask, broadcast-address, time-offset, routers, domain-search, domain-name, domain-name-servers, host-name; Just take out the host-name and you won't get (a new) one. You should however make sure that all your servers have a hostname configured before you do that. /etc/sysconfig/network is where you do that on CentOS6.> Making my wireless connection a system connection increases the > exposure of my WPA key and doesn't solve the problem of the network > configuration changing, perhaps because I connected or disconnected > an ethernet cable or the machine went to sleep on one WLAN and woke > up on another.So your key isn't visible and only root can change a system device. A system device gets activated before the desktop. So you're not depending on having access to gconf etc. https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Deployment_Guide/sec-User_and_System_Connections.html> > Do you know of a place I can set a static name that NetworkManager > won't override? That would be ideal. I just doesn't make sense > that the machine's internal relationships would depend on its > external connections. >See above. It's standard dhclient options. -- Regards Peter Larsen
Robert Nichols
2015-Apr-27 01:08 UTC
[CentOS] Prevent network setup from changing the hostname
On 04/26/2015 07:37 PM, Frank Cox wrote:> On Sun, 26 Apr 2015 19:25:27 -0500 > Robert Nichols wrote: > >> Do you know of a place I can set a static name that NetworkManager >> won't override? > > What about this: > > hostnamectl set-hostname whateveryouwant# which hostnamectl /usr/bin/which: no hostnamectl in (/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin) # yum provides \*/hostnamectl ''' No Matches found Apparently does not exist for CentOS 6. -- Bob Nichols "NOSPAM" is really part of my email address. Do NOT delete it.
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.