[NBLUG/talk] IP Host # as Host ID

Mark Street jet at sonic.net
Mon Mar 15 09:10:04 PST 2004


Dave's suggestion should work also by editing the line in /etc/hosts.  I 
thought you might like a little more detail on what is happening here and 
where it is happening.  We don't know how you have your ppp connection setup 
(what tool you used - manual chat script or gui tool).  It is strange that 
the environment variable is different when you su to root. 

The hostname is set on system initialization in the /etc/sysconfig/network 
file.  Make sure you have this entry in this file:

HOSTNAME=server03

From /usr/share/doc/initscripts-7.14/sysconfig.txt on my machine;

/etc/sysconfig/network:

  NETWORKING=yes|no
  HOSTNAME=<fqdn by default, but whatever hostname you want>
---------------------
Here is where it gets interesting.

When you bring up the ppp link the script - 

/etc/sysconfig/network-scripts/ifup-post

may be resetting your hostname based on the IP that is given to it.  Take a 
look at ifup-post and ifup-ppp in /etc/sysconfig/network-scripts.  I imagine 
you have a configuration file for your ppp connection named ifcfg-ppp0, this 
file is read when the ppp connection is brought up.    

From ifup-post
# don't set hostname on ppp/slip connections
if [ "$2" = "boot" -a \
     "${DEVICE}" != lo -a \
     "${DEVICETYPE}" != "ppp" -a \
     "${DEVICETYPE}" != "slip" ]; then
    if need_hostname; then
        IPADDR=`LANG= LC_ALL= ifconfig ${DEVICE} | grep 'inet addr' |
                awk -F: '{ print $2 } ' | awk '{ print $1 }'`
        eval `/bin/ipcalc --silent --hostname ${IPADDR}`
        if [ "$?" = "0" ]; then
            set_hostname $HOSTNAME
        fi
    fi
fi

The fuctions that set the hostname if one is NOT set are found 
in /etc/sysconfig/network-scripts/network-functions.

need_hostname ()
{
    CHECK_HOSTNAME=`hostname`
    if [ "$CHECK_HOSTNAME" = "(none)" -o "$CHECK_HOSTNAME" = "localhost" -o \
        "$CHECK_HOSTNAME" = "localhost.localdomain" ]; then
        return 0
    else
        return 1
    fi
}

set_hostname ()
{
    hostname $1
    if ! grep search /etc/resolv.conf >/dev/null 2>&1; then
        domain=`echo $1 | sed 's/^[^\.]*\.//'`
        echo "search $domain" >> /etc/resolv.conf
    fi
}


On Sunday 14 March 2004 10:39 pm, HarryH wrote:
> Hi,
> I noticed on my RH 7.2 that from time to time, if I go into super user mode
> ( su - and then password), the host IP number from my ISP shows up in place
> of server03, which is my Linux box Hostname:
>
> [root at host-66-81-144-198 home]#
>
> When I exit back to my user login, I get: [Harry at server03 Harry]$.  This
> happens when the modem is connected to my ISP.  Noticed this some time ago
> but thought it a "fluke" but now it must be a bug or an intruder.  Any
> ideas?
>
> Thanks,
> Harry

-- 
Mark Street, D.C.
Red Hat Certified Engineer
Cert# 807302251406074
--
Key fingerprint = 3949 39E4 6317 7C3C 023E  2B1F 6FB3 06E7 D109 56C0
GPG key http://www.streetchiro.com/pubkey.asc



More information about the talk mailing list