setting the client hostname

Steve zephod at cfl.rr.com
Thu Feb 19 15:54:35 UTC 2009


---- Steve <zephod at cfl.rr.com> wrote: 
> 
> ---- "Jeremy C. Reed" <Jeremy_Reed at isc.org> wrote: 
> > > ---- Steve <zephod at cfl.rr.com> wrote: 
> > 
> > > > Can someone point me to where dhclient sets the hostname from what is 
> > > > received fron the dhcpd server?
> > 
> > 
> > Have a look at the dhclient-script(8) manual page and your installed 
> > dhclient-script.
> > 
> 
> I see in /sbin/dhclient-script in the dhconfig function:
> 
> if [ -n "$new_host_name" ] && need_hostname; then
>     host_name $new_host_name
> fi

OK, I have finally found where the hostname gets set in my F9 system; its in the /etc/sysconfig/network-scripts/ifup-post script. In particulat it is this code:

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

So I have actually been on a wild goose chase - dhcp has nothing to do with it. 
It was this line in the dhclient man page that got me started down this road:

"...The default option list is:

subnet-mask, broadcast-address, time-offset, routers,
domain-name, domain-name-servers, host-name, nis-domain,
nis-servers, ntp-servers"

I took this to mean that these options are always requested by the client and that the server would always reply. I guess this could still be true but dhclient doesn't do anything with the host name it received from the server, if it does indeed get one.

Now I need to find out why ipcalc gives me two different answers when I run it consecutively but that has nothing to do do with dhcp.

Steve





More information about the dhcp-users mailing list