[CentOS] Prevent network setup from changing the hostname

Sun Apr 26 23:31:47 UTC 2015
Peter Larsen <peter at peterlarsen.org>

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.

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?
> The problem: When my graphical login session starts, the xauth
> database gets an token that is labeled with the hostname at that
> time. If there is not yet a network connection, that will be
> "localhost.localdomain". When a network connection is then made
> (my wireless connection needs the key from my login), the hostname
> changes. That breaks X session sharing because there is no xauth
> token that matches the current hostname. If I get a root shell
> with "su -", commands launched from that shell cannot access the
> display. If I set up an ssh connection with "ssh -X", I get a
> complaint about missing xauth data.
> On systems with an "ONBOOT=yes" network connection, there is no
> problem since the hostname is set before the X session starts.
> It's just when the hostname changes during the X session that
> there is a problem.
> I am running CentOS 6, fully updated. It's taken me a long time
> to track down the root cause of this problem. Now I just need a
> solution, preferably something less ham-fisted than "xhost -".

  Peter Larsen