Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to force hostname w/DHCP?

Status
Not open for further replies.

rblue

Technical User
Jul 20, 2000
121
US
I just changed floors @ work, now I'm on a different subnet. Rather that just asking for a new IP. I figured I'd just reconfigure for DHCP. The system gets an IP address just fine, but the hostname gets blown away if I reboot the machine and comes back as "unknown".

Is there a way to force the hostname so that this doesn't happen?

ifconfig -a output:

le0: flags=1004843<UP,BROADCAST,RUNNING,MULTICAST,DHCP,IPv4> mtu 1500 index 2
inet 10.210.52.188 netmask ffffff00 broadcast 10.210.52.255

Thanks,
Rob
 
Hi
if DHCP does not return a hostname, it usually use &quot;unknown&quot;.
please read the script of /etc/init/inetsvc the lines between 162 upto 168





if [ &quot;$_INIT_NET_STRATEGY&quot; = &quot;dhcp&quot; ]; then
162 #
163 # if DHCP doesn't return a hostname, use &quot;unknown&quot; so
164 # client can resolve IP address into a local hostname.
165 #
166 hostname=`/sbin/dhcpinfo Hostname`
167 if [ -z &quot;$hostname&quot; ]; then
168 hostname=&quot;unknown&quot;
The trick is to change your hostname back to the right one, I put this little script into
/etc/init.d/set_hostname

HOSTNAME=`cat /etc/nodename`

echo &quot;Setting hostname to $HOSTNAME... \c&quot;
uname -S $HOSTNAME
echo &quot;Done.&quot;


# chmod +x set_hostname

# hostname
unknown
cd /etc/init.d
and run the script

# ./set_hostname
setting hostname to Abdikarim...Done
# hostname
Abdikarim

So far, I did not succeed 100% to solve this problem.

After I run the little script, I found out
so many problems
I can not run admintool, Netscape, Explore and I can not edit the crontab but I can run the crontab
e.g

#netscape &
650
# Xlib: connection to &quot;:0.0&quot; refused by server
Xlib: Invalid MIT-MAGIC-COOKIE-1 key
Error: Can't open display: :0.0
Xlib: connection to &quot;:0.0&quot; refused by server
Xlib: Invalid MIT-MAGIC-COOKIE-1 key
Error: Can't open display: :0.0

#
# hostname
Abdikarim
#








.

Farah regal
good luck
&quot;think twice and hit enter once&quot;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top