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

Contents of /xml/htdocs/doc/en/handbook/hb-net-modules.xml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations) (download) (as text)
Thu Jun 9 07:33:59 2005 UTC (8 years, 10 months ago) by swift
Branch: MAIN
File MIME type: application/xml
#88188 - New baselayout -> new part on the Gentoo Handbook

1 <?xml version="1.0" encoding="UTF-8"?>
2 <!DOCTYPE sections SYSTEM "/dtd/book.dtd">
3
4 <!-- The content of this document is licensed under the CC-BY-SA license -->
5 <!-- See http://creativecommons.org/licenses/by-sa/2.0 -->
6
7 <sections>
8
9 <version>1.0</version>
10 <date>2005-06-06</date>
11
12 <section>
13 <title>Network Modules</title>
14 <body>
15
16 <p>
17 We now support modular networking scripts, which means we can easily
18 add support for new interface types and configuration modules while keeping
19 compatibility with existing ones.
20 </p>
21
22 <p>
23 Modules load by default if the package they need is installed. If
24 you specify a module here that doesn't have its package installed
25 then you get an error stating which package you need to install.
26 Ideally, you only use the modules setting when you have two or more
27 packages installed that supply the same service and you need to prefer
28 one over the other.
29 </p>
30
31 <pre caption="Module preference">
32 <comment># Prefer iproute2 over ifconfig</comment>
33 modules=( "iproute2" )
34
35 <comment># You can also specify other modules for an interface
36 # In this case we prefer udhcpc over dhcpcd</comment>
37 modules_eth0=( "udhcpc" )
38
39 <comment># You can also specify which modules not to use - for example you may be
40 # using a supplicant or linux-wlan-ng to control wireless configuration but
41 # you still want to configure network settings per ESSID associated with.</comment>
42 modules=( "!iwconfig" )
43 </pre>
44
45 </body>
46 </section>
47
48 <section>
49 <title>Interface Handlers</title>
50 <body>
51
52 <p>
53 We provide two interface handlers presently: ifconfig and iproute2.
54 You need one of these to do any kind of network configuration.
55 </p>
56
57 <p>
58 ifconfig is the current Gentoo default and it's included in the system profile.<br/>
59 iproute2 is a more powerful and flexible package, but it's not included by default.
60 </p>
61
62 <pre caption="To install iproute2">
63 # <i>emerge sys-apps/iproute2</i>
64
65 <comment># To prefer iproute2 over ifconfig if both are installed</comment>
66 modules=( "iproute2" )
67 </pre>
68
69 <p>
70 As both ifconfig and iproute2 do very similar things we allow their basic configuration
71 to work with each other. For example both the below code snippets work regardless of
72 which module you are using.
73 </p>
74
75 <pre caption="ifconfig and iproute2 examples">
76 config_eth0=( "192.168.0.2/24" )
77 config_eth0=( "192.168.0.2 netmask 255.255.255.0" )
78
79 <comment># We can also specify broadcast</comment>
80 config_eth0=( "192.168.0.2/24 brd 192.168.0.255" )
81 config_eth0=( "192.168.0.2 netmask 255.255.255.0 broadcast 192.168.0.255" )
82 </pre>
83
84 </body>
85 </section>
86
87 <section id="dhcp">
88 <title>DHCP</title>
89 <body>
90
91 <p>
92 DHCP is a means of obtaining network information (IP address, DNS servers,
93 Gateway, etc) from a DHCP server. This means that if there is a DHCP server
94 running on the network, you just have to tell each client to use DHCP and it
95 sets up the network all by itself. Of course, you will have to configure for
96 other things like wireless, ppp or other things if required before you can use
97 DHCP.
98 </p>
99
100 <p>
101 DHCP can be provided by dhclient, dhcpcd, dhclient, pump or udhcpc. Each DHCP module
102 has its pros and cons - here's a quick run down.
103 </p>
104
105 <table>
106 <tr>
107 <th>DHCP Module</th>
108 <th>Package</th>
109 <th>Pros</th>
110 <th>Cons</th>
111 </tr>
112 <tr>
113 <ti>dhclient</ti>
114 <ti>net-misc/dhcp</ti>
115 <ti>
116 Made by ISC, the same people who make the BIND DNS software<br />
117 Very configurable
118 </ti>
119 <ti>
120 Configuration is overly complex<br />
121 Software is quite bloated<br />
122 Cannot get NTP servers from DHCP<br />
123 Does not send hostname by default
124 </ti>
125 </tr>
126 <tr>
127 <ti>dhcpcd</ti>
128 <ti>net-misc/dhcpcd</ti>
129 <ti>
130 Long time Gentoo default<br />
131 No reliance on outside tools
132 </ti>
133 <ti>
134 No longer maintained upstream<br />
135 Can be slow at times<br />
136 Does not daemonize when lease is infinite
137 </ti>
138 </tr>
139 <tr>
140 <ti>pump</ti>
141 <ti>net-misc/pump</ti>
142 <ti>
143 Lightweight<br />
144 No reliance on outside tools
145 </ti>
146 <ti>
147 No longer maintained upstream<br />
148 Unreliable, especially over modems<br />
149 Cannot get NIS servers from DHCP
150 </ti>
151 </tr>
152 <tr>
153 <ti>udhcpc</ti>
154 <ti>net-misc/udhcp</ti>
155 <ti>
156 Lightweight - smallest dhcp client around<br />
157 Made for embedded systems
158 </ti>
159 <ti>
160 Unproven - no distro uses it by default<br />
161 Cannot define a timeout beyond 3 seconds
162 </ti>
163 </tr>
164 </table>
165
166 <p>
167 If you have more than one DHCP client installed, you need to specify which
168 one to use - otherwise we default to dhcpcd if available.
169 </p>
170
171 <p>
172 To send specific options to the dhcp module, use module_eth0="..."
173 <e>(change module to the DHCP module you're using - ie dhcpcd_eth0)</e>
174 </p>
175
176 <p>
177 We try and make DHCP relatively agnostic - as such we support the following
178 commands using the dhcp_eth0 variable. The default is not to set any of them
179 </p>
180
181 <ul>
182 <li>release - releases the IP address for re-use</li>
183 <li>nodns - don't overwrite /etc/resolv.conf</li>
184 <li>nontp - don't overwrite /etc/ntp.conf</li>
185 <li>nonis - don't overwrite /etc/yp.conf</li>
186 </ul>
187
188 <pre caption="Sample DHCP configuration in /etc/conf.d/net">
189 <comment># Only needed if you have more than one DHCP module installed</comment>
190 modules=( "dhcpcd" )
191
192 config_eth0=( "dhcp" )
193 dhcpcd_eth0="-t 10" <comment># Timeout after 10 seconds</comment>
194 dhcp_eth0="release nodns nontp nonis" <comment># Only get an address</comment>
195 </pre>
196
197 <note>
198 dhcpcd, udhcpc and pump send the current hostname to the DHCP server by
199 default so you don't need to specify this anymore.
200 </note>
201
202 </body>
203 </section>
204
205 <section>
206 <title>ADSL Modem</title>
207 <body>
208
209 <p>
210 First we need to install the ADSL software.
211 </p>
212
213 <pre caption="Install the rp-pppoe package">
214 # <i>emerge net-dialup/rp-pppoe</i>
215 </pre>
216
217 <warn>
218 baselayout-1.11.x supports PPPOE only<br/>
219 Hopefully future versions will support PPPOA<br/>
220 </warn>
221
222 <p>
223 Now we need to instruct configure eth0 to be an ADSL interface and enter our
224 username.
225 </p>
226
227 <pre caption="Configure eth0 for ADSL">
228 config_eth0=( "adsl" )
229 user_eth0="username"
230 </pre>
231
232 <p>
233 Finally you need to define your username and password in
234 <path>/etc/ppp/pap-secrets</path>
235 </p>
236
237 <pre caption="sample /etc/ppp/pap-secrets">
238 <comment># The * is important</comment>
239 "username" * "password"
240 </pre>
241
242 </body>
243 </section>
244
245 <section id="apipa">
246 <title>APIPA (Automatic Private IP Addressing)</title>
247 <body>
248
249 <p>
250 APIPA tries to find a free address in the range 169.254.0.0-169.254.255.255
251 by arping a random address in that range on the interface. If no reply is
252 found then we assign that address to the interface.
253 </p>
254
255 <p>
256 This is only useful for LANs where there is no DHCP server and you don't
257 connect directly to the internet and all other computers use APIPA.
258 </p>
259
260 <p>
261 For APIPA support, emerge net-misc/iputils or net-analyzer/arping
262 </p>
263
264 <pre caption="APIPA configuration in /etc/conf.d/net">
265 <comment># Try DHCP first - if that fails then fallback to APIPA</comment>
266 config_eth0=( "dhcp" )
267 fallback_eth0=( "apipa" )
268
269 <comment># Just use APIPA</comment>
270 config_eth0=( "apipa" )
271 </pre>
272
273 </body>
274 </section>
275
276 <section>
277 <title>Bonding</title>
278 <body>
279
280 <p>
281 For link bonding/trunking emerge net-misc/ifenslave
282 </p>
283
284 <p>
285 Bonding is used to increase network bandwidth. If you have two network
286 cards going to the same network, you can bond them together so your
287 applications see just one interface but they really use both network cards.
288 </p>
289
290 <pre caption="bonding configuration in /etc/conf.d/net">
291 <comment>To bond interfaces together</comment>
292 slaves_bond0="eth0 eth1 eth2"
293
294 <comment># You may not want to assign an IP to the bonded interface</comment>
295 config_bond0=( "null" )
296
297 <comment># Depend on eth0, eth1 and eth2 as they may require extra configuration</comment>
298 depend_bond0() {
299 need net.eth0 net.eth1 net.eth2
300 }
301 </pre>
302
303 </body>
304 </section>
305
306 <section>
307 <title>Bridging (802.1d support)</title>
308 <body>
309
310 <p>
311 For bridging support emerge net-misc/bridge-utils
312 </p>
313
314 <p>
315 Bridging is used to join networks together. For example, you may have a
316 server that connects to the internet via an ADSL modem and a wireless
317 access card to enable other computers to connect to the internet via the
318 ADSL modem. You could create a bridge to join the two interfaces together.
319 </p>
320
321 <pre caption="Bridge configuration in /etc/conf.d/net">
322 <comment># Configure the bridge - "man btctl" for more details</comment>
323 brctl_br0=( "setfd 0" "sethello 0" "stp off" )
324
325 <comment># To add ports to bridge br0</comment>
326 bridge_br0="eth0 eth1"
327
328 <comment># You need to configure the ports to null values so dhcp does not get started</comment>
329 config_eth0=( "null" )
330 config_eth1=( "null" )
331
332 <comment># Finally give the bridge an address - you could use DHCP as well</comment>
333 config_br0=( "192.168.0.1/24" )
334
335 <comment># Depend on eth0 and eth1 as they may require extra configuration</comment>
336 depend_br0() {
337 need net.eth0 net.eth1
338 }
339 </pre>
340
341 <impo>
342 For using some bridge setups, you may need to consult the
343 <uri link="?part=3&amp;chap=2#variable_name">variable name</uri>
344 documentation.
345 </impo>
346
347 </body>
348 </section>
349
350 <section>
351 <title>MAC Address</title>
352 <body>
353
354 <p>
355 You don't need to emerge anything for changing the MAC address of your
356 interface if you change to a specific address. However, if you need to
357 change to a random address or a random address of a given type then you
358 need to emerge net-analyzer/macchanger.
359 </p>
360
361 <pre caption="MAC Address change example">
362 <comment># To set the MAC address of the interface</comment>
363 mac_eth0="00:11:22:33:44:55"
364
365 <comment># To randomize the last 3 bytes only</comment>
366 mac_eth0="random-ending"
367
368 <comment># To randomize between the same physical type of connection (eg fibre,
369 # copper, wireless) , all vendors</comment>
370 mac_eth0="random-samekind"
371
372 <comment># To randomize between any physical type of connection (eg fibre, copper,
373 # wireless) , all vendors</comment>
374 mac_eth0="random-anykind"
375
376 <comment># Full randomization - WARNING: some MAC addresses generated by this may
377 # NOT act as expected</comment>
378 mac_eth0="random-full"
379 </pre>
380
381 </body>
382 </section>
383
384 <section>
385 <title>Tunnelling</title>
386 <body>
387
388 <p>
389 You don't need to emerge anything for tunnelling as the interface handler
390 can do it for you.
391 </p>
392
393 <pre caption="Tunnelling configuration in /etc/conf.d/net">
394 <comment># For GRE tunnels</comment>
395 iptunnel_vpn0="mode gre remote 207.170.82.1 key 0xffffffff ttl 255"
396
397 <comment># For IPIP tunnels</comment>
398 iptunnel_vpn0="mode ipip remote 207.170.82.2 ttl 255"
399
400 <comment># To configure the interface</comment>
401 config_vpn0=( "192.168.0.2 peer 192.168.1.1" )
402 </pre>
403
404 </body>
405 </section>
406
407 <section>
408 <title>VLAN (802.1q support)</title>
409 <body>
410
411 <p>
412 For VLAN support, emerge net-misc/vconfig
413 </p>
414
415 <p>Virtual LAN is a group of network devices that behave as if they were
416 connected to a single network segment - even though they may not be.
417 VLAN members can only see members of the same VLAN even though they may
418 share the same physical network.
419 </p>
420
421 <pre caption="VLAN configuration in /etc/conf.d/net">
422 <comment># Specify the VLAN numbers for the interface like so</comment>
423 <comment># Please ensure your VLAN IDs are NOT zero-padded</comment>
424 vlans_eth0="1 2"
425
426 <comment># You can also configure the VLAN</comment>
427 <comment># see for vconfig man page for more details</comment>
428 vconfig_eth0=( "set_name_type VLAN_PLUS_VID_NO_PAD" )
429 vconfig_vlan1=( "set_flag 1" "set_egress_map 2 6" )
430
431 <comment># Configure the interface as usual</comment>
432 config_vlan1=( "172.16.3.1 netmask 255.255.254.0" )
433 config_vlan2=( "172.16.2.1 netmask 255.255.254.0" )
434 </pre>
435
436 <impo>
437 For using some VLAN setups, you may need to consult the
438 <uri link="?part=3&amp;chap=2#variable_name">variable name</uri>
439 documentation.
440 </impo>
441
442 </body>
443 </section>
444
445 </sections>

  ViewVC Help
Powered by ViewVC 1.1.20