Dynamic Hostname Assignment

Kenneth Culver culverk at yumyumyum.org
Fri Jul 25 08:59:23 PDT 2003


> 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?
>
Most likely, dhclient isn't what's setting it on redhat, it's probably a
support script in redhat that's doing it.

Ken


More information about the freebsd-questions mailing list