3 # This script can be installed in /etc/dhclient-enter-hooks to set the client's
4 # hostname based either on the hostname that the DHCP server supplied or the
5 # hostname in whatever ptr record exists for the assigned IP address.
7 if [ x
$new_host_name = x
]; then
8 ptrname
=`echo $new_ip_address \
10 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)/\4.\3.\2.\1.in-addr.arpa/'`
11 (echo "set type=ptr"; echo "$ptrname") |
nslookup >/tmp
/nslookup.$$
12 set `sed -n -e "s/$ptrname[ ]*\(canonical \)*name *= *\(.*\)/\2 \1/p" \
17 if [ $# -gt 1 ] && [ x
$2 = xcanonical
]; then
18 new_host_name
=`sed -n -e "s/$1[ ]*name *= *\(.*\)/\1/p" \
26 if [ x
$new_host_name != x
]; then
27 hostname
$new_host_name