mirror of
https://github.com/bradfa/clfs-embedded-pregithub.git
synced 2026-01-14 02:58:56 +00:00
Using udhcpc and eth0, on 'ifup eth0' obtain an IP address via DHCP and assign it properly to eth0.
90 lines
2.8 KiB
XML
90 lines
2.8 KiB
XML
<?xml version="1.0" encoding="ISO-8859-1"?>
|
|
<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
|
|
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
|
|
<!ENTITY % general-entities SYSTEM "../../general.ent">
|
|
%general-entities;
|
|
]>
|
|
|
|
<sect1 id="ch-scripts-network">
|
|
<?dbhtml filename="network.html"?>
|
|
|
|
<title>Configuring the network Script</title>
|
|
|
|
<indexterm zone="ch-scripts-network">
|
|
<primary sortas="d-network">network</primary>
|
|
<secondary>configuring</secondary></indexterm>
|
|
|
|
<sect2>
|
|
<title>Creating Network Interface Configuration Files</title>
|
|
|
|
<para>Which interfaces are brought up and down by the network utilities
|
|
depends on the files and directories in the
|
|
<filename class="directory">/etc/network</filename> directory. The
|
|
<filename>interfaces</filename> file should contain a
|
|
description of the interfaces, as done by Debian, and each of the
|
|
directories contain scripts for actions to perform on each type of network
|
|
event.</para>
|
|
|
|
<para>The following command creates the required directories and the
|
|
<filename>interfaces</filename> file, assuming DHCP will be used for
|
|
eth0:</para>
|
|
|
|
<screen><userinput>mkdir -pv ${CLFS}/targetfs/etc/network/if-{post-{up,down},pre-{up,down},up,down}.d
|
|
mkdir -pv ${CLFS}/targetfs/usr/share/udhcpc
|
|
|
|
cat > ${CLFS}/targetfs/etc/network/interfaces << "EOF"
|
|
<literal>auto eth0
|
|
iface eth0 inet dhcp</literal>
|
|
EOF</userinput></screen>
|
|
|
|
<para>For DHCP to work properly with udhcpc, the BusyBox dhcp client, a
|
|
configuration script is needed. Create a simple script to assign the
|
|
provided DHCP address and update <filename>/etc/resolv.conf</filename>:</para>
|
|
|
|
<screen><userinput>cat > ${CLFS}/targetfs/usr/share/udhcpc/default.script << "EOF"
|
|
<literal>#!/bin/sh
|
|
# udhcpc Interface Configuration
|
|
# Based on http://lists.debian.org/debian-boot/2002/11/msg00500.html
|
|
# udhcpc script edited by Tim Riker <Tim@Rikers.org>
|
|
|
|
[ -z "$1" ] && echo "Error: should be called from udhcpc" && exit 1
|
|
|
|
RESOLV_CONF="/etc/resolv.conf"
|
|
[ -n "$broadcast" ] && BROADCAST="broadcast $broadcast"
|
|
[ -n "$subnet" ] && NETMASK="netmask $subnet"
|
|
|
|
case "$1" in
|
|
deconfig)
|
|
/sbin/ifconfig $interface 0.0.0.0
|
|
;;
|
|
|
|
renew|bound)
|
|
/sbin/ifconfig $interface $ip $BROADCAST $NETMASK
|
|
|
|
if [ -n "$router" ] ; then
|
|
while route del default gw 0.0.0.0 dev $interface ; do
|
|
true
|
|
done
|
|
|
|
for i in $router ; do
|
|
route add default gw $i dev $interface
|
|
done
|
|
fi
|
|
|
|
echo -n > $RESOLV_CONF
|
|
[ -n "$domain" ] && echo search $domain >> $RESOLV_CONF
|
|
for i in $dns ; do
|
|
echo nameserver $i >> $RESOLV_CONF
|
|
done
|
|
;;
|
|
esac
|
|
|
|
exit 0
|
|
</literal>EOF
|
|
|
|
chmod +x ${CLFS}/targetfs/usr/share/udhcpc/default.script</userinput></screen>
|
|
|
|
</sect2>
|
|
|
|
</sect1>
|