suggestion for dhcp hints

Gregory Davis gdavis7 at
Thu Mar 21 12:09:14 PST 2002

Hello there!  In the latest dhcp hint, the author has setup the hostname, 
but only makes a call to action for setting up the IP.  For instance, after 
setting dhcp according to the hint, hostname -i returns garbage.  This is 
because the dynamically assigned IP is not included in the /etc/hosts file. 
 I do not know if that will cause any problems, but I like to do things all 
the way.  So I played with the ethnet init script and came up with these 
inclusions thereto, one for the bottom of the start) case, and the other 
for the bottom of the stop) case.  Of course, these include my domain 
names, but users should replace them with his or her own.  Also, these 
inclusions get the IP address from dhcp's info file (is this a security 
risk?) so it is concurrent with the dynamically assigned IP from the dhcp 
server.  These inclusions also prevent against runaway additions to the 
/etc/hosts file by checking for previous additions using grep.


## begin start) inclusion
        if [ -z "`cat /etc/hosts | /bin/grep ""`" ]
                source /etc/dhcpc/dhcpcd-$
                echo "$IPADDR        Neptune" \
                        | cat >> /etc/hosts

## end start) inclusion

## begin stop) inclusion
        echo \
"# Begin /etc/hosts (network card version)      localhost.localdomain   localhost

# below is dynamic IP address added by ethnet script

" \
        | cat > /etc/hosts
## end stop) inclusion
Unsubscribe: send email to listar at
and put 'unsubscribe hints' in the subject header of the message

More information about the hints mailing list