Configuring the LFS bootscripts to support DHCP clients
Config files
/etc/sysconfig/network,
/etc/sysconfig/network-devices/ifup-eth0,
/etc/sysconfig/network-devices/ifdown-eth0,
/etc/sysconfig/network-devices/ifconfig.eth0
Configuration Information
Note that on this and the following pages, we
use eth0 as the example interface.
If you want to configure a different (or more than one) interface, simply
replace eth0 with the interface you wish to
use.
These instructions will convert the configuration files from
LFS (a static configuration) to a configuration using the
DHCP protocol. Note that static and
DHCP-based interfaces can co-exist on a
LFS system. To do this, you should only make the
alterations to those interfaces which need to support
DHCP. All of the instructions on this page are applicable
no matter which DHCP client you intend to use.
If the interface you intend to use as your default gateway is going to
use DHCP, the first step is to remove the GATEWAY
and GATEWAY_IF variables
from /etc/sysconfig/network. This will only need to be
done once.
cd /etc/sysconfig &&
cp network network.bak &&
sed "s/GATEWAY/# GATEWAY/" network.bak > network
You then need to create scripts which will override the default
network scripts and provide DHCP support. These two scripts
are generic and so for use with both DHCP clients. First,
the ifup-eth0 script:
cat > /etc/sysconfig/network-devices/ifup-eth0 << "EOF"
#!/bin/sh
. /etc/sysconfig/rc || exit
. $rc_functions || exit
. $network_devices/ifconfig.eth0 || exit
echo "Bringing up the eth0 interface..."
modprobe eth0
loadproc $DHCP_PROG $DHCP_START
EOF
Then the ifdown-eth0 script:
cat > /etc/sysconfig/network-devices/ifdown-eth0 << "EOF"
#!/bin/sh
. /etc/sysconfig/rc || exit
. $rc_functions || exit
. $network_devices/ifconfig.eth0 || exit
echo "Bringing down the eth0 interface..."
$DHCP_PROG $DHCP_STOP
evaluate_retval
EOF
Next, we need to make corrections to the
/etc/hosts file. Be sure to replace
HOSTNAME and
DOMAIN_NAME with apropriate values.
mv -f /etc/hosts /etc/hosts.bak &&
cat > /etc/hosts << "EOF"
# Begin /etc/hosts
127.0.0.1 HOSTNAME HOSTNAME.DOMAIN_NAME localhost localhost.localdomain
# End /etc/hosts
EOF
Finally, we need to make the scripts executable:
chmod 755 /etc/sysconfig/network-devices/ifup-eth0 &&
chmod 755 /etc/sysconfig/network-devices/ifdown-eth0
This script, in its current state,
will cause an error at shutdown. At the moment, it
is best to just live with the error. The network scripts for
LFS and BLFS are currently being
revised. In the interim, you can use a simple workaround to rid yourself
of the error. Move your K80network stop scripts to
K49network. You must be absolutely certain,
however, that you have all network filesystems unmounted before this
script is executed.