Re: Instructing dhclient to set hostname of client
- From: Doug Barton <dougb@xxxxxxxxxxx>
- Date: Sun, 22 Oct 2006 22:30:46 -0700
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
_______________________________________________
freebsd-net@xxxxxxxxxxx mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-net
To unsubscribe, send any mail to "freebsd-net-unsubscribe@xxxxxxxxxxx"
- Follow-Ups:
- Re: Instructing dhclient to set hostname of client
- From: Andrey V. Elsukov
- Re: Instructing dhclient to set hostname of client
- References:
- Instructing dhclient to set hostname of client
- From: Joe Holden
- Instructing dhclient to set hostname of client
- Prev by Date: Instructing dhclient to set hostname of client
- Next by Date: Re: Avoiding natd overhead
- Previous by thread: Instructing dhclient to set hostname of client
- Next by thread: Re: Instructing dhclient to set hostname of client
- Index(es):
Relevant Pages
|