Dave Whiteley <[EMAIL PROTECTED]> writes:

> What is the polite Debian way of automatically setting the hostname
> after booting using BOOTP/DHCP.
> 
> ...  /etc/hostname is identical on all
> the machines. The IP addresses are correctly discovered and set.  
> 
> I know that I could write a script that gets the host IP address, and
> then gets the name associated with that IP, and then updates the
> /etc/hostname; and that I could run this script "somewhere" in the
> bootup process, or even during the login process. ...

See the man page dhclient-script(8).

I've had success with a script /etc/dhclient-exit-hooks like this:

  # Set the hostname 
  if [ x$reason != xBOUND ] && [ x$reason != REBIND ]; then exit; fi 
  echo dhclient-exit-hooks: IP address is $new_ip_address 
  hostname=$( host $new_ip_address | sed -ne 's/Name: //p' ) 
  hostname $hostname 
  echo dhclient-exit-hooks: hostname is $( hostname ) 

You could update /etc/hostname too if you like.

-- 
Jim Richardson
School of Mathematics & Statistics, University of Sydney
[EMAIL PROTECTED]  www.maths.usyd.edu.au:8000/jimr.html


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to