Re: [CentOS] Prevent network setup from changing the hostname

2015-04-28 Thread Robert Nichols

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.

___
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos


Re: [CentOS] Prevent network setup from changing the hostname

2015-04-27 Thread Scott Robbins
On Sun, Apr 26, 2015 at 08:08:49PM -0500, Robert Nichols wrote:


> >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.

No, it's a systemd thing, I think, started with RHEL7.

I've always used /etc/sysconfig/network for the hostname entry, which works
through CentOS-6.x
-- 
Scott Robbins
PGP keyID EB3467D6
( 1B48 077D 66F6 9DB0 FDC2 A409 FA54 EB34 67D6 )
gpg --keyserver pgp.mit.edu --recv-keys EB3467D6

___
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos


Re: [CentOS] Prevent network setup from changing the hostname

2015-04-26 Thread Peter Larsen
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

___
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos


Re: [CentOS] Prevent network setup from changing the hostname

2015-04-26 Thread Robert Nichols

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.

___
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos


Re: [CentOS] Prevent network setup from changing the hostname

2015-04-26 Thread Robert Nichols

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.

___
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos


Re: [CentOS] Prevent network setup from changing the hostname

2015-04-26 Thread Peter Larsen
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


___
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos


Re: [CentOS] Prevent network setup from changing the hostname

2015-04-26 Thread Frank Cox
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
___
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos


Re: [CentOS] Prevent network setup from changing the hostname

2015-04-26 Thread Robert Nichols

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.

___
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos


Re: [CentOS] Prevent network setup from changing the hostname

2015-04-26 Thread Peter Larsen
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 -".
>


-- 
Regards
  Peter Larsen

___
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos


[CentOS] Prevent network setup from changing the hostname

2015-04-26 Thread Robert Nichols

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 -".

--
Bob Nichols "NOSPAM" is really part of my email address.
Do NOT delete it.

___
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos