On Tue, 18 Jul 2000, Alex Hewitt USG wrote:
> However, when I tried to setup my Linux system, the system hung when it
> tried to start sendmail and then hung again when it got to the Apache
> httpd daemon.
As others have pointed out, the problem is your machine's host name isn't
resolving to a domain name.
Various programs (like sendmail) need to know your fully qualified domain
name (FQDN) in order to function properly. They determine your FQDN by
feeding the hostname to the name resolver and seeing what comes back. The
resolver will get your hostname (say "foo") and try and find a match for "foo"
in the DNS domains it knows about. This can take awhile, especially if DNS is
out because the network isn't up yet. :-)
A quicky-and-dirty fix is to put your unqualified hostname in your
/etc/hosts file as an alias for the localhost address (127.0.0.1). Some
people also invent a bogus FQDN for localhost ("localhost.localdomain", for
example). For example, if your hostname is "foo":
127.0.0.1 localhost.localdomain localhost foo
You can also run into problems if a program tries to find the domain names
of all the network interfaces addresses in your system. A program will find
127.0.0.1 on the "lo" interface, but that will resolve nicely since it is in
the /etc/hosts file. But 192.168.1.101 on eth0 (or whatever) likely won't be.
A solution to that follows below.
> I waited for the services to timeout and once I was able to login, I tried
> to start X which hung trying to get the host's IP address.
This is probably X trying to connect to the font server, although that's
just a guess.
> I was temporarily able to correct all of this by editing my /etc/hosts
> file and adding the system's hostname and the IP address that the DHCP
> server had given it (specifically 192.168.1.101). Somehow this doesn't
> quite seem correct.
Actually, it would be perfect, except for the fact that DHCP addresses can,
of course, change. I suppose you could just edit the file every time that
happened, but ...
You say you're using a Red Hat system. Red Hat uses two scripts, /sbin/ifup
and /sbin/ifdown, to configure network interfaces. They have a useful feature
where they invoke ifup-local and ifdown-local after they are done (if they
exist).
I solved the problem you're having by creating those scripts, and having
them add/remove the hostname to the /etc/hosts file with the dynamic address.
The scripts are attached to this message.
Usage:
If the network interface is "eth0" you can pretty much just plug-and-play.
If not, you need to add a line with "PRIMARY_INTERFACE=whatever" to your
/etc/sysconfig/network file to tell these scripts which interface is
associated with your hostname.
Hope this helps!
--
Ben Scott <[EMAIL PROTECTED]>
| "Knowledge is always of value, and the value is never predictable. What |
| will come of it, we cannot know." -- Larry Niven |
#!/bin/sh
DEVICE="$1"
THIS="ifdown-local"
# check args
if [ -z "$DEVICE" ] ; then
echo "$THIS: Must specify device (e.g., eth0) as first argument" > /dev/stderr
exit 1
fi
# read in network configuration
NETCFG=/etc/sysconfig/network
if ! [ -f $NETCFG ] ; then
logger -p local0.err -i -t "$THIS" "$NETCFG" does not exist - aborting
exit 1
fi
source $NETCFG
# if hostname isn't set, cough and die
if [ -z "$HOSTNAME" ] ; then
logger -p local0.err -i -t "$THIS" HOSTNAME is not set - aborting
exit 1
fi
# if HOSTNAME is an FQDN, set SHORTNAME to just the hostname
if echo $HOSTNAME | fgrep -q . ; then
SHORTNAME=$( echo $HOSTNAME | awk -F. '{ print $1}' )
fi
# if primary interface isn't selected, assume eth0
if [ -z "$PRIMARY_INTERFACE" ] ; then
PRIMARY_INTERFACE=eth0
logger -p local0.notice -i -t "$THIS" PRIMARY_INTERFACE is not set - assumed
"$PRIMARY_INTERFACE"
fi
# read in device config file
DEVCFG="/etc/sysconfig/network-scripts/ifcfg-$DEVICE"
if ! [ -f "$DEVCFG" ] ; then
logger -p local0.err -i -t "$THIS" "$DEVCFG" does not exist - aborting
exit 1
fi
source $DEVCFG
# if this was the primary interface, and it was dynamically configured...
if [ "$DEVICE" = "$PRIMARY_INTERFACE" ] && [ "$BOOTPROTO" = bootp -o "$BOOTPROTO" =
dhcp ] ; then
# remove the hostname from /etc/hosts
logger -p local0.debug -i -t "$THIS" "removing entry for $HOSTNAME from
/etc/hosts"
grep -v $HOSTNAME < /etc/hosts > /etc/hosts.tmp
mv -f /etc/hosts.tmp /etc/hosts
fi
# END OF FILE
#!/bin/sh
DEVICE="$1"
THIS="ifup-local"
# check args
if [ -z "$DEVICE" ] ; then
echo "$THIS: Must specify device (e.g., eth0) as first argument" > /dev/stderr
exit 1
fi
# read in network configuration
NETCFG=/etc/sysconfig/network
if ! [ -f $NETCFG ] ; then
logger -p local0.err -i -t "$THIS" "$NETCFG" does not exist - aborting
exit 1
fi
source $NETCFG
# if hostname isn't set, cough and die
if [ -z "$HOSTNAME" ] ; then
logger -p local0.err -i -t "$THIS" HOSTNAME is not set - aborting
exit 1
fi
# if HOSTNAME is an FQDN, set SHORTNAME to just the hostname
if echo $HOSTNAME | fgrep -q . ; then
SHORTNAME=$( echo $HOSTNAME | awk -F. '{ print $1}' )
fi
# if primary interface isn't selected, assume eth0
if [ -z "$PRIMARY_INTERFACE" ] ; then
PRIMARY_INTERFACE=eth0
logger -p local0.notice -i -t "$THIS" PRIMARY_INTERFACE is not set - assumed
"$PRIMARY_INTERFACE"
fi
# read in device config file
DEVCFG="/etc/sysconfig/network-scripts/ifcfg-$DEVICE"
if ! [ -f "$DEVCFG" ] ; then
logger -p local0.err -i -t "$THIS" "$DEVCFG" does not exist - aborting
exit 1
fi
source $DEVCFG
# get the interface's IP address
IPADDR=$(ifconfig ${DEVICE} | grep 'inet addr' | awk -F: '{ print $2 } ' | awk '{
print $1 }' )
if [ -z "$IPADDR" ] ; then
logger -p local0.err -i -t "$THIS" unable to determine device IP address -
aborting
exit 1
fi
# if this is the primary interface, and it was dynamically configured...
if [ "$DEVICE" = "$PRIMARY_INTERFACE" ] && [ "$BOOTPROTO" = bootp -o "$BOOTPROTO" =
dhcp ] ; then
# add the hostname to /etc/hosts, removing old entry, if any
logger -p local0.debug -i -t "$THIS" "adding entry for $HOSTNAME to
/etc/hosts"
grep -v $HOSTNAME < /etc/hosts > /etc/hosts.tmp
echo $IPADDR $HOSTNAME $SHORTNAME >> /etc/hosts.tmp
mv -f /etc/hosts.tmp /etc/hosts
fi
# END OF FILE