1 | <?xml version="1.0" encoding="ISO-8859-1"?>
|
---|
2 | <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
|
---|
3 | "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
|
---|
4 | <!ENTITY % general-entities SYSTEM "../../general.ent">
|
---|
5 | %general-entities;
|
---|
6 | ]>
|
---|
7 |
|
---|
8 | <sect1 id="ch-scripts-network">
|
---|
9 | <?dbhtml filename="network.html"?>
|
---|
10 |
|
---|
11 | <title>Configuring the network Script</title>
|
---|
12 |
|
---|
13 | <indexterm zone="ch-scripts-network">
|
---|
14 | <primary sortas="d-network">network</primary>
|
---|
15 | <secondary>configuring</secondary></indexterm>
|
---|
16 |
|
---|
17 | <sect2>
|
---|
18 | <title>Creating Network Interface Configuration Files</title>
|
---|
19 |
|
---|
20 | <para>Which interfaces are brought up and down by the network utilities
|
---|
21 | depends on the files and directories in the
|
---|
22 | <filename class="directory">/etc/network</filename> directory. The
|
---|
23 | <filename>interfaces</filename> file should contain a
|
---|
24 | description of the interfaces, as done by Debian, and each of the
|
---|
25 | directories contain scripts for actions to perform on each type of network
|
---|
26 | event.</para>
|
---|
27 |
|
---|
28 | <para>The following command creates the required directories and the
|
---|
29 | <filename>interfaces</filename> file, assuming DHCP will be used for
|
---|
30 | eth0:</para>
|
---|
31 |
|
---|
32 | <screen><userinput>mkdir -pv ${CLFS}/targetfs/etc/network/if-{post-{up,down},pre-{up,down},up,down}.d
|
---|
33 | mkdir -pv ${CLFS}/targetfs/usr/share/udhcpc
|
---|
34 |
|
---|
35 | cat > ${CLFS}/targetfs/etc/network/interfaces << "EOF"
|
---|
36 | <literal>auto eth0
|
---|
37 | iface eth0 inet dhcp</literal>
|
---|
38 | EOF</userinput></screen>
|
---|
39 |
|
---|
40 | <para>For DHCP to work properly with udhcpc, the BusyBox dhcp client, a
|
---|
41 | configuration script is needed. Create a simple script to assign the
|
---|
42 | provided DHCP address and update <filename>/etc/resolv.conf</filename>:</para>
|
---|
43 |
|
---|
44 | <screen><userinput>cat > ${CLFS}/targetfs/usr/share/udhcpc/default.script << "EOF"
|
---|
45 | <literal>#!/bin/sh
|
---|
46 | # udhcpc Interface Configuration
|
---|
47 | # Based on http://lists.debian.org/debian-boot/2002/11/msg00500.html
|
---|
48 | # udhcpc script edited by Tim Riker <Tim@Rikers.org>
|
---|
49 |
|
---|
50 | [ -z "$1" ] && echo "Error: should be called from udhcpc" && exit 1
|
---|
51 |
|
---|
52 | RESOLV_CONF="/etc/resolv.conf"
|
---|
53 | [ -n "$broadcast" ] && BROADCAST="broadcast $broadcast"
|
---|
54 | [ -n "$subnet" ] && NETMASK="netmask $subnet"
|
---|
55 |
|
---|
56 | case "$1" in
|
---|
57 | deconfig)
|
---|
58 | /sbin/ifconfig $interface 0.0.0.0
|
---|
59 | ;;
|
---|
60 |
|
---|
61 | renew|bound)
|
---|
62 | /sbin/ifconfig $interface $ip $BROADCAST $NETMASK
|
---|
63 |
|
---|
64 | if [ -n "$router" ] ; then
|
---|
65 | while route del default gw 0.0.0.0 dev $interface ; do
|
---|
66 | true
|
---|
67 | done
|
---|
68 |
|
---|
69 | for i in $router ; do
|
---|
70 | route add default gw $i dev $interface
|
---|
71 | done
|
---|
72 | fi
|
---|
73 |
|
---|
74 | echo -n > $RESOLV_CONF
|
---|
75 | [ -n "$domain" ] && echo search $domain >> $RESOLV_CONF
|
---|
76 | for i in $dns ; do
|
---|
77 | echo nameserver $i >> $RESOLV_CONF
|
---|
78 | done
|
---|
79 | ;;
|
---|
80 | esac
|
---|
81 |
|
---|
82 | exit 0
|
---|
83 | </literal>EOF
|
---|
84 |
|
---|
85 | chmod +x ${CLFS}/targetfs/usr/share/udhcpc/default.script</userinput></screen>
|
---|
86 |
|
---|
87 | </sect2>
|
---|
88 |
|
---|
89 | </sect1>
|
---|