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 script
|
---|
21 | depends on the files and directories in the <filename
|
---|
22 | class="directory">/etc/network.d</filename> hierarchy.
|
---|
23 | This directory should contain a file for each interface to be
|
---|
24 | configured, such as <filename>interface.xyz</filename>, where
|
---|
25 | <quote>xyz</quote> is a network interface name. Inside this file we
|
---|
26 | would be defining the attributes to this interface, such as its IP
|
---|
27 | address(es), subnet masks, and so forth.</para>
|
---|
28 |
|
---|
29 | <para>The following command creates the <filename>network.conf</filename>
|
---|
30 | file for use by the entire system:</para>
|
---|
31 |
|
---|
32 | <screen><userinput>cat > ${CLFS}/targetfs/etc/network.conf << "EOF"
|
---|
33 | <literal># /etc/network.conf
|
---|
34 | # Global Networking Configuration
|
---|
35 | # interface configuration is in /etc/network.d/
|
---|
36 |
|
---|
37 | # set to yes to enable networking
|
---|
38 | NETWORKING=yes
|
---|
39 |
|
---|
40 | # set to yes to set default route to gateway
|
---|
41 | USE_GATEWAY=no
|
---|
42 |
|
---|
43 | # set to gateway IP address
|
---|
44 | GATEWAY=192.168.0.1
|
---|
45 |
|
---|
46 | # Interfaces to add to br0 bridge
|
---|
47 | # Leave commented to not setup a network bridge
|
---|
48 | # Substitute br0 for eth0 in the interface.eth0 sample below to bring up br0
|
---|
49 | # instead
|
---|
50 | # bcm47xx with vlans:
|
---|
51 | #BRIDGE_INTERFACES="eth0.0 eth0.1 wlan0"
|
---|
52 | # Other access point with a wired eth0 and a wireless wlan0 interface:
|
---|
53 | #BRIDGE_INTERFACES="eth0 wlan0"
|
---|
54 | </literal>
|
---|
55 | EOF</userinput></screen>
|
---|
56 |
|
---|
57 | <para>The <envar>GATEWAY</envar> variable should contain the default
|
---|
58 | gateway IP address, if one is present. If not, then comment out the
|
---|
59 | variable entirely.</para>
|
---|
60 |
|
---|
61 | <para>The following command creates a sample <filename>interface.eth0</filename>
|
---|
62 | file for the <emphasis>eth0</emphasis> device:</para>
|
---|
63 |
|
---|
64 | <screen><userinput>mkdir ${CLFS}/targetfs/etc/network.d &&
|
---|
65 | cat > ${CLFS}/targetfs/etc/network.d/interface.eth0 << "EOF"
|
---|
66 | <literal># Network Interface Configuration
|
---|
67 |
|
---|
68 | # network device name
|
---|
69 | INTERFACE=eth0
|
---|
70 |
|
---|
71 | # set to yes to use DHCP instead of the settings below
|
---|
72 | DHCP=no
|
---|
73 |
|
---|
74 | # IP address
|
---|
75 | IPADDRESS=192.168.1.2
|
---|
76 |
|
---|
77 | # netmask
|
---|
78 | NETMASK=255.255.255.0
|
---|
79 |
|
---|
80 | # broadcast address
|
---|
81 | BROADCAST=192.168.1.255</literal>
|
---|
82 | EOF</userinput></screen>
|
---|
83 |
|
---|
84 | <para>The <envar>INTERFACE</envar> variable should contain the name of
|
---|
85 | the interface interface.</para>
|
---|
86 |
|
---|
87 | <para>The <envar>DHCP</envar> variable if set to yes will allow you to
|
---|
88 | use dhcp. If set to no, you will need to configure the rest of the options.</para>
|
---|
89 |
|
---|
90 | <para>The <envar>IPADDRESS</envar> variable should contain the default
|
---|
91 | IP address for this interface.</para>
|
---|
92 |
|
---|
93 | <para>The <envar>NETMASK</envar> variable should contain the default
|
---|
94 | Subnet Mask for the IP address for this interface.</para>
|
---|
95 |
|
---|
96 | <para>The <envar>BROADCAST</envar> variable should contain the default
|
---|
97 | Broadcast Address for the Subnet Mask of the IP Range being used on
|
---|
98 | this interface.</para>
|
---|
99 |
|
---|
100 | </sect2>
|
---|
101 |
|
---|
102 | <sect2 id="udhcpc.conf">
|
---|
103 | <title>Creating the ${CLFS}/targetfs/etc/udhcpc.conf File</title>
|
---|
104 |
|
---|
105 | <indexterm zone="udhcpc.conf">
|
---|
106 | <primary sortas="e-/etc/udhcpc.conf">/etc/udhcpc.conf</primary>
|
---|
107 | </indexterm>
|
---|
108 |
|
---|
109 | <para>For DHCP to work properly a configuration script is needed.
|
---|
110 | Create a sample udhcpc.conf:</para>
|
---|
111 |
|
---|
112 | <screen><userinput>cat > ${CLFS}/targetfs/etc/udhcpc.conf << "EOF"
|
---|
113 | <literal>#!/bin/sh
|
---|
114 | # udhcpc Interface Configuration
|
---|
115 | # Based on http://lists.debian.org/debian-boot/2002/11/msg00500.html
|
---|
116 | # udhcpc script edited by Tim Riker <Tim@Rikers.org>
|
---|
117 |
|
---|
118 | [ -z "$1" ] && echo "Error: should be called from udhcpc" && exit 1
|
---|
119 |
|
---|
120 | RESOLV_CONF="/etc/resolv.conf"
|
---|
121 | RESOLV_BAK="/etc/resolv.bak"
|
---|
122 |
|
---|
123 | [ -n "$broadcast" ] && BROADCAST="broadcast $broadcast"
|
---|
124 | [ -n "$subnet" ] && NETMASK="netmask $subnet"
|
---|
125 |
|
---|
126 | case "$1" in
|
---|
127 | deconfig)
|
---|
128 | if [ -f "$RESOLV_BAK" ]; then
|
---|
129 | mv "$RESOLV_BAK" "$RESOLV_CONF"
|
---|
130 | fi
|
---|
131 | /sbin/ifconfig $interface 0.0.0.0
|
---|
132 | ;;
|
---|
133 |
|
---|
134 | renew|bound)
|
---|
135 | /sbin/ifconfig $interface $ip $BROADCAST $NETMASK
|
---|
136 |
|
---|
137 | if [ -n "$router" ] ; then
|
---|
138 | while route del default gw 0.0.0.0 dev $interface ; do
|
---|
139 | true
|
---|
140 | done
|
---|
141 |
|
---|
142 | for i in $router ; do
|
---|
143 | route add default gw $i dev $interface
|
---|
144 | done
|
---|
145 | fi
|
---|
146 |
|
---|
147 | if [ ! -f "$RESOLV_BAK" ] && [ -f "$RESOLV_CONF" ]; then
|
---|
148 | mv "$RESOLV_CONF" "$RESOLV_BAK"
|
---|
149 | fi
|
---|
150 |
|
---|
151 | echo -n > $RESOLV_CONF
|
---|
152 | [ -n "$domain" ] && echo search $domain >> $RESOLV_CONF
|
---|
153 | for i in $dns ; do
|
---|
154 | echo nameserver $i >> $RESOLV_CONF
|
---|
155 | done
|
---|
156 | ;;
|
---|
157 | esac
|
---|
158 |
|
---|
159 | exit 0
|
---|
160 | </literal>EOF
|
---|
161 |
|
---|
162 | chmod +x ${CLFS}/targetfs/etc/udhcpc.conf</userinput></screen>
|
---|
163 |
|
---|
164 | </sect2>
|
---|
165 |
|
---|
166 | <sect2 id="resolv.conf">
|
---|
167 | <title>Creating the ${CLFS}/targetfs/etc/resolv.conf File</title>
|
---|
168 |
|
---|
169 | <indexterm zone="resolv.conf">
|
---|
170 | <primary sortas="e-/etc/resolv.conf">/etc/resolv.conf</primary>
|
---|
171 | </indexterm>
|
---|
172 |
|
---|
173 | <para>If the system is going to be connected to the Internet, it will
|
---|
174 | need some means of Domain Name Service (DNS) name resolution to
|
---|
175 | resolve Internet domain names to IP addresses, and vice versa. This is
|
---|
176 | best achieved by placing the IP address of the DNS server, available
|
---|
177 | from the ISP or network administrator, into
|
---|
178 | <filename>/etc/resolv.conf</filename>. Create the file by running the
|
---|
179 | following:</para>
|
---|
180 |
|
---|
181 | <screen><userinput>cat > ${CLFS}/targetfs/etc/resolv.conf << "EOF"
|
---|
182 | <literal># Begin /etc/resolv.conf
|
---|
183 |
|
---|
184 | domain <replaceable>[Your Domain Name]</replaceable>
|
---|
185 | nameserver <replaceable>[IP address of your primary nameserver]</replaceable>
|
---|
186 | nameserver <replaceable>[IP address of your secondary nameserver]</replaceable>
|
---|
187 |
|
---|
188 | # End /etc/resolv.conf</literal>
|
---|
189 | EOF</userinput></screen>
|
---|
190 |
|
---|
191 | <para>Replace <replaceable>[IP address of the nameserver]</replaceable>
|
---|
192 | with the IP address of the DNS most appropriate for the setup. There will
|
---|
193 | often be more than one entry (requirements demand secondary servers for
|
---|
194 | fallback capability). If you only need or want one DNS server, remove the
|
---|
195 | second <emphasis>nameserver</emphasis> line from the file. The IP address
|
---|
196 | may also be a router on the local network.</para>
|
---|
197 |
|
---|
198 | </sect2>
|
---|
199 |
|
---|
200 | </sect1>
|
---|