Operating System - HP-UX
1832363 Members
2562 Online
110041 Solutions
New Discussion

DHCP cleint enabled, but hostame not set properly

 
SOLVED
Go to solution
David Burgess
Esteemed Contributor

DHCP cleint enabled, but hostame not set properly

I've configured a DHCP client on LAN1 by enabling it in /etc/rc.config.d/netconf and touching /etc/dhcpclient.data.

On reboot it obtains a lease from my ISP. It is given the hostname dhcp-4-51.

uname -a shows the hostname as unknown and when I start CDE via reflections it says welcome to unknown.

On Solaris I added an rc script to reset the hostname and all was well. Is there something similar I can do on HPUX 11.00?

maybe I need an rc script with uname -S or hostname?

Many thanks,

Dave.
8 REPLIES 8
Clemens van Everdingen
Honored Contributor

Re: DHCP cleint enabled, but hostame not set properly

Hi,

Use set_parms to set your hostname.

C.
The computer is a great invention, there are as many mistakes as ever, but they are nobody's fault !
Clemens van Everdingen
Honored Contributor

Re: DHCP cleint enabled, but hostame not set properly

Hi,

sorry, the systems gets a new hostname every time I guess.
So not a correct answer.

C.
The computer is a great invention, there are as many mistakes as ever, but they are nobody's fault !
David Burgess
Esteemed Contributor

Re: DHCP cleint enabled, but hostame not set properly

Doesn't that require a reboot?

If I do auto_parms kindly updates /etc/rc.config.d/netconf and /etc/hosts on boot back to the dhcp-4-51 hostname.

What I really want is to keep my hostname as "raver" and ignore what my ISP gives me.
Clemens van Everdingen
Honored Contributor

Re: DHCP cleint enabled, but hostame not set properly

Hi,

allright my first impresion was OK.
Use set_parms to set the hostname.

Yes reboot.

C.
The computer is a great invention, there are as many mistakes as ever, but they are nobody's fault !
Steven Sim Kok Leong
Honored Contributor
Solution

Re: DHCP cleint enabled, but hostame not set properly

Hi,

Use /etc/rc.config.d/netconf and specify under:

HOSTNAME="xyz"

Alternatively, set uname -S hostname right at the end of /sbin/rc1.d/S320hostname:

uname -S xyz

For more details, take a look at /sbin/rc1.d/S320hostname. You can't use set_parms because it prompts interactively.

Hope this helps. Regards.

Steven Sim Kok Leong
David Burgess
Esteemed Contributor

Re: DHCP cleint enabled, but hostame not set properly

I'll give the uname -S raver at the end of /sbin/rc1.d/S320hostname tonight. Is there no way of overriding auto_parms updating /etc/hosts and /etc/rc.config.d/netconf when it runs at boot?
Steven Gillard_2
Honored Contributor

Re: DHCP cleint enabled, but hostame not set properly

Not without editing the auto_parms script, which you don't want to do...

Just another note, if you are going to change the hostname in a script after auto_parms has run, you should make sure that your hostname is resolvable properly otherwise you'll have no end of trouble. So, make sure your script also updates the appropriate /etc/hosts entry with the IP address supplied by DHCP, and that nsswitch.conf is configured to look at hosts before DNS.

Regards,
Steve
David Burgess
Esteemed Contributor

Re: DHCP cleint enabled, but hostame not set properly

I wrote this script last night /sbin/rc1.d/S321sethostname. It runs straight after /sbin/rc1.d/S320hostname and sets everything back to what it should be.

Thanks for all your help,

Dave.


#!/sbin/sh # # @(#) $Revision: 1.0 Dave Burgess 18/04/2002$
#
# /sbin/rc1.d/S321sethostname
# /sbin/auto_parms sets up the dhcp client. Unfortunately ISP's can set the
# hostname for us. In this case it is set to dhcp-4-51.
# This script resets the hostname to raver.

new_hostname="raver"
PATH=/sbin:/usr/sbin:/usr/bin
export PATH
echo "Resetting dhcp set hostname to $new_hostname"
uname -S $new_hostname
cp -p /etc/hosts /tmp/hosts.boot
cat /tmp/hosts.boot | sed s/dhcp-4-51/$new_hostname/g > /etc/hosts
cp -p /etc/rc.config.d/netconf /tmp/netconf.boot
cat /tmp/netconf.boot | sed s/dhcp-4-51/$new_hostname/g > /etc/rc.config.d/netconf