Subject: Re: getting the hostname from DHCP server
To: Louis Guillaume <lguillaume@berklee.edu>
From: Stephen Borrill <netbsd@precedence.co.uk>
List: netbsd-users
Date: 02/16/2006 09:04:40
On Wed, 15 Feb 2006, Louis Guillaume wrote:
>
> I'm wondering if dhclient on NetBSD can get the hostname sent by the DHCP
> server or simply from reverse-DNS look-up.
>
> On Linux, dhcpcd has the -H option for this.
>
> So with no /etc/myname or "hostname=" in rc.conf, dhclient will pull the
> hostname sent by the DHCP
> server.
>
> It "just-works" on the Mac. I'm not sure if Apple's Directory Services uses
> only DNS or if it gets the hostname from the DHCP server.

It "just works" on NetBSD too. This relies on the DHCP server sending the 
hostname; it won't fall back to the client doing reverse DNS.

From /sbin/dhclient-script:

         if type hostname > /dev/null 2>&1; then
                 if [ \( -z "$current_hostname" \) -o \
                     \( "x$new_host_name" = "x$old_hostname" \) ]; then
                         current_hostname=`hostname`
                 fi
                 if [ \( -z "$current_hostname" \) -o \
                     \( "x$new_host_name" != "x$old_hostname" \) ]; then
                         hostname $new_host_name
                 fi
         fi

-- 
Stephen