Subject: getting the hostname from DHCP server
To: None <netbsd-users@netbsd.org>
From: Louis Guillaume <lguillaume@berklee.edu>
List: netbsd-users
Date: 02/15/2006 23:51:53
Hi,
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.
I've been doing this...
[ -z "`hostname`" ] && {
hn=`host $(ifconfig wi0 | awk '$1 == "inet" { print $2 }') | sed 's/.*
\(.*\)\.$/\1/'`
}
[ -n "$hn" ] && {
echo -n "Setting Hostname: "
hostname $hn
echo -n "`hostname`"
}
...in /etc/rc.local. Seems like there should be an automatic way through
dhclient.
Louis