source: clfs-embedded/BOOK/bootscripts/common/network.xml@ 3450c8f

Last change on this file since 3450c8f was 49c9bc5, checked in by Andrew Bradford <bradfa@…>, 14 years ago

Fixed udhcpc.conf script file name

Thanks to Steven Swann (sjs205.linux at gmail) for point this out.
Fixes #755.

  • Property mode set to 100644
File size: 6.3 KB
RevLine 
[a9e389d]1<?xml version="1.0" encoding="ISO-8859-1"?>
[bd48e48]2<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
3 "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
[a9e389d]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
[1d67150]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
[a9e389d]27 address(es), subnet masks, and so forth.</para>
28
[1d67150]29 <para>The following command creates the <filename>network.conf</filename>
30 file for use by the entire system:</para>
[a9e389d]31
[de9651e]32<screen><userinput>cat &gt; ${CLFS}/etc/network.conf &lt;&lt; "EOF"
[1d67150]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
38NETWORKING=yes
[a9e389d]39
[1d67150]40# set to yes to set default route to gateway
41USE_GATEWAY=no
42
43# set to gateway IP address
[423fe6b]44GATEWAY=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>
[1d67150]55EOF</userinput></screen>
[a9e389d]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
[1d67150]61 <para>The following command creates a sample <filename>interface.eth0</filename>
62 file for the <emphasis>eth0</emphasis> device:</para>
63
[de9651e]64<screen><userinput>mkdir ${CLFS}/etc/network.d &amp;&amp;
65cat &gt; ${CLFS}/etc/network.d/interface.eth0 &lt;&lt; "EOF"
[1d67150]66<literal># Network Interface Configuration
67
68# network device name
69INTERFACE=eth0
70
71# set to yes to use DHCP instead of the settings below
72DHCP=no
73
74# IP address
75IPADDRESS=192.168.1.2
76
77# netmask
78NETMASK=255.255.255.0
79
80# broadcast address
81BROADCAST=192.168.1.255</literal>
82EOF</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>
[a9e389d]99
100 </sect2>
101
[423fe6b]102 <sect2 id="udhcpc.conf">
103 <title>Creating the ${CLFS}/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
[49c9bc5]112<screen><userinput>cat &gt; ${CLFS}/etc/udhcpc.conf &lt;&lt; "EOF"
[423fe6b]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 &lt;Tim@Rikers.org&gt;
117
118[ -z "$1" ] &amp;&amp; echo "Error: should be called from udhcpc" &amp;&amp; exit 1
119
120RESOLV_CONF="/etc/resolv.conf"
121RESOLV_BAK="/etc/resolv.bak"
122
123[ -n "$broadcast" ] &amp;&amp; BROADCAST="broadcast $broadcast"
124[ -n "$subnet" ] &amp;&amp; NETMASK="netmask $subnet"
125
126case "$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" ] &amp;&amp; [ -f "$RESOLV_CONF" ]; then
148 mv "$RESOLV_CONF" "$RESOLV_BAK"
149 fi
150
151 echo -n &gt; $RESOLV_CONF
152 [ -n "$domain" ] &amp;&amp; echo search $domain &gt;&gt; $RESOLV_CONF
153 for i in $dns ; do
154 echo nameserver $i &gt;&gt; $RESOLV_CONF
155 done
156 ;;
157esac
158
159exit 0
160</literal>EOF
161
162chmod +x ${CLFS}/etc/udhcpc.conf</userinput></screen>
163
164 </sect2>
165
[a9e389d]166 <sect2 id="resolv.conf">
[de9651e]167 <title>Creating the ${CLFS}/etc/resolv.conf File</title>
[a9e389d]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
[de9651e]181<screen><userinput>cat &gt; ${CLFS}/etc/resolv.conf &lt;&lt; "EOF"
[a9e389d]182<literal># Begin /etc/resolv.conf
183
184domain <replaceable>[Your Domain Name]</replaceable>
185nameserver <replaceable>[IP address of your primary nameserver]</replaceable>
186nameserver <replaceable>[IP address of your secondary nameserver]</replaceable>
187
188# End /etc/resolv.conf</literal>
189EOF</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>
Note: See TracBrowser for help on using the repository browser.