HOSTNAME from DNS name server
kauer at biplane.com.au
Mon Jun 29 14:00:39 UTC 2009
On Mon, 2009-06-29 at 15:22 +0200, Michael Zoet wrote:
> 1. your DNS Server needs to accept DNS zone updates from your DHCP server
> 2. your DHCP server must send DNS zone updates to your DNS server
> 3. (maybe) you need to tweak the file /etc/dhcp3/dhclient.conf
All this will (may) fix the problem by making the DNS entry for an
address match the hostname. It doesn't solve the problem of what
hostname should be set locally, how those names should be set locally,
or how hostnames get set on multiple machines.
An alternative might be to set the hostname locally based on information
already in the DNS.
1: For the addresses that will be used, make sure you have reverse
lookups in your DNS. E.g.:
201 IN A PTR host1.mydomain.
202 IN A PTR host2.mydomain.
203 IN A PTR host3.mydomain.
2: Use a DHCP exit hook to set the local hostname to the appropriate DNS
name. The DHCP exit hooks are in /etc/dhcp3/dhclient-exit-hooks.d
Then every time your address is set with DHCP, the hostname will be set
Look at the exit hook "debug" to find out what variables you have at
your disposal - you probably want to use "new_ip_address". You can find
out the relevant name by doing a reverse lookup of that address:
myname=`dig +short -x new_ip_address`
You can reduce the name to just a hostname using basename:
myhost=`basename $myname .mydomain`
If your addresses are in several domains you'll have to do something
more complicated; you need to strip off everything after the first dot
from the left.
Then you can set the hostname:
Remember to set your hostname *after* /etc/resolv.conf has been set up,
because you need correct nameserver info to do the reverse lookup.
If you don't want to fiddle with exit hooks, modify the client script
instead - usually /sbin/dhclient.script or /etc/dhcp3/dhclient-script,
but settable in dhclient.conf.
All this is for the ISC DHCP client; other clients should have similar
PS: I've done DHCP hooks, but not to change the hostname, so the above
is untested for that purpose.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 189 bytes
Desc: This is a digitally signed message part
More information about the ubuntu-users