Subject: getting the hostname from DHCP server
To: None <>
From: Louis Guillaume <>
List: netbsd-users
Date: 02/15/2006 23:51:53

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 

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.

I've been doing this...

[ -z "`hostname`" ] && {
  hn=`host $(ifconfig wi0 | awk '$1 == "inet" { print $2 }') | sed 's/.* 

[ -n "$hn" ] && {
  echo -n "Setting Hostname: "
  hostname $hn
  echo -n "`hostname`"
} /etc/rc.local. Seems like there should be an automatic way through