Date: Sun, 22 Oct 2006 22:30:46 -0700 From: Doug Barton <dougb@FreeBSD.org> To: joe@joeholden.co.uk Cc: net@freebsd.org Subject: Re: Instructing dhclient to set hostname of client Message-ID: <453C5386.5080102@FreeBSD.org> In-Reply-To: <453C0E42.4010604@joeholden.co.uk> References: <453C0E42.4010604@joeholden.co.uk>
next in thread | previous in thread | raw e-mail | index | archive | help
Joe Holden wrote:
> Hi all,
>
> Is it possible to get dhclient to resolve the ip its been given, and set
> that as the hostname? (6.2-PRE)
For future reference, this really belongs on freebsd-questions. If you
know for sure that the DHCP server is going to send you a hostname,
then you can put this in your /etc/dhclient.conf:
request subnet-mask, routers, broadcast-address,
domain-name, host-name,
domain-name-servers;
(obviously those aren't all related to your hostname, but probably a
good idea anyway).
If you're talking about a laptop where you're not sure what the DHCP
server is going to send you, then I have this in /etc/rc.local:
for ip in `ifconfig | awk '/inet / {print $2}'`; do
case "${ip}" in
127.0.0.1|0.0.0.0) ;;
*) newhost=`host ${ip} | cut -f5 -d ' '`
case "${newhost}" in
''|*NXDOMAIN*) ;;
*\.*) hostname ${newhost%.}
sleep 1
break
;;
esac
;;
esac
done
Combine that with a default hostname in /etc/rc.conf[.local] and
you're good to go.
hth,
Doug
--
This .signature sanitized for your protection
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?453C5386.5080102>
