Dynamic Hostname Assignment

Mike Maltese mike at pcmedx.com
Thu Jul 24 20:33:38 PDT 2003


If I understand your question correctly, the following line in
/etc/dhclient.conf should do what you want:

    send host-name "yourhostname";


----- Original Message ----- 
From: "Shawn" <drevil at warpcore.org>
To: <freebsd-questions at freebsd.org>
Sent: Thursday, July 24, 2003 7:03 PM
Subject: Dynamic Hostname Assignment


> When I recently installed and setup FreeBSD 5.1 on my box here at home,
> I noticed that it didn't dynamically set the hostname for me. When I
> used RedHat Linux 9 before it did.
>
> I was puzzled by this at first, since RedHat and FreeBSD both use
> dhclient (AFAIK), and I spent a few hours looking around for settings
> for dhclient and found some information about require-hostname, and a
> few other things. But, no matter what I tried, it didn't seem to work. I
> continued to look for various articles about dynamic hostname
> configuration and I am fairly certain I covered the relevant portions of
> the handbook. Everything I've read seemed to indicate it should "just
> work", but it wasn't.
>
> Finally, after I couldn't find an answer anywhere, I devised my own
> little hack. I modified /etc/rc.d/hostname like so:
>
> hostname_start()
> {
> ip=`ifconfig xl0 | grep 'inet ' | awk '{print $2}'`
> # Set the host name if it is not already set
> #
> if [ -z "`hostname -s`" ]; then
> if [ $ip ]; then
> hostname=`host $ip | awk '{print $5}'`
> hostname ${hostname}
> echo "Setting hostname: `hostname`."
> fi
> fi
> }
>
> I then symlinked /etc/rc.d/hostname to
> /usr/local/etc/rc.d/001.hostname.sh so that after the network interface
> and everything had been brought up it would set my hostname correctly.
> I'm sure this is probably an ugly and unnecessary hack, but I could find
> no other way to get my hostname to be set properly :]
>
> I'm quite willing to go debug or rip apart dhclient to figure out why it
> isn't grabbing the hostname if someone points me in the right direction.
> Any suggestions?
>
> -- 
> Shawn <drevil at warpcore.org>
> http://drevil.warpcore.org/
>
> _______________________________________________
> freebsd-questions at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> To unsubscribe, send any mail to
"freebsd-questions-unsubscribe at freebsd.org"



More information about the freebsd-questions mailing list