Hostname "Chicken and Egg"
Bob McClure Jr
robertmcclure at earthlink.net
Thu Dec 16 23:09:45 UTC 2004
On Thu, Dec 16, 2004 at 03:01:55PM -0800, Bob Kinney wrote:
> Happy Holidays all--
>
> I'm running RH9, and recently switched from being directly connected to
> the internet (dhcp giving me a publicly routed address) to being behind
> a router.
>
> I reconfigured my IP address to be a static, private one now, and my
> hostname now comes up as "localhost.localdomain". I'm trying to name the
> host "vectra".
>
> Looking at the man page for hostname, it says that:
> " The host name is usually set once at system startup in
> /etc/rc.d/rc.inet1 or /etc/init.d/boot (normally by reading the con-
> tents of a file which contains the host name, e.g. /etc/hostname)."
>
> Although the files mentioned aren't there, I found in /etc/rc.sysinit
> a section that seems to set the hostname by *calling* /bin/hostname.
> >>
> HOSTNAME=`/bin/hostname`
> if [ -f /etc/sysconfig/network ]; then
> . /etc/sysconfig/network
> else
> NETWORKING=no
> fi
> if [ -z "$HOSTNAME" -o "$HOSTNAME" = "(none)" ]; then
> HOSTNAME=localhost
> fi
> <<
>
>
> [root at localhost init.d]# cat /etc/sysconfig/network
> NETWORKING=yes
> HOSTNAME=localhost.localdomain
> [root at localhost init.d]#
>
>
> It would seem that the hostname is being set either by the
> /etc/sysconfig/network file, or by the fallout case listed in
> /etc/rc.sysinit (if -z $HOSTNAME ...).
>
> I don't know why the hostname command would fail:
>
> [root at localhost init.d]# cat /etc/hostname
> vectra
> [root at localhost init.d]#
>
> Also, what does the line ". /etc/sysconfig/network" do?
> Is "." (dot) a command?
>
> --bk
Yes. "." means to "source", that is to execute in the current shell.
/etc/sysconfig/network is nothing but a shell script that sets
environment variables (well, shell variables, actually), one of which
is $HOSTNAME. So edit the file so that it has your desire host name
and then reboot.
Cheers,
--
Bob McClure, Jr. Bobcat Open Systems, Inc.
robertmcclure at earthlink.net http://www.bobcatos.com
Grace happens.
More information about the Redhat-install-list
mailing list