[CentOS] CentOS 7, networkmangler, and hostname

Wed Jul 23 19:09:31 UTC 2014
Mauricio Tavares <raubvogel at gmail.com>

 )

On Wed, Jul 23, 2014 at 2:55 PM,  <m.roth at 5-cent.us> wrote:
> Mauricio Tavares wrote:
>> On Wed, Jul 23, 2014 at 2:01 PM,  <m.roth at 5-cent.us> wrote:
>>> I've a 7 box (actually, it's RHEL, but the general list there is
>>> moribund), and I'm trying to configure it "correctly" so that it gets
>>> its hostname from the DHCP server. All I've found so far is a script
>>> to use from hooks of some kind. *Surely* there's just a configuration
>>> file option somewhere....
>>>
>>       Best I found using network manager is writing a script,
>> dhclient-exit-hooks.d/hostname
>> (http://askubuntu.com/questions/104918/how-to-get-hostname-from-dhcp-server).
>> There is also a way to do that using systemd-networkd; I am not very
>> proud to say I know how to do so though.
>>
> I've been digging, and found something a) confusing and b) disturbing. But
> first, *does* NM use any of the /etc/sysconfig/network-scripts *other*
> than the ifcfg-<interface>? Specifically, does it use ifup, ifdown, and
> esp. ifup-post?
>
> Here's the reason: in ifup-post is the following code:
> # don't set hostname on ppp/slip connections
> if [ "$2" = "boot" -a \
>      "${DEVICE}" != lo -a \
>      "${DEVICETYPE}" != "ppp" -a \
>      "${DEVICETYPE}" != "slip" ]; then
>     if need_hostname; then
>         IPADDR=$(LANG=C ip -o -4 addr ls dev ${DEVICE} | awk '{ print $4 ;
> exit }')
>         eval $(/bin/ipcalc --silent --hostname ${IPADDR} ; echo "status=$?")
>         if [ "$status" = "0" ]; then
>             set_hostname $HOSTNAME
>         fi
>     fi
> fi
>
> Now, that function, need_hostname, is in network-functions, and reads:
> need_hostname ()
> {
>     CHECK_HOSTNAME=$(hostname)
>     if [ "$CHECK_HOSTNAME" = "(none)" -o "$CHECK_HOSTNAME" = "localhost" -o \
>         "$CHECK_HOSTNAME" = "localhost.localdomain" ]; then
>         return 0
>     else
>         return 1
>     fi
> }
>
> So it *should* be setting it... if it's called.
>
      My experience with NM is from ubuntu, over there if you
configure an interface in the /etc/network/interfaces file (their
equivalent of /etc/sysconfig/network-scripts , it *should* not try to
fondle that interface any longer. That said, the network-scripts do
have a

NM_CONTROLLED=no

option, so NM must at least check for that. I have a feeling if you
set that to yes, it will ignore the rest of the file and do its own
thing.

There is also a /etc/NetworkManager/ directory which seems to imply
that NM does a lot of things on its own and ignore the old network
config files. https://bugzilla.gnome.org/show_bug.cgi?id=667874 and
the picture in http://serverfault.com/questions/429014/what-is-the-relation-between-networkmanager-and-network-service-in-fedora-rhel-c
seem  to confirm that.


>         mark
>
>
> _______________________________________________
> CentOS mailing list
> CentOS at centos.org
> http://lists.centos.org/mailman/listinfo/centos