Re: hostname comes up as "unknown" with cheap-o cable modem router

From: Ian Fitchet (idf_at_lunanbay.LESS-SPAM.com)
Date: 11/16/03


Date: Sun, 16 Nov 2003 18:16:49 +0000

Logan Shaw <lshaw-usenet@austin.rr.com> writes:

> Since you asked the correct way, the correct way is to fix the
> DHCP server that is giving you a bogus hostname.

 I shall address my complaint to Microsoft regarding their Windows
 Server 2003 DHCP Server presently.

 I found that the issue is slightly more complicated by Solaris' use
 of /sbin/dhcpstrategy which sneaks in when nobody's looking to make
 vital executive decisions regarding how your computer will work.

 If the DHCP server fails to return a hostname then in
 rcS.d/S29network.sh :-

# If DHCP was used on a primary interface then set the hostname
# that was returned. If no hostname was returned, set the name
# to be "unknown". The hostname must be set to something, because
# tooltalk will hang unless the name can be locally resolved.
# Sendmail also requires the name to be resolvable locally.
# Later, in inetsvc, we create a name "unknown" and create a entry
# in the local /etc/inet/hosts file pairing "unknown" with the IP
# address assigned by DHCP.
#

 But, if the hostname is unknown then dhcpstrategy sets
 _INIT_NET_STRATEGY (in /sbin/rc?) to be "none". If it's set to
 "none" then all subsequent tests for DHCP related info fail! Most
 obviously, /rc2.d/S72inetsvc fails to do anything with the DHCP info
 in its hands. How jolly tiresome, we British might say.

 I haven't attempted to decifer the meanderings of the network
 initialisation code so my hack was two-fold:

 1. put your hostname into /etc/nodename and add

/etc/rcS.d/S99set-hostname

 which simply calls "uname -S `cat /etc/nodename`" which means that
 the subsequent call to dhcpstrategy in /sbin/rc2 will set
 _INIT_NET_STRATEGY to "dhcp"

 2. add

/etc/rc2.d/S72inetsvc-reset-hosts

 which wants to add an appropriate entry into /etc/hosts so that name
 lookups for sendmail and friends works. Something along the lines
 of:

        set -- `/sbin/netstrategy`

        hname=`uname -n`
        ipaddr=`netstat -ni -I $2 | awk '$1 !~ /Name/ {print $4}'`

        echo "$ipaddr $hname # $0" >> /etc/inet/hosts

 Note that the name of this init script is vital -- you must put the
 entry in /etc/hosts before any subsequent script tries to use it.
 You may also wish to modify the above script to only add the
 IP/Host line if it's not already there. I get a new one every reboot
 because I'm too lazy!

 Given Bryan Cantrell's posting re: dtrace and that this is still true
 on b44 (as I've literally just done it and the first thing I did was
 read some news!) perhaps our heroes in Mountain View might want to
 take a look at how the system sets up the networking in the face of
 arguably broken but common enough DHCP servers.

Cheers,

        Ian



Relevant Pages

  • Re: sun dhcp on multihomed machine
    ... > Dave Miner wrote: ... >> Using the fixed address as the primary interface is what we suggest ... If your DSL provider's DHCP server doesn't supply a hostname in the DHCP ...
    (comp.unix.solaris)
  • SUMMARY: Solaris 9 DHCP client hostname / DNS Update
    ... echo "Setting hostname to $HOSTNAME... ... The Solaris DHCP client will not directly send updates to a DNS server; ... DNS on its behalf. ... hostname from the DHCP server, and most DHCP servers won't provide it. ...
    (SunManagers)
  • SUMMARY: DHCP and Solaris 9 - hostname issue
    ... You have to modify the startup scripts because the Windows DHCP server ... I set up a new Sun Blade 2000 as a DHCP client. ... Everything works EXCEPT the hostname assignment. ... DHCP server returns the requested hostname as a DHCP option? ...
    (SunManagers)
  • DHCP and Solaris 9 - hostname issue
    ... I set up a new Sun Blade 2000 as a DHCP client. ... Everything works EXCEPT the hostname assignment. ... The request is sent to the DHCP server, ...
    (SunManagers)
  • send hostname in dhclient.conf
    ... how can i do this that dhclient.conf send my hostname to the dhcp server? ... is there any script that copy the entry in /etc/hostname and paste it ...
    (Debian-User)