/[gentoo]/xml/htdocs/doc/en/handbook/hb-net-advanced.xml
Gentoo

Diff of /xml/htdocs/doc/en/handbook/hb-net-advanced.xml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.10 Revision 1.11
2<!DOCTYPE sections SYSTEM "/dtd/book.dtd"> 2<!DOCTYPE sections SYSTEM "/dtd/book.dtd">
3 3
4<!-- The content of this document is licensed under the CC-BY-SA license --> 4<!-- The content of this document is licensed under the CC-BY-SA license -->
5<!-- See http://creativecommons.org/licenses/by-sa/2.5 --> 5<!-- See http://creativecommons.org/licenses/by-sa/2.5 -->
6 6
7<!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/handbook/hb-net-advanced.xml,v 1.10 2005/12/21 12:20:43 jkt Exp $ --> 7<!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/handbook/hb-net-advanced.xml,v 1.11 2005/12/22 19:55:49 jkt Exp $ -->
8 8
9<sections> 9<sections>
10 10
11<version>1.3</version> 11<version>1.4</version>
12<date>2005-08-14</date> 12<date>2005-12-22</date>
13 13
14<section> 14<section>
15<title>Advanced Configuration</title> 15<title>Advanced Configuration</title>
16<body> 16<body>
17 17
18<p> 18<p>
19The config_eth0 variable is the heart of an interface's configuration. It's a 19The <c>config_eth0</c> variable is the heart of an interface configuration. It's
20high level instruction list for configuring the interface (eth0 in this case). 20a high level instruction list for configuring the interface (<c>eth0</c> in this
21Each command in the instruction list is performed sequentially. The interface is 21case). Each command in the instruction list is performed sequentially. The
22deemed OK if at least one command works. 22interface is deemed OK if at least one command works.
23</p> 23</p>
24 24
25<p> 25<p>
26Here's a list of in-built instructions. 26Here's a list of in-built instructions.
27</p> 27</p>
30<tr> 30<tr>
31 <th>Command</th> 31 <th>Command</th>
32 <th>Description</th> 32 <th>Description</th>
33</tr> 33</tr>
34<tr> 34<tr>
35 <ti>null</ti> 35 <ti><c>null</c></ti>
36 <ti>Do nothing</ti> 36 <ti>Do nothing</ti>
37</tr> 37</tr>
38<tr> 38<tr>
39 <ti>noop</ti> 39 <ti><c>noop</c></ti>
40 <ti> 40 <ti>
41 If the interface is up and there is an address then abort configuration 41 If the interface is up and there is an address then abort configuration
42 successfully 42 successfully
43 </ti> 43 </ti>
44</tr> 44</tr>
46 <ti>an IPv4 or IPv6 address</ti> 46 <ti>an IPv4 or IPv6 address</ti>
47 <ti>Add the address to the interface</ti> 47 <ti>Add the address to the interface</ti>
48</tr> 48</tr>
49<tr> 49<tr>
50 <ti> 50 <ti>
51 dhcp, adsl or apipa (or a custom command from a 3rd party module) 51 <c>dhcp</c>, <c>adsl</c> or <c>apipa</c> (or a custom command from a 3rd
52 </ti> 52 party module)
53 <ti> 53 </ti>
54 <ti>
54 Run the module which provides the command. For example "dhcp" will run a 55 Run the module which provides the command. For example <c>dhcp</c> will run
55 module that provides dhcp which can be one of either dhcpcd, udhcpc, 56 a module that provides DHCP which can be one of either <c>dhcpcd</c>,
56 dhclient or pump. 57 <c>udhcpc</c>, <c>dhclient</c> or <c>pump</c>.
57 </ti> 58 </ti>
58</tr> 59</tr>
59</table> 60</table>
60 61
61<p> 62<p>
94 "apipa" 95 "apipa"
95) 96)
96</pre> 97</pre>
97 98
98<note> 99<note>
99When using the ifconfig module and adding more than one address, interface 100When using the <c>ifconfig</c> module and adding more than one address,
100aliases are created for each extra address. So with the above two examples you 101interface aliases are created for each extra address. So with the above two
101will get interfaces eth0, eth0:1 and eth0:2. You cannot do anything special with 102examples you will get interfaces <c>eth0</c>, <c>eth0:1</c> and <c>eth0:2</c>.
102these interfaces as the kernel and other programs will just treat eth0:1 and 103You cannot do anything special with these interfaces as the kernel and other
103eth0:2 as eth0. 104programs will just treat <c>eth0:1</c> and <c>eth0:2</c> as <c>eth0</c>.
104</note> 105</note>
105 106
106<impo> 107<impo>
107The fallback order is important! If we did not specify the "null" option then 108The fallback order is important! If we did not specify the <c>null</c> option
108the "apipa" command would only be run if the "noop" command failed. 109then the <c>apipa</c> command would only be run if the <c>noop</c> command
110failed.
109</impo> 111</impo>
110 112
111<note> 113<note>
112<uri link="?part=4&amp;chap=3#apipa">APIPA</uri> and <uri 114<uri link="?part=4&amp;chap=3#apipa">APIPA</uri> and <uri
113link="?part=4&amp;chap=3#dhcp">DHCP</uri> are discussed later. 115link="?part=4&amp;chap=3#dhcp">DHCP</uri> are discussed later.
119<title>Network Dependencies</title> 121<title>Network Dependencies</title>
120<body> 122<body>
121 123
122<p> 124<p>
123Init scripts in <path>/etc/init.d</path> can depend on a specific network 125Init scripts in <path>/etc/init.d</path> can depend on a specific network
124interface or just net. "net" can be defined in <path>/etc/conf.d/rc</path> to 126interface or just net. <c>net</c> can be defined in <path>/etc/conf.d/rc</path>
125mean different things using the <c>RC_NET_STRICT_CHECKING</c> variable. 127to mean different things using the <c>RC_NET_STRICT_CHECKING</c> variable.
126</p> 128</p>
127 129
128<table> 130<table>
129<tr> 131<tr>
130 <th>Value</th> 132 <th>Value</th>
131 <th>Description</th> 133 <th>Description</th>
132</tr> 134</tr>
133<tr> 135<tr>
134 <ti>none</ti> 136 <ti><c>none</c></ti>
135 <ti>The net service is always considered up</ti> 137 <ti>The <path>net</path> service is always considered up</ti>
136</tr>
137<tr> 138</tr>
139<tr>
138 <ti>no</ti> 140 <ti><c>no</c></ti>
139 <ti>
140 This basically means that at least one net.* service besides net.lo must be
141 up. This can be used by notebook users that have a wifi and a static nic,
142 and only wants one up at any given time to have the net service seen as up.
143 </ti> 141 <ti>
144</tr> 142 This basically means that at least one <path>net.*</path> service besides
145<tr> 143 <path>net.lo</path> must be up. This can be used by notebook users that
146 <ti>lo</ti> 144 have a WIFI and a static NIC, and only wants one up at any given time to
145 have the net service seen as up.
147 <ti> 146 </ti>
148 This is the same as the 'no' option, but net.lo is also counted. This should 147</tr>
149 be useful to people that do not care about any specific interface being up 148<tr>
150 at boot. 149 <ti><c>lo</c></ti>
151 </ti> 150 <ti>
152</tr> 151 This is the same as the <c>no</c> option, but <path>net.lo</path> is also
153<tr> 152 counted. This should be useful to people that do not care about any specific
154 <ti>yes</ti> 153 interface being up at boot.
155 <ti> 154 </ti>
155</tr>
156<tr>
157 <ti><c>yes</c></ti>
158 <ti>
156 For this ALL network interfaces MUST be up for the 'net' service to be 159 For this ALL network interfaces MUST be up for the <path>net</path> service
157 considered up. 160 to be considered up.
158 </ti> 161 </ti>
159</tr> 162</tr>
160</table> 163</table>
161 164
162<p> 165<p>
163But what about net.br0 depending on net.eth0 and net.eth1? net.eth1 may be a 166But what about <path>net.br0</path> depending on <path>net.eth0</path> and
164wireless or ppp device that needs configuration before it can be added to the 167<path>net.eth1</path>? <path>net.eth1</path> may be a wireless or PPP device
165bridge. This cannot be done in <path>/etc/init.d/net.br0</path> as that's a 168that needs configuration before it can be added to the bridge. This cannot be
166symbolic link to net.lo 169done in <path>/etc/init.d/net.br0</path> as that's a symbolic link to
167</p> 170<path>net.lo</path>.
168
169<p> 171</p>
170The answer is making your own depend() function in <path>/etc/conf.d/net</path>. 172
173<p>
174The answer is making your own <c>depend()</c> function in
175<path>/etc/conf.d/net</path>.
171</p> 176</p>
172 177
173<pre caption="net.br0 dependency in /etc/conf.d/net"> 178<pre caption="net.br0 dependency in /etc/conf.d/net">
174<comment># You can use any dependency (use, after, before) as found in current scripts</comment> 179<comment># You can use any dependency (use, after, before) as found in current scripts</comment>
175depend_br0() { 180depend_br0() {
193<p> 198<p>
194Variable names are dynamic. They normally follow the structure of 199Variable names are dynamic. They normally follow the structure of
195<c>variable_${interface|mac|essid|apmac}</c>. For example, the variable 200<c>variable_${interface|mac|essid|apmac}</c>. For example, the variable
196<c>dhcpcd_eth0</c> holds the value for dhcpcd options for eth0 and 201<c>dhcpcd_eth0</c> holds the value for dhcpcd options for eth0 and
197<c>dhcpcd_essid</c> holds the value for dhcpcd options when any interface 202<c>dhcpcd_essid</c> holds the value for dhcpcd options when any interface
198connects to the essid "essid". 203connects to the ESSID "essid".
199</p> 204</p>
200 205
201<p> 206<p>
202However, there is no hard and fast rule that states interface names must be 207However, there is no hard and fast rule that states interface names must be
203ethx. In fact, many wireless interfaces have names like wlanx, rax as well as 208ethx. In fact, many wireless interfaces have names like wlanx, rax as well as
209 214
210<p> 215<p>
211The downside of all this is that Gentoo uses bash variables for networking - 216The downside of all this is that Gentoo uses bash variables for networking -
212and bash cannot use anything outside of English alpha-numerics. To get around 217and bash cannot use anything outside of English alpha-numerics. To get around
213this limitation we change every character that is not an English alpha-numeric 218this limitation we change every character that is not an English alpha-numeric
214into a _ character. 219into a <c>_</c> character.
215</p> 220</p>
216 221
217<p> 222<p>
218Another downside of bash is the content of variables - some characters need to 223Another downside of bash is the content of variables - some characters need to
219be escaped. This can be achived by placing the \ character in front of the 224be escaped. This can be achived by placing the <c>\</c> character in front of
220character that needs to be escaped. The following list of characters needs 225the character that needs to be escaped. The following list of characters needs
221to be escaped in this way: <c>"</c>, <c>'</c> and <c>\</c>. 226to be escaped in this way: <c>"</c>, <c>'</c> and <c>\</c>.
222</p> 227</p>
223 228
224<p> 229<p>
225In this example we use wireless ESSID as they can contain the widest scope 230In this example we use wireless ESSID as they can contain the widest scope

Legend:
Removed from v.1.10  
changed lines
  Added in v.1.11

  ViewVC Help
Powered by ViewVC 1.1.20