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

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

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

Revision 1.25 Revision 1.26
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-modules.xml,v 1.25 2009/02/13 04:40:27 nightmorph Exp $ --> 7<!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/handbook/hb-net-modules.xml,v 1.26 2011/08/14 16:12:13 swift Exp $ -->
8 8
9<sections> 9<sections>
10 10
11<abstract> 11<abstract>
12Gentoo provides you flexible networking - here you are told about choosing 12Gentoo provides you flexible networking - here you are told about choosing
13different DHCP clients, setting up bonding, bridging, VLANs and more. 13different DHCP clients, setting up bonding, bridging, VLANs and more.
14</abstract> 14</abstract>
15 15
16<version>8.4</version> 16<version>9</version>
17<date>2009-02-12</date> 17<date>2011-08-13</date>
18 18
19<section> 19<section>
20<title>Network Modules</title> 20<title>Network Modules</title>
21<body> 21<body>
22 22
39otherwise specified. 39otherwise specified.
40</note> 40</note>
41 41
42<pre caption="Module preference"> 42<pre caption="Module preference">
43<comment># Prefer iproute2 over ifconfig</comment> 43<comment># Prefer iproute2 over ifconfig</comment>
44modules=( "iproute2" ) 44modules="iproute2"
45 45
46<comment># You can also specify other modules for an interface 46<comment># You can also specify other modules for an interface
47# In this case we prefer pump over dhcpcd</comment> 47# In this case we prefer pump over dhcpcd</comment>
48modules_eth0=( "pump" ) 48modules_eth0="pump"
49 49
50<comment># You can also specify which modules not to use - for example you may be 50<comment># You can also specify which modules not to use - for example you may be
51# using a supplicant or linux-wlan-ng to control wireless configuration but 51# using a supplicant or linux-wlan-ng to control wireless configuration but
52# you still want to configure network settings per ESSID associated with.</comment> 52# you still want to configure network settings per ESSID associated with.</comment>
53modules=( "!iwconfig" ) 53modules="!iwconfig"
54</pre> 54</pre>
55 55
56</body> 56</body>
57</section> 57</section>
58<section> 58<section>
72 72
73<pre caption="To install iproute2"> 73<pre caption="To install iproute2">
74# <i>emerge sys-apps/iproute2</i> 74# <i>emerge sys-apps/iproute2</i>
75 75
76<comment># To prefer iproute2 over ifconfig if both are installed</comment> 76<comment># To prefer iproute2 over ifconfig if both are installed</comment>
77modules=( "iproute2" ) 77modules="iproute2"
78</pre> 78</pre>
79 79
80<p> 80<p>
81As both <c>ifconfig</c> and <c>iproute2</c> do very similar things we allow 81As both <c>ifconfig</c> and <c>iproute2</c> do very similar things we allow
82their basic configuration to work with each other. For example both the below 82their basic configuration to work with each other. For example both the below
83code snippet work regardless of which module you are using. 83code snippet work regardless of which module you are using.
84</p> 84</p>
85 85
86<pre caption="ifconfig and iproute2 examples"> 86<pre caption="ifconfig and iproute2 examples">
87config_eth0=( "192.168.0.2/24" ) 87config_eth0="192.168.0.2/24"
88config_eth0=( "192.168.0.2 netmask 255.255.255.0" ) 88config_eth0="192.168.0.2 netmask 255.255.255.0"
89 89
90<comment># We can also specify broadcast</comment> 90<comment># We can also specify broadcast</comment>
91config_eth0=( "192.168.0.2/24 brd 192.168.0.255" ) 91config_eth0="192.168.0.2/24 brd 192.168.0.255"
92config_eth0=( "192.168.0.2 netmask 255.255.255.0 broadcast 192.168.0.255" ) 92config_eth0="192.168.0.2 netmask 255.255.255.0 broadcast 192.168.0.255"
93</pre> 93</pre>
94 94
95</body> 95</body>
96</section> 96</section>
97<section id="dhcp"> 97<section id="dhcp">
176 <li><c>nonis</c> - don't overwrite <path>/etc/yp.conf</path></li> 176 <li><c>nonis</c> - don't overwrite <path>/etc/yp.conf</path></li>
177</ul> 177</ul>
178 178
179<pre caption="Sample DHCP configuration in /etc/conf.d/net"> 179<pre caption="Sample DHCP configuration in /etc/conf.d/net">
180<comment># Only needed if you have more than one DHCP module installed</comment> 180<comment># Only needed if you have more than one DHCP module installed</comment>
181modules=( "dhcpcd" ) 181modules="dhcpcd"
182 182
183config_eth0=( "dhcp" ) 183config_eth0="dhcp"
184dhcpcd_eth0="-t 10" <comment># Timeout after 10 seconds</comment> 184dhcpcd_eth0="-t 10" <comment># Timeout after 10 seconds</comment>
185dhcp_eth0="release nodns nontp nonis" <comment># Only get an address</comment> 185dhcp_eth0="release nodns nontp nonis" <comment># Only get an address</comment>
186</pre> 186</pre>
187 187
188<note> 188<note>
202 202
203<pre caption="Install the ppp package"> 203<pre caption="Install the ppp package">
204# <i>emerge net-dialup/ppp</i> 204# <i>emerge net-dialup/ppp</i>
205</pre> 205</pre>
206 206
207<note>
208If you need PPPoA, then make sure to use >=<c>baselayout-1.12.x</c>.
209</note>
210
211<p> 207<p>
212Second, create the PPP net script and the net script for the ethernet interface 208Second, create the PPP net script and the net script for the ethernet interface
213to be used by PPP: 209to be used by PPP:
214</p> 210</p>
215 211
217# <i>ln -s /etc/init.d/net.lo /etc/init.d/net.ppp0</i> 213# <i>ln -s /etc/init.d/net.lo /etc/init.d/net.ppp0</i>
218# <i>ln -s /etc/init.d/net.lo /etc/init.d/net.eth0</i> 214# <i>ln -s /etc/init.d/net.lo /etc/init.d/net.eth0</i>
219</pre> 215</pre>
220 216
221<p> 217<p>
222Be sure to set RC_NET_STRICT_CHECKING="yes" in <path>/etc/conf.d/rc</path>. 218Be sure to set <c>rc_depend_strict</c> to "YES" in <path>/etc/rc.conf</path>.
223</p> 219</p>
224 220
225<p> 221<p>
226Now we need to configure <path>/etc/conf.d/net</path>. 222Now we need to configure <path>/etc/conf.d/net</path>.
227</p> 223</p>
228 224
229<pre caption="A basic PPPoE setup"> 225<pre caption="A basic PPPoE setup">
230config_eth0=( null ) <comment>(Specify your ethernet interface)</comment> 226config_eth0=null <comment>(Specify your ethernet interface)</comment>
231config_ppp0=( "ppp" ) 227config_ppp0="ppp"
232link_ppp0="eth0" <comment>(Specify your ethernet interface)</comment> 228link_ppp0="eth0" <comment>(Specify your ethernet interface)</comment>
233plugins_ppp0=( "pppoe" ) 229plugins_ppp0="pppoe"
234username_ppp0='user' 230username_ppp0='user'
235password_ppp0='password' 231password_ppp0='password'
236pppd_ppp0=( 232pppd_ppp0="
237 "noauth" 233noauth
238 "defaultroute" 234defaultroute
239 "usepeerdns" 235usepeerdns
240 "holdoff 3" 236holdoff 3
241 "child-timeout 60" 237child-timeout 60
242 "lcp-echo-interval 15" 238lcp-echo-interval 15
243 "lcp-echo-failure 3" 239lcp-echo-failure 3
244 noaccomp noccp nobsdcomp nodeflate nopcomp novj novjccomp 240noaccomp noccp nobsdcomp nodeflate nopcomp novj novjccomp"
245)
246 241
247depend_ppp0() { 242rc_need_ppp0="net.eth0"
248 need net.eth0
249}
250</pre> 243</pre>
251 244
252<p> 245<p>
253You can also set your password in <path>/etc/ppp/pap-secrets</path>. 246You can also set your password in <path>/etc/ppp/pap-secrets</path>.
254</p> 247</p>
264information on how to properly configure it. 257information on how to properly configure it.
265</p> 258</p>
266 259
267<impo> 260<impo>
268Please carefully read the section on ADSL and PPP in 261Please carefully read the section on ADSL and PPP in
269<path>/etc/conf.d/net.example</path>. It contains many more detailed 262<path>/usr/share/doc/openrc-0.8.3-r1/net.example.bz2</path>. It contains many
270explanations of all the settings your particular PPP setup will likely need. 263more detailed explanations of all the settings your particular PPP setup will
264likely need. Of course, change <c>0.8.3-r1</c> with the version of OpenRC
265installed on your system.
271</impo> 266</impo>
272 267
273</body> 268</body>
274</section> 269</section>
275<section id="apipa"> 270<section id="apipa">
291For APIPA support, emerge <c>net-misc/iputils</c> or <c>net-analyzer/arping</c>. 286For APIPA support, emerge <c>net-misc/iputils</c> or <c>net-analyzer/arping</c>.
292</p> 287</p>
293 288
294<pre caption="APIPA configuration in /etc/conf.d/net"> 289<pre caption="APIPA configuration in /etc/conf.d/net">
295<comment># Try DHCP first - if that fails then fallback to APIPA</comment> 290<comment># Try DHCP first - if that fails then fallback to APIPA</comment>
296config_eth0=( "dhcp" ) 291config_eth0="dhcp"
297fallback_eth0=( "apipa" ) 292fallback_eth0="apipa"
298 293
299<comment># Just use APIPA</comment> 294<comment># Just use APIPA</comment>
300config_eth0=( "apipa" ) 295config_eth0="apipa"
301</pre> 296</pre>
302 297
303</body> 298</body>
304</section> 299</section>
305<section> 300<section>
319<pre caption="bonding configuration in /etc/conf.d/net"> 314<pre caption="bonding configuration in /etc/conf.d/net">
320<comment># To bond interfaces together</comment> 315<comment># To bond interfaces together</comment>
321slaves_bond0="eth0 eth1 eth2" 316slaves_bond0="eth0 eth1 eth2"
322 317
323<comment># You may not want to assign an IP to the bonded interface</comment> 318<comment># You may not want to assign an IP to the bonded interface</comment>
324config_bond0=( "null" ) 319config_bond0="null"
325 320
326<comment># Depend on eth0, eth1 and eth2 as they may require extra configuration</comment> 321<comment># Depend on eth0, eth1 and eth2 as they may require extra configuration</comment>
327depend_bond0() {
328 need net.eth0 net.eth1 net.eth2 322rc_need_bond0="net.eth0 net.eth1 net.eth2"
329}
330</pre> 323</pre>
331 324
332</body> 325</body>
333</section> 326</section>
334<section> 327<section>
346create a bridge to join the two interfaces together. 339create a bridge to join the two interfaces together.
347</p> 340</p>
348 341
349<pre caption="Bridge configuration in /etc/conf.d/net"> 342<pre caption="Bridge configuration in /etc/conf.d/net">
350<comment># Configure the bridge - "man brctl" for more details</comment> 343<comment># Configure the bridge - "man brctl" for more details</comment>
351brctl_br0=( "setfd 0" "sethello 0" "stp off" ) 344brctl_br0="setfd 0" "sethello 0" "stp off"
352 345
353<comment># To add ports to bridge br0</comment> 346<comment># To add ports to bridge br0</comment>
354bridge_br0="eth0 eth1" 347bridge_br0="eth0 eth1"
355 348
356<comment># You need to configure the ports to null values so dhcp does not get started</comment> 349<comment># You need to configure the ports to null values so dhcp does not get started</comment>
357config_eth0=( "null" ) 350config_eth0="null"
358config_eth1=( "null" ) 351config_eth1="null"
359 352
360<comment># Finally give the bridge an address - you could use DHCP as well</comment> 353<comment># Finally give the bridge an address - you could use DHCP as well</comment>
361config_br0=( "192.168.0.1/24" ) 354config_br0="192.168.0.1/24"
362 355
363<comment># Depend on eth0 and eth1 as they may require extra configuration</comment> 356<comment># Depend on eth0 and eth1 as they may require extra configuration</comment>
364depend_br0() {
365 need net.eth0 net.eth1 357rc_need_br0="net.eth0 net.eth1"
366}
367</pre> 358</pre>
368 359
369<impo> 360<impo>
370For using some bridge setups, you may need to consult the <uri 361For using some bridge setups, you may need to consult the <uri
371link="?part=4&amp;chap=2#variable_name">variable name</uri> documentation. 362link="?part=4&amp;chap=2#variable_name">variable name</uri> documentation.
376<section> 367<section>
377<title>MAC Address</title> 368<title>MAC Address</title>
378<body> 369<body>
379 370
380<p> 371<p>
381You don't need to emerge anything for changing the MAC address of your 372If you need to, you can change the MAC address of your interfaces through
382interface if you have <c>sys-apps/baselayout-1.11.14</c> or newer and want to 373the network configuration file too.
383change to a specific MAC address. However, if you need to change to a random MAC
384address or have a baselayout older than the version mentioned above, you have
385to emerge <c>net-analyzer/macchanger</c> to be able to make use of this feature.
386</p> 374</p>
387 375
388<pre caption="MAC Address change example"> 376<pre caption="MAC Address change example">
389<comment># To set the MAC address of the interface</comment> 377<comment># To set the MAC address of the interface</comment>
390mac_eth0="00:11:22:33:44:55" 378mac_eth0="00:11:22:33:44:55"
422 410
423<comment># For IPIP tunnels</comment> 411<comment># For IPIP tunnels</comment>
424iptunnel_vpn0="mode ipip remote 207.170.82.2 ttl 255" 412iptunnel_vpn0="mode ipip remote 207.170.82.2 ttl 255"
425 413
426<comment># To configure the interface</comment> 414<comment># To configure the interface</comment>
427config_vpn0=( "192.168.0.2 peer 192.168.1.1" ) 415config_vpn0="192.168.0.2 peer 192.168.1.1"
428</pre> 416</pre>
429 417
430</body> 418</body>
431</section> 419</section>
432<section> 420<section>
449<comment># Please ensure your VLAN IDs are NOT zero-padded</comment> 437<comment># Please ensure your VLAN IDs are NOT zero-padded</comment>
450vlans_eth0="1 2" 438vlans_eth0="1 2"
451 439
452<comment># You can also configure the VLAN</comment> 440<comment># You can also configure the VLAN</comment>
453<comment># see for vconfig man page for more details</comment> 441<comment># see for vconfig man page for more details</comment>
454vconfig_eth0=( "set_name_type VLAN_PLUS_VID_NO_PAD" ) 442vconfig_eth0="set_name_type VLAN_PLUS_VID_NO_PAD"
455vconfig_vlan1=( "set_flag 1" "set_egress_map 2 6" ) 443vconfig_vlan1="set_flag 1" "set_egress_map 2 6"
456 444
457<comment># Configure the interface as usual</comment> 445<comment># Configure the interface as usual</comment>
458config_vlan1=( "172.16.3.1 netmask 255.255.254.0" ) 446config_vlan1="172.16.3.1 netmask 255.255.254.0"
459config_vlan2=( "172.16.2.1 netmask 255.255.254.0" ) 447config_vlan2="172.16.2.1 netmask 255.255.254.0"
460</pre> 448</pre>
461 449
462<impo> 450<impo>
463For using some VLAN setups, you may need to consult the <uri 451For using some VLAN setups, you may need to consult the <uri
464link="?part=4&amp;chap=2#variable_name">variable name</uri> documentation. 452link="?part=4&amp;chap=2#variable_name">variable name</uri> documentation.

Legend:
Removed from v.1.25  
changed lines
  Added in v.1.26

  ViewVC Help
Powered by ViewVC 1.1.20