glfs/connect/dhcp/bootscripts.xml
Igor Živković 369af35a2a s/source/./ in init scripts
git-svn-id: svn://svn.linuxfromscratch.org/BLFS/trunk/BOOK@1776 af4574ff-66df-0310-9fd7-8a98e5e911e0
2004-02-08 00:50:23 +00:00

102 lines
4.2 KiB
XML

<sect1 id="dhcpclient" xreflabel="Configuring the LFS bootscripts to support DHCP clients">
<?dbhtml filename="configdhcp.html" dir="connect"?>
<title>Configuring the <acronym>LFS</acronym> bootscripts to support <acronym>DHCP</acronym> clients</title>
<sect2><title>Config files</title>
<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>
</sect2>
<sect2><title>Configuration Information</title>
<para>Note that on this and the following pages, we
use <emphasis role="strong">eth0</emphasis> as the example interface.
If you want to configure a different (or more than one) interface, simply
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>
<para>If the interface you intend to use as your default gateway is going to
use <acronym>DHCP</acronym>, the first step is to remove the <envar>GATEWAY
</envar> and <envar>GATEWAY_IF</envar> variables
from <filename>/etc/sysconfig/network</filename>. This will only need to be
done once.</para>
<screen><userinput><command>cd /etc/sysconfig &amp;&amp;
cp network network.bak &amp;&amp;
sed "s/GATEWAY/# GATEWAY/" network.bak > network</command></userinput></screen>
<para>You then need to create scripts which will override the default
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>
<screen><userinput><command>cat &gt; /etc/sysconfig/network-devices/ifup-eth0 &lt;&lt; "EOF" </command>
#!/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
<command>EOF</command></userinput></screen>
<para>Then the <filename>ifdown-eth0</filename> script:</para>
<screen><userinput><command>cat &gt; /etc/sysconfig/network-devices/ifdown-eth0 &lt;&lt; "EOF" </command>
#!/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
<command>EOF</command></userinput></screen>
<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 &amp;&amp;
cat &gt; /etc/hosts &lt;&lt; "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>
<screen><userinput><command>chmod 755 /etc/sysconfig/network-devices/ifup-eth0 &amp;&amp;
chmod 755 /etc/sysconfig/network-devices/ifdown-eth0</command></userinput></screen>
<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>
</sect2>
</sect1>