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