/[gentoo]/xml/htdocs/doc/en/home-router-howto.xml
Gentoo

Contents of /xml/htdocs/doc/en/home-router-howto.xml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.67 - (hide annotations) (download) (as text)
Mon Dec 9 12:19:35 2013 UTC (4 months ago) by swift
Branch: MAIN
CVS Tags: HEAD
Changes since 1.66: +2 -2 lines
File MIME type: application/xml
Moved to https://wiki.gentoo.org/wiki/Home_Router

1 vapier 1.1 <?xml version='1.0' encoding='UTF-8'?>
2     <!DOCTYPE guide SYSTEM "/dtd/guide.dtd">
3 swift 1.67 <!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/home-router-howto.xml,v 1.66 2013/04/03 18:32:25 vapier Exp $ -->
4 vapier 1.1
5 swift 1.67 <guide disclaimer="obsolete" redirect="https://wiki.gentoo.org/wiki/Home_Router">
6 vapier 1.1 <title>Home Router Guide</title>
7    
8     <author title="Author">
9 swift 1.61 <mail link="vapier@gentoo.org">Mike Frysinger</mail>
10 vapier 1.1 </author>
11    
12     <abstract>
13 swift 1.60 This document details how to turn an old Gentoo machine into a router
14 vapier 1.1 for connecting your home network to the internet.
15     </abstract>
16    
17 vapier 1.36 <!-- The content of this document is released into the public domain -->
18     <license/>
19    
20 vapier 1.66 <version>3</version>
21     <date>2013-04-03</date>
22 vapier 1.1
23     <chapter>
24     <title>Introduction</title>
25     <section>
26     <body>
27    
28     <p>
29 neysx 1.23 Building your own router out of old spare parts has many advantages over buying
30 swift 1.61 a pre-made canned router by say Linksys. The biggest one by far is control
31     over the connection. The other advantages are left up to your imagination;
32 neysx 1.23 just about anything can be done in this scenario, it's just a matter of needing
33     it.
34 vapier 1.1 </p>
35    
36     <p>
37 neysx 1.23 This guide will show you how to setup Network Address Translation (NAT) on the
38     router (kernel and iptables), add and configure common services (Domain Name
39 nightmorph 1.59 System (DNS) via dnsmasq, dhcp via dhcpcd, ADSL via ppp), and conclude
40 neysx 1.23 with more elaborate and fun things that can be done (port forwarding, traffic
41     shaping, proxies/caching, etc...).
42 vapier 1.1 </p>
43    
44     <p>
45 swift 1.61 Before getting started, there's a few basic requirements you must meet. First,
46 neysx 1.23 you'll need a computer that has at least 2 Network Interface Cards (NICs) in
47 swift 1.61 it. Next, you'll need the configuration settings for your internet connection
48     (may include things like IP/DNS/Gateway/username/password). Finally, you'll
49 neysx 1.23 need a bit of spare time and some Gentoo loving.
50 vapier 1.1 </p>
51    
52     <p>
53     The conventions used in this guide are:
54     </p>
55 neysx 1.23
56 vapier 1.1 <ul>
57     <li>eth0 - NIC connected to the Local Area Network (LAN)</li>
58     <li>eth1 - NIC connected to the Wide Area Network (WAN)</li>
59     <li>LAN utilizes the private 192.168.0.xxx network</li>
60     <li>router is hardcoded to the standard 192.168.0.1 IP</li>
61 vapier 1.3 <li>router is running Linux 2.4 or 2.6; you're on your own with 2.0/2.2</li>
62 vapier 1.1 </ul>
63    
64     <impo>
65 neysx 1.23 Due to security precautions, I would highly suggest you shut down any unneeded
66     services on the router until we have a chance to get the firewall up and
67 swift 1.61 rolling. To view the currently running services, just run <c>rc-status</c>.
68 vapier 1.1 </impo>
69    
70     </body>
71     </section>
72     </chapter>
73    
74     <chapter>
75     <title>Kernel setup (know thyself first)</title>
76     <section>
77     <body>
78    
79     <p>
80 swift 1.61 Your kernel needs to have the drivers running for both your NICs. To see if
81     your cards are already setup, just run <c>ifconfig</c>. Your output may differ
82     slightly from the following, that's fine. What matters is that the interface
83 neysx 1.23 shows up at all.
84 vapier 1.1 </p>
85 neysx 1.23
86 vapier 1.1 <pre caption="Checking NICs">
87     # <i>ifconfig -a</i>
88 swift 1.61 eth0 Link encap:Ethernet HWaddr 00:60:F5:07:07:B8
89     BROADCAST MULTICAST MTU:1500 Metric:1
90     RX packets:0 errors:0 dropped:0 overruns:0 frame:0
91     TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
92     collisions:0 txqueuelen:1000
93     RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
94     Interrupt:11 Base address:0x9800
95    
96     eth1 Link encap:Ethernet HWaddr 00:60:F5:07:07:B9
97     BROADCAST MULTICAST MTU:1500 Metric:1
98     RX packets:0 errors:0 dropped:0 overruns:0 frame:0
99     TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
100     collisions:0 txqueuelen:1000
101     RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
102     Interrupt:10 Base address:0x9400
103 vapier 1.1 </pre>
104 neysx 1.23
105 vapier 1.1 <p>
106 neysx 1.23 If you do not see your two cards showing up and you're not sure what kind of
107 swift 1.61 cards you have, try running <c>lspci | grep Ethernet</c>. You can get that
108     from <c>emerge pciutils</c>. Once you have this information, go into your
109 vapier 1.49 kernel and add support for the correct drivers.
110 vapier 1.1 </p>
111    
112     <p>
113 neysx 1.23 The next thing you'll need is support for iptables and NAT (and packet shaping
114 swift 1.61 if you want). The following list is split up into always required (*),
115 swift 1.60 required only for adsl via PPPoE (a), suggested for everyone (x), and only
116 swift 1.61 for shaper (s) features. It does not matter whether you build the features
117 swift 1.60 into the kernel or as a module so long as when the feature is needed, the
118     correct module(s) are loaded (module loading is left to the reader as a fun
119 neysx 1.23 exercise however).
120 vapier 1.1 </p>
121 neysx 1.23
122 vapier 1.1 <pre caption="Network Options">
123 swift 1.61 Networking options ---&gt;
124     [*] TCP/IP networking
125     [*] IP: advanced router
126     [*] Network packet filtering (replaces ipchains)
127 vapier 1.20 <comment>If you use 2.4.x, you have to enable the following for DHCP:</comment>
128 swift 1.61 [*] Socket Filtering
129 vapier 1.1
130 swift 1.61 IP: Netfilter Configuration ---&gt;
131     [*] Connection tracking (required for masq/NAT)
132     [x] FTP protocol support
133     [x] IRC protocol support
134     [*] IP tables support (required for filtering/masq/NAT)
135     [*] IP range match support
136     [x] MAC address match support
137     [*] Multiple port match support
138     [*] Packet filtering
139     [*] REJECT target support
140     [x] REDIRECT target support
141     [*] Full NAT
142     [*] MASQUERADE target support
143     [s] Packet mangling
144     [s] MARK target support
145     [x] LOG target support
146    
147     QoS and/or fair queueing ---&gt;
148     [s] QoS and/or fair queueing
149     [s] HTB packet scheduler
150     [s] Ingress Qdisc
151    
152     [a] PPP (point-to-point protocol) support
153     [a] PPP filtering
154     [a] PPP support for async serial ports
155     [a] PPP support for sync tty ports
156     [a] PPP Deflate compression
157     [a] PPP BSD-Compress compression
158     [a] PPP over Ethernet
159 vapier 1.1 </pre>
160 neysx 1.23
161 vapier 1.1 <note>
162 vapier 1.51 Some things may be slightly different in a 2.4 vs 2.6 kernel, but you should be
163 swift 1.61 able to figure it out :). Even among 2.6 kernels, these options have a
164     tendency to move around. Good luck!
165 vapier 1.1 </note>
166    
167     </body>
168     </section>
169     </chapter>
170    
171     <chapter>
172     <title>Hug the WAN (a.k.a. The Internet)</title>
173    
174     <section>
175     <title>Intro</title>
176     <body>
177 neysx 1.23
178 vapier 1.1 <p>
179 neysx 1.23 There are many ways to connect to the internet so I'll just cover the ones I'm
180 swift 1.61 familiar with. That leaves us with ADSL (PPPoE) and cable modems
181     (static/dynamic). If there are other methods out there, feel free to write up
182     a little blurb and e-mail me. Feel free to skip any of the following sections
183     in this chapter that don't apply to you. This chapter is just about getting
184 neysx 1.23 the router connected to the internet via eth1.
185 vapier 1.1 </p>
186 neysx 1.23
187 vapier 1.1 </body>
188     </section>
189     <section>
190     <title>ADSL and PPPoE</title>
191     <body>
192    
193     <p>
194 swift 1.60 All the fancy PPPoE software that used to be provided by rp-pppoe
195     (<uri link="http://www.roaringpenguin.com/">Roaring Penguin</uri>) has been
196     integrated into the <uri link="http://samba.org/ppp/">standard PPP
197 swift 1.61 package</uri>. Simply <c>emerge ppp</c> and you'll be on your way. Remember
198     how I said you'll need username/password information? Well I wasn't lying so
199     I hope you have it now! Load up <path>/etc/conf.d/net</path> in your favorite
200 vapier 1.58 editor and set it up.
201 vapier 1.1 </p>
202    
203     <pre caption="Setting up eth1">
204 vapier 1.58 <comment>(Replace 'vla9h924' with your username and 'boogie' with your password)</comment>
205 vapier 1.1
206     # <i>nano /etc/conf.d/net</i>
207 vapier 1.66 <comment>Tell openrc to use adsl over eth1 for ppp0:</comment>
208     config_ppp0="ppp"
209 vapier 1.58 link_ppp0="eth1"
210 vapier 1.66 plugins_ppp0="pppoe"
211     pppd_ppp0="
212     defaultroute
213     usepeerdns
214 swift 1.65 <comment>There may be other settings you want, see /usr/share/doc/openrc-*/net.example.bz2</comment>
215 vapier 1.66 "
216 vapier 1.58 username_ppp0="vla9h924"
217     password_ppp0="boogie"
218    
219     # <i>ln -s net.lo /etc/init.d/net.ppp0</i>
220     # <i>rc-update add net.ppp0 default</i>
221     # <i>/etc/init.d/net.ppp0 start</i>
222 vapier 1.1 </pre>
223    
224 vapier 1.3 <warn>
225 swift 1.61 When the DSL interface comes up, it will create ppp0. Although your NIC is
226     called eth1, the IP is actually bound to ppp0. From now on, when you see
227 vapier 1.39 examples that utilize 'eth1', substitute with 'ppp0'.
228 vapier 1.3 </warn>
229 vapier 1.1
230 vapier 1.58 <warn>
231 swift 1.60 Make sure you change the permissions of the /etc/conf.d/net file so that only
232 vapier 1.58 root can read/write it since you're sticking your username/password in it.
233     </warn>
234    
235     <warn>
236 swift 1.60 For people transitioning from the <c>rp-pppoe</c> package, or for people who
237     hit weird connection resets, see the MTU section in the Troubleshooting
238 vapier 1.58 chapter.
239     </warn>
240    
241 vapier 1.1 </body>
242     </section>
243    
244     <section>
245     <title>Cable and/or dynamic/static IP</title>
246     <body>
247    
248     <p>
249 swift 1.60 If you have a static IP then you will need a few more details than if
250 swift 1.61 you have a dynamic IP. For static users, you will need your IP,
251 vapier 1.1 gateway, and DNS servers.
252     </p>
253    
254     <pre caption="Setting up eth1">
255     <comment>Dynamic IP Users:</comment>
256     # <i>emerge dhcpcd</i>
257     # <i>nano /etc/conf.d/net</i>
258 neysx 1.23 <comment>You'll need an entry like so:</comment>
259 vapier 1.66 config_eth1="dhcp"
260 vapier 1.1
261     <comment>Static IP Users:</comment>
262     # <i>nano /etc/conf.d/net</i>
263 neysx 1.23 <comment>You'll need entries like so:</comment>
264 vapier 1.66 config_eth1="66.92.78.102/24 brd 66.92.78.255"
265     routes_eth1="default via 66.92.78.1"
266 vapier 1.1 # <i>nano /etc/resolv.conf</i>
267 neysx 1.23 <comment>Add one line per DNS server:</comment>
268     nameserver 123.123.123.123
269 vapier 1.1
270     <comment>Dynamic and Static Setup:</comment>
271 vapier 1.30 # <i>ln -s net.lo /etc/init.d/net.eth1</i>
272 vapier 1.1 # <i>rc-update add net.eth1 default</i>
273     # <i>/etc/init.d/net.eth1 start</i>
274     </pre>
275    
276     <p>
277     You should be all set to go now.
278     </p>
279    
280     </body>
281     </section>
282     </chapter>
283    
284     <chapter>
285     <title>Hug the LAN (bring along some friends)</title>
286     <section>
287     <body>
288    
289     <p>
290     This step is a breeze compared to the previous one.
291     </p>
292    
293     <pre caption="Setting up eth0">
294     # <i>nano /etc/conf.d/net</i>
295 neysx 1.23 <comment>Add a line like the following:</comment>
296 vapier 1.66 config_eth0="192.168.0.1/24 brd 192.168.0.255"
297 vapier 1.1 # <i>rc-update add net.eth0 default</i>
298     # <i>/etc/init.d/net.eth0 start</i>
299     </pre>
300    
301     </body>
302     </section>
303     </chapter>
304    
305     <chapter>
306     <title>LAN Services (because we're nice people)</title>
307    
308     <section>
309     <title>DHCP Server</title>
310     <body>
311 neysx 1.23
312 vapier 1.1 <p>
313 neysx 1.23 I bet it'd be nice if everyone else in your house could just plug their
314 swift 1.61 computers into the network and things would just work. No need to remember
315 neysx 1.23 mind-numbing details or make them stare at confusing configuration screens!
316 swift 1.61 Life would be grand eh? Introducing the Dynamic Host Configuration Protocol
317 neysx 1.23 (DHCP) and why you should care.
318 vapier 1.1 </p>
319    
320 vapier 1.2 <p>
321 swift 1.61 DHCP is exactly what its name implies. It's a protocol that allows you
322     to dynamically configure other hosts automatically. You run a DHCP server on
323 vapier 1.33 the router, give it all the information about your network (valid IPs,
324 neysx 1.23 DNS servers, gateways, etc...), and then when the other hosts start up, they
325 swift 1.61 run a DHCP client to automatically configure themselves. No fuss, no muss!
326 neysx 1.23 For more information about DHCP, you can always visit <uri
327     link="http://en.wikipedia.org/wiki/DHCP">Wikipedia</uri>.
328 vapier 1.2 </p>
329    
330 vapier 1.33 <p>
331     We'll use a package called dnsmasq which provides both DHCP and DNS services.
332 swift 1.61 For now lets just focus on the DHCP aspect. Note that if you want to run a
333 vapier 1.33 different DHCP server, you can find another example in the Fun Things chapter.
334 swift 1.60 Also, if you wish to tinker with the DHCP server settings, just read the
335 swift 1.61 comments in <path>/etc/dnsmasq.conf</path>. All the defaults should work fine
336 vapier 1.33 though.
337     </p>
338    
339     <pre caption="Setting up a DHCP server">
340     # <i>emerge dnsmasq</i>
341     # <i>nano /etc/dnsmasq.conf</i>
342 vapier 1.43 <comment>Add this line to enable dhcp:</comment>
343 vapier 1.33 dhcp-range=192.168.0.100,192.168.0.250,72h
344 vapier 1.43 <comment>Restrict dnsmasq to just the LAN interface</comment>
345     interface=eth0
346 vapier 1.33
347     # <i>rc-update add dnsmasq default</i>
348     # <i>/etc/init.d/dnsmasq start</i>
349 vapier 1.1 </pre>
350    
351     <p>
352 swift 1.61 Now your little router is a bona-fide DHCP server! Plugin those computers and
353     watch them work! With Windows systems you should go into the TCP/IP Properties
354 neysx 1.23 and select the 'Obtain an IP address automatically' and 'Obtain DNS server
355 swift 1.61 address automatically' options. Sometimes the changes aren't instantaneous, so
356 vapier 1.31 you may have to open a command prompt and run <c>ipconfig /release</c> and
357 swift 1.61 <c>ipconfig /renew</c>. But enough about Windows, let's get back to our
358 neysx 1.23 favorite penguin.
359 vapier 1.1 </p>
360 neysx 1.23
361 vapier 1.1 </body>
362     </section>
363    
364     <section>
365     <title>DNS Server</title>
366     <body>
367 neysx 1.23
368 vapier 1.2 <p>
369 neysx 1.23 When people want to visit a place on the internet, they remember names, not a
370 swift 1.61 string of funky numbers. After all, what's easier to remember, ebay.com or
371     66.135.192.87? This is where the DNS steps in. DNS servers run all over the
372 neysx 1.23 internet, and whenever someone wants to visit 'ebay.com', these servers turn
373     'ebay.com' (what we understand) into '66.135.192.87' (what our computers
374 swift 1.61 understand). For more information about DNS, you can always visit <uri
375 neysx 1.23 link="http://en.wikipedia.org/wiki/DNS">Wikipedia</uri>.
376 vapier 1.2 </p>
377 vapier 1.1
378     <p>
379 vapier 1.33 Since we're using dnsmasq for our DHCP server, and it includes a DNS server,
380 swift 1.61 you've got nothing left to do here! Your little router is already providing
381     DNS to its DHCP clients. Bet you wish everything was this easy ;).
382 vapier 1.1 </p>
383    
384     <p>
385 swift 1.60 You're welcome to choose other DNS servers if you're more comfortable with
386     them, but the reason dnsmasq is great is because it was designed to do exactly
387 swift 1.61 what we want and nothing more. It's a little DNS caching/forwarding server for
388     local networks. We're not looking to provide DNS for our own domain here, just
389 vapier 1.33 offer simple DNS services to everyone else on our LAN.
390 vapier 1.1 </p>
391    
392     </body>
393     </section>
394    
395     <section>
396 vapier 1.4 <title>NAT (a.k.a. IP-masquerading)</title>
397 vapier 1.1 <body>
398    
399     <p>
400 neysx 1.23 At this point, people on your network can talk to each other and they can look
401     up hostnames via DNS, but they still can't actually connect to the internet.
402     While you may think that's great (more bandwidth for you!), I bet they're not
403     too happy just yet.
404 vapier 1.1 </p>
405    
406 vapier 1.2 <p>
407 swift 1.61 This is where Network Address Translation (NAT) steps in. NAT is a way of
408 swift 1.60 connecting multiple computers in a private LAN to the internet when you have a
409 swift 1.61 smaller number of public IP addresses available to you. Typically you are given
410 vapier 1.33 1 IP by your ISP, but you want to let your whole house connect to the internet.
411 swift 1.61 NAT is the magic that makes this possible. For more information about NAT, you
412 vapier 1.33 can always visit <uri link="http://en.wikipedia.org/wiki/NAT">Wikipedia</uri>.
413 vapier 1.2 </p>
414    
415     <note>
416 swift 1.61 Before we get started, make sure you have iptables on your system. Although it
417     is automatically installed on most systems, you may not have it. If you don't,
418 neysx 1.23 just run <c>emerge iptables</c>.
419 vapier 1.2 </note>
420    
421 vapier 1.1 <pre caption="Setting up iptables">
422     <comment>First we flush our current rules</comment>
423     # <i>iptables -F</i>
424     # <i>iptables -t nat -F</i>
425    
426 vapier 1.33 <comment>Setup default policies to handle unmatched traffic</comment>
427 vapier 1.32 # <i>iptables -P INPUT ACCEPT</i>
428     # <i>iptables -P OUTPUT ACCEPT</i>
429     # <i>iptables -P FORWARD DROP</i>
430    
431 vapier 1.30 <comment>Copy and paste these examples ...</comment>
432     # <i>export LAN=eth0</i>
433     # <i>export WAN=eth1</i>
434    
435 vapier 1.1 <comment>Then we lock our services so they only work from the LAN</comment>
436 vapier 1.30 # <i>iptables -I INPUT 1 -i ${LAN} -j ACCEPT</i>
437 vapier 1.1 # <i>iptables -I INPUT 1 -i lo -j ACCEPT</i>
438 nightmorph 1.63 # <i>iptables -A INPUT -p UDP --dport bootps ! -i ${LAN} -j REJECT</i>
439     # <i>iptables -A INPUT -p UDP --dport domain ! -i ${LAN} -j REJECT</i>
440 vapier 1.1
441 vapier 1.21 <comment>(Optional) Allow access to our ssh server from the WAN</comment>
442 vapier 1.30 # <i>iptables -A INPUT -p TCP --dport ssh -i ${WAN} -j ACCEPT</i>
443 vapier 1.21
444 vapier 1.1 <comment>Drop TCP / UDP packets to privileged ports</comment>
445 nightmorph 1.63 # <i>iptables -A INPUT -p TCP ! -i ${LAN} -d 0/0 --dport 0:1023 -j DROP</i>
446     # <i>iptables -A INPUT -p UDP ! -i ${LAN} -d 0/0 --dport 0:1023 -j DROP</i>
447 vapier 1.1
448     <comment>Finally we add the rules for NAT</comment>
449 vapier 1.30 # <i>iptables -I FORWARD -i ${LAN} -d 192.168.0.0/255.255.0.0 -j DROP</i>
450     # <i>iptables -A FORWARD -i ${LAN} -s 192.168.0.0/255.255.0.0 -j ACCEPT</i>
451     # <i>iptables -A FORWARD -i ${WAN} -d 192.168.0.0/255.255.0.0 -j ACCEPT</i>
452     # <i>iptables -t nat -A POSTROUTING -o ${WAN} -j MASQUERADE</i>
453 vapier 1.1 <comment>Tell the kernel that ip forwarding is OK</comment>
454     # <i>echo 1 > /proc/sys/net/ipv4/ip_forward</i>
455     # <i>for f in /proc/sys/net/ipv4/conf/*/rp_filter ; do echo 1 > $f ; done</i>
456    
457     <comment>This is so when we boot we don't have to run the rules by hand</comment>
458     # <i>/etc/init.d/iptables save</i>
459     # <i>rc-update add iptables default</i>
460 vapier 1.14 # <i>nano /etc/sysctl.conf</i>
461 vapier 1.50 <comment>Add/Uncomment the following lines:</comment>
462 vapier 1.14 net.ipv4.ip_forward = 1
463 vapier 1.50 net.ipv4.conf.default.rp_filter = 1
464    
465     <comment>If you have a dynamic internet address you probably want to enable this:</comment>
466     net.ipv4.ip_dynaddr = 1
467 vapier 1.1 </pre>
468    
469     <p>
470 neysx 1.23 Once you've typed out all of that, the rest of your network should now be able
471 swift 1.60 to use the internet as if they were directly connected themselves.
472 vapier 1.1 </p>
473    
474 vapier 1.50 <p>
475     The ip_dynaddr option is useful for dial on demand systems or when your ISP
476 swift 1.61 gives out dynamic addresses. This works around the problem where a connection
477     is attempted before the internet interface is fully setup. Really this just
478 vapier 1.50 provides for a smoother network experience for users behind your router.
479     </p>
480    
481 vapier 1.3 </body>
482     </section>
483     </chapter>
484    
485     <chapter>
486     <title>Fun Things (for a rainy day)</title>
487    
488     <section>
489     <title>Intro</title>
490     <body>
491 neysx 1.23
492 vapier 1.1 <p>
493 swift 1.61 Believe it or not, you're done :). From here on out, I'll cover a bunch of
494     common topics that may interest you. Everything in this chapter is completely
495 neysx 1.23 optional.
496 vapier 1.1 </p>
497 neysx 1.23
498 vapier 1.3 </body>
499     </section>
500 vapier 1.1
501 vapier 1.3 <section>
502     <title>Port Forwarding</title>
503     <body>
504 neysx 1.23
505 vapier 1.3 <p>
506 neysx 1.23 Sometimes you would like to be able to host services on a computer behind the
507 swift 1.61 router, or just to make your life easier when connecting remotely. Perhaps you
508 neysx 1.23 want to run a FTP, HTTP, SSH, or VNC server on one or more machines behind your
509 swift 1.61 router and be able to connect to them all. The only caveat is that you can
510     only have one service/machine combo per port. For example, there is no
511 neysx 1.23 practical way to setup three FTP servers behind your router and then try to
512     connect to them all through port 21; only one can be on port 21 while the
513     others would have to be on say port 123 and port 567.
514 vapier 1.3 </p>
515    
516     <p>
517 neysx 1.23 All the port forwarding rules are of the form <c>iptables -t nat -A PREROUTING
518 vapier 1.30 [-p protocol] --dport [external port on router] -i ${WAN} -j DNAT --to [ip/port
519 swift 1.61 to forward to]</c>. Unfortunately, iptables does not accept hostnames when port
520     forwarding. If you are forwarding an external port to the same port on the
521     internal machine, you can omit the destination port. See the iptables(8) man
522 vapier 1.33 page for more information.
523 vapier 1.3 </p>
524    
525 swift 1.28 <pre caption="Running the iptables commands">
526 vapier 1.30 <comment>Copy and paste these examples ...</comment>
527     # <i>export LAN=eth0</i>
528     # <i>export WAN=eth1</i>
529    
530 vapier 1.3 <comment>Forward port 2 to ssh on an internal host</comment>
531 vapier 1.30 # <i>iptables -t nat -A PREROUTING -p tcp --dport 2 -i ${WAN} -j DNAT --to 192.168.0.2:22</i>
532 vapier 1.3
533     <comment>FTP forwarding to an internal host</comment>
534 vapier 1.30 # <i>iptables -t nat -A PREROUTING -p tcp --dport 21 -i ${WAN} -j DNAT --to 192.168.0.56</i>
535 vapier 1.3
536     <comment>HTTP forwarding to an internal host</comment>
537 vapier 1.30 # <i>iptables -t nat -A PREROUTING -p tcp --dport 80 -i ${WAN} -j DNAT --to 192.168.0.56</i>
538 vapier 1.3
539     <comment>VNC forwarding for internal hosts</comment>
540 vapier 1.30 # <i>iptables -t nat -I PREROUTING -p tcp --dport 5900 -i ${WAN} -j DNAT --to 192.168.0.2</i>
541     # <i>iptables -t nat -I PREROUTING -p tcp --dport 5901 -i ${WAN} -j DNAT --to 192.168.0.3:5900</i>
542 vapier 1.3 <comment>If you want to VNC in to 192.168.0.3, then just add ':1' to the router's hostname</comment>
543    
544 vapier 1.55 <comment>SAMBA forwarding to an internal host (excess ports to cover Windows)</comment>
545     # <i>iptables -t nat -I PREROUTING -p tcp --dport 135 -i ${WAN} -j DNAT --to 192.168.0.2</i>
546     # <i>iptables -t nat -I PREROUTING -p tcp --dport 139 -i ${WAN} -j DNAT --to 192.168.0.2</i>
547     # <i>iptables -t nat -I PREROUTING -p tcp --dport 445 -i ${WAN} -j DNAT --to 192.168.0.2</i>
548     # <i>iptables -t nat -I PREROUTING -p udp --dport 137:138 -i ${WAN} -j DNAT --to 192.168.0.2</i>
549     # <i>iptables -t nat -I PREROUTING -p udp --dport 445 -i ${WAN} -j DNAT --to 192.168.0.2</i>
550    
551 vapier 1.3 <comment>Bittorrent forwarding</comment>
552 vapier 1.30 # <i>iptables -t nat -A PREROUTING -p tcp --dport 6881:6889 -i ${WAN} -j DNAT --to 192.168.0.2</i>
553 vapier 1.15
554 vapier 1.33 <comment>eDonkey/eMule forwarding</comment>
555     # <i>iptables -t nat -A PREROUTING -p tcp --dport 4662 -i ${WAN} -j DNAT --to 192.168.0.55</i>
556    
557 vapier 1.15 <comment>Game Cube Warp Pipe support</comment>
558 vapier 1.30 # <i>iptables -t nat -A PREROUTING -p udp --dport 4000 -i ${WAN} -j DNAT --to 192.168.0.56</i>
559 vapier 1.15
560 vapier 1.33 <comment>Playstation 2 Online support</comment>
561 vapier 1.30 # <i>iptables -t nat -A PREROUTING -p tcp --dport 10070:10080 -i ${WAN} -j DNAT --to 192.168.0.11</i>
562     # <i>iptables -t nat -A PREROUTING -p udp --dport 10070:10080 -i ${WAN} -j DNAT --to 192.168.0.11</i>
563 vapier 1.34
564     <comment>Xbox Live</comment>
565     # <i>iptables -t nat -A PREROUTING -p tcp --dport 3074 -i ${WAN} -j DNAT --to 192.168.0.69</i>
566     # <i>iptables -t nat -A PREROUTING -p udp --dport 3074 -i ${WAN} -j DNAT --to 192.168.0.69</i>
567     # <i>iptables -t nat -A PREROUTING -p udp --dport 88 -i ${WAN} -j DNAT --to 192.168.0.69</i>
568 vapier 1.3 </pre>
569    
570     <note>
571 neysx 1.37 If you have other common / cool examples, please <mail
572     link="vapier@gentoo.org">e-mail me</mail>.
573 vapier 1.3 </note>
574 neysx 1.23
575 vapier 1.3 </body>
576     </section>
577    
578     <section>
579     <title>Identd (for IRC)</title>
580     <body>
581 neysx 1.23
582 vapier 1.3 <p>
583 swift 1.61 Internet Relay Chat utilizes the ident service pretty heavily. Now that the
584 neysx 1.23 IRC clients are behind the router, we need a way to host ident for both the
585 swift 1.61 router and the clients. One such server has been created called
586 neysx 1.23 <c>midentd</c>.
587 vapier 1.3 </p>
588    
589     <pre caption="Setting up ident">
590     # <i>emerge midentd</i>
591     # <i>rc-update add midentd default</i>
592     # <i>/etc/init.d/midentd start</i>
593     </pre>
594    
595     <p>
596 swift 1.61 There are a few other ident servers in portage. Depending on your needs, I
597 neysx 1.23 would recommend checking out <c>oidentd</c> and <c>fakeidentd</c>.
598 vapier 1.3 </p>
599 neysx 1.23
600 vapier 1.3 </body>
601     </section>
602    
603 vapier 1.5 <!--
604     <section>
605     <title>Traffic Shaping</title>
606     <body>
607     <p>
608 swift 1.60 This is an attempt to simply and Gentooify the <uri link="http://www.tldp.org/HOWTO/ADSL-Bandwidth-Management-HOWTO/">ADSL Bandwidth Management HOWTO</uri>
609 swift 1.61 found over at the TLDP. Feel free to refer to the original document
610 vapier 1.5 for more details.
611     </p>
612    
613     <p>
614 swift 1.60 Here we will be setting up what some people refer to as a "Packet Shaper",
615     <uri link="http://en.wikipedia.org/wiki/Traffic_shaping">"Traffic Shaping"</uri>,
616     or <uri link="http://en.wikipedia.org/wiki/QoS">"Quality of Service"</uri>.
617     Simply put, we want to setup rules on our router that will slow down
618     certain activities (like sending large e-mails or downloading from P2P
619     networks) while keeping other activities (like browsing the web or playing
620 swift 1.61 online video games) reasonably fast. A 30 second difference in a video
621 swift 1.60 game is a lot worse than a 30 second difference in downloading large
622 vapier 1.5 files :).
623     </p>
624    
625     <p>
626 swift 1.60 The first thing is to make sure your kernel has all the features added to
627 swift 1.61 it. See the chapter on <uri link="#doc_chap2">Kernel setup</uri> for more
628     information. Next, you will need to <c>emerge iptables iputils</c> so that
629 swift 1.60 you will have access to the <c>iptables</c>, <c>ip</c>, and <c>tc</c>
630 vapier 1.5 commands.
631     </p>
632    
633     <p>
634 swift 1.61 Before we jump into the commands, let's cover a little of the theory. The
635 swift 1.60 way this whole system works is to classify common network streams and then
636 swift 1.61 to prioritize them. You use iptables to classify network streams, iputils
637 swift 1.60 to define the different priority levels, and the kernel to adjust speeds.
638     Just remember that although you can control outbound traffic pretty tightly
639     (from the LAN to the WAN), your ability to control inbound traffic (from
640 swift 1.61 the WAN to the LAN) is somewhat limited. Just remember that the following
641 swift 1.60 examples are to get your feet wet; if you want more then I'd suggest
642 swift 1.61 reading up on the subject. In this example, we will be using the
643 swift 1.60 <uri link="http://luxik.cdi.cz/~devik/qos/htb/">Hierarchical Token Buckets (HTB)</uri>
644 swift 1.61 packet scheduling algorithm. Still with me? Great, let's start shaping :).
645 vapier 1.5 </p>
646    
647     <pre caption="Setup">
648     DEV=eth1 <comment>NIC connected to WAN</comment>
649     RATE_OUT=100 <comment>Available outbound bandwidth (in kilobits [kb])</comment>
650     RATE_IN=1400 <comment>Available inbound bandwidth (in kb)</comment>
651    
652 swift 1.61 <comment>Here we initialize the priority system. The 45 is used to set the default classification level.</comment>
653 vapier 1.5 ip link set dev ${DEV} qlen 30
654     tc qdisc add dev ${DEV} root handle 1: htb default 45
655     tc class add dev ${DEV} parent 1: classid 1:1 htb rate ${RATE_OUT}kbit
656     </pre>
657    
658     <p>
659 swift 1.60 Here we initialized the system which will be used to prioritize all of
660 swift 1.61 our network traffic. We created our queue, told it to use the HTB
661     algorithm, and set the default classification level to '45'. The
662 swift 1.60 default is completely arbitrary, as are the levels we choose from
663 swift 1.61 here on out. The only thing that matters is how the levels compare
664 swift 1.60 relatively; a level '10' packet will be given preference over a
665 swift 1.61 level '45' packet. Let's move on to declaring different levels.
666 vapier 1.5 </p>
667    
668     <pre caption="Declaring levels">
669     tc class add dev $DEV parent 1:1 classid 1:10 htb rate $rkbit ceil $tkbit prio $p
670     tc qdisc add dev $DEV parent 1:10 handle 10: sfq
671     </pre>
672     </body>
673     </section>
674     -->
675    
676 vapier 1.3 <section>
677 vapier 1.9 <title>Time Server</title>
678     <body>
679 neysx 1.23
680 vapier 1.9 <p>
681 vapier 1.24 Keeping your system time correct is essential in maintaining a healthy system.
682 neysx 1.23 One of the most common ways of accomplishing this is with the Network Time
683     Protocol (NTP) and the ntp package (which provides implementations for both
684     server and client).
685 vapier 1.9 </p>
686    
687     <p>
688 swift 1.61 Many people run ntp clients on their computers. Obviously, the more clients in
689     the world, the larger the load the ntp servers need to shoulder. In
690 neysx 1.23 environments like home networks though, we can help keep the load down on
691 swift 1.61 public servers while still providing the proper time to all our computers. As
692 neysx 1.23 an added bonus, our private updates will be a lot faster for the clients too!
693     All we have to do is run a ntp server on our router that synchronizes itself
694     with the public internet servers while providing the time to the rest of the
695 swift 1.61 computers in the network. To get started, simply <c>emerge ntp</c> on the
696 vapier 1.9 router.
697     </p>
698    
699     <pre caption="Setting up the NTP server">
700     # <i>nano /etc/conf.d/ntp-client</i>
701     <comment>Customize if you wish but the defaults should be fine</comment>
702     # <i>rc-update add ntp-client default</i>
703    
704     # <i>nano /etc/ntp.conf</i>
705 neysx 1.23 <comment>Add the follwing lines:</comment>
706 vapier 1.9 restrict default ignore
707     restrict 192.168.0.0 mask 255.255.255.0 notrust nomodify notrap
708 neysx 1.23 <comment>These will allow only ntp clients with an IP
709     address in the 192.168.0.xxx range to use your ntp server</comment>
710 vapier 1.9 # <i>nano /etc/conf.d/ntpd</i>
711     <comment>Customize if you wish but the defaults should be fine</comment>
712 vapier 1.17 # <i>rc-update add ntpd default</i>
713 vapier 1.9
714     # <i>/etc/init.d/ntp-client start</i>
715     # <i>/etc/init.d/ntpd start</i>
716     </pre>
717    
718 vapier 1.22 <note>
719 neysx 1.23 You should make sure that you allow inbound and outbound communication on the
720 swift 1.61 ntp port (123/udp) when setting up the server. The client just needs outbound
721 neysx 1.23 access on port 123 over udp.
722 vapier 1.22 </note>
723    
724 vapier 1.9 <p>
725 swift 1.61 Now, on your clients, have them <c>emerge ntp</c> also. However, we will just
726 neysx 1.23 run the ntp client so setup is a lot simpler.
727 vapier 1.9 </p>
728    
729     <pre caption="Setting up a NTP client">
730     # <i>nano /etc/conf.d/ntp-client</i>
731     <comment>Change the 'pool.ntp.org' server in the NTPCLIENT_OPTS variable to '192.168.0.1'</comment>
732     # <i>rc-update add ntp-client default</i>
733     # <i>/etc/init.d/ntp-client start</i>
734     </pre>
735 neysx 1.23
736 vapier 1.9 </body>
737     </section>
738    
739     <section>
740 vapier 1.29 <title>Rsync Server</title>
741     <body>
742    
743     <p>
744 swift 1.60 For those who run multiple Gentoo boxes on the same lan, you often want to
745     keep from having every machine running <c>emerge sync</c> with remote
746 swift 1.61 servers. By setting up a local rsync, you save on both your bandwidth and
747     the Gentoo rsync servers' bandwidth. It's pretty simple to do.
748 vapier 1.29 </p>
749 neysx 1.45
750 vapier 1.29 <note>
751 neysx 1.45 For a much more in-depth rsync guide, please see the official <uri
752     link="/doc/en/rsync.xml#local">rsync guide</uri>.
753 vapier 1.29 </note>
754    
755     <p>
756 swift 1.61 Since every Gentoo machine requires rsync, theres no need to emerge it. Edit
757 swift 1.60 the default <path>/etc/rsyncd.conf</path> config file, uncomment the
758     <c>[gentoo-portage]</c> section, and make sure you add an <c>address</c>
759 swift 1.61 option. All the other defaults should be fine.
760 vapier 1.29 </p>
761    
762     <pre caption="Rsync server config">
763     pid file = /var/run/rsyncd.pid
764     use chroot = yes
765     read only = yes
766     address = 192.168.0.1
767    
768     [gentoo-portage]
769 swift 1.61 path = /mnt/space/portage
770     comment = Gentoo Linux Portage tree
771     exclude = /distfiles /packages
772 vapier 1.29 </pre>
773    
774     <p>
775     Then you need to start the service (again, the defaults are OK).
776     </p>
777    
778     <pre caption="Starting the rsync server">
779     # <i>/etc/init.d/rsyncd start</i>
780     # <i>rc-update add rsyncd default</i>
781     </pre>
782    
783     <p>
784     Only thing left is to set tell your clients to sync against the router.
785     </p>
786    
787     <pre caption="Client SYNC settings in make.conf">
788     SYNC="rsync://192.168.0.1/gentoo-portage"
789     </pre>
790    
791     </body>
792     </section>
793    
794     <section>
795 vapier 1.3 <title>Mail Server</title>
796     <body>
797 neysx 1.23
798 vapier 1.3 <p>
799 neysx 1.23 Sometimes it's nice to run your own Simple Mail Transfer Protocol (SMTP) server
800 swift 1.61 on the router. You may have your own reason for wanting to do so, but I run it
801 neysx 1.23 so that the users see mail as being sent instantly and the work of
802 swift 1.61 retrying/routing is left up to the mail server. Some ISPs also don't allow for
803 neysx 1.23 mail relaying for accounts that aren't part of their network (like Verizon).
804     Also, you can easily throttle the delivery of mail so that large attachments
805     won't seriously lag your connection for half an hour.
806 vapier 1.4 </p>
807    
808     <pre caption="Setting up SMTP">
809 nightmorph 1.56 # <i>emerge netqmail</i>
810 vapier 1.4 <comment>make sure the output of `hostname` is correct</comment>
811 nightmorph 1.56 # <i>emerge --config netqmail</i>
812 nightmorph 1.63 # <i>iptables -I INPUT -p tcp --dport smtp ! -i ${LAN} -j REJECT</i>
813 vapier 1.4 # <i>ln -s /var/qmail/supervise/qmail-send /service/qmail-send</i>
814 vapier 1.10 # <i>ln -s /var/qmail/supervise/qmail-smtpd /service/qmail-smtpd</i>
815 vapier 1.4 # <i>cd /etc/tcprules.d</i>
816     # <i>nano tcp.qmail-smtp</i>
817 vapier 1.57 <!--
818 vapier 1.13 # <i>cd /etc</i>
819     # <i>nano tcp.smtp</i>
820 vapier 1.57 -->
821 neysx 1.23 <comment>Add an entry like so to the allow section:</comment>
822     192.168.0.:allow,RELAYCLIENT=""
823 vapier 1.13 <!--
824 vapier 1.4 # <i>tcprules tcp.qmail-qmtp.cdb rules.tmp &lt; tcp.qmail-smtp</i>
825 vapier 1.57 # <i>tcprules tcp.smtp.cdb rules.tmp &lt; tcp.smtp</i>
826 vapier 1.13 -->
827 vapier 1.57 # <i>make</i>
828 vapier 1.4 # <i>rc-update add svscan default</i>
829     # <i>/etc/init.d/svscan start</i>
830     </pre>
831    
832     <p>
833 swift 1.61 I'm a huge fan of qmail, but you're free to use a different mta :). When you
834 neysx 1.23 setup e-mail on the hosts in your network, tell them that their SMTP server is
835 swift 1.61 192.168.0.1 and everything should be peachy. You might want to visit the <uri
836 nightmorph 1.56 link="http://netqmail.org/">netqmail homepage</uri> for more documentation.
837 vapier 1.3 </p>
838 neysx 1.23
839 vapier 1.3 </body>
840     </section>
841    
842 vapier 1.4 <!--
843 vapier 1.3 <section>
844 vapier 1.4 <title>E-mail Virus Scanning</title>
845 vapier 1.3 <body>
846     <p>
847 swift 1.60 If you'd like to provide e-mail virus scanning for your users, but
848     don't want to have to install a virus scanner on every single machine,
849     then <c>pop3vscan</c> may just be the thing for you; a transparent
850 vapier 1.4 Post Office Protocol (POP) scanner.
851 vapier 1.3 </p>
852 vapier 1.4
853     <pre caption="Setting up pop3vscan">
854     TODO
855     </pre>
856    
857 vapier 1.3 </body>
858     </section>
859 vapier 1.4 -->
860 vapier 1.3
861 vapier 1.33 <section>
862     <title>Full DHCP Server</title>
863     <body>
864    
865     <p>
866 swift 1.61 Earlier we used dnsmasq to provide DHCP service to all our clients. For most
867     people with a simple small LAN, this is perfect. But you may need something
868     with more features. Thus we turn to a full-featured DHCP server as provided
869 vapier 1.33 by the <uri link="http://www.isc.org/products/DHCP">ISC</uri> folks.
870     </p>
871    
872     <pre caption="Setting up dhcpd">
873     # <i>emerge dhcp</i>
874     # <i>nano /etc/dhcp/dhcpd.conf</i>
875     <comment>(Here is a sample configuration file:)</comment>
876     authoritative;
877     ddns-update-style interim;
878     subnet 192.168.0.0 netmask 255.255.255.0 {
879 swift 1.61 range 192.168.0.100 192.168.0.250;
880     default-lease-time 259200;
881     max-lease-time 518400;
882     option subnet-mask 255.255.255.0;
883     option broadcast-address 192.168.0.255;
884     option routers 192.168.0.1;
885     option domain-name-servers 192.168.0.1;
886 vapier 1.33 }
887 vapier 1.44 # <i>nano /etc/conf.d/dhcpd</i>
888 vapier 1.33 <comment>(Set IFACE="eth0")</comment>
889 vapier 1.44 # <i>rc-update add dhcpd default</i>
890     # <i>/etc/init.d/dhcpd start</i>
891 vapier 1.33 </pre>
892    
893     <p>
894 swift 1.60 This is the minimal setup required to replace the dnsmasq DHCP functionality
895 swift 1.61 that we used earlier. Speaking of which, you did remember to disable the DHCP
896     features in dnsmasq didn't you? If not, you should do so now (just comment
897 vapier 1.33 out the <c>dhcp-range</c> setting in <path>/etc/dnsmasq.conf</path> and restart
898     the service).
899     </p>
900    
901     </body>
902     </section>
903    
904 vapier 1.38 <section>
905     <title>Connect Another LAN (or two or three or ...)</title>
906     <body>
907    
908     <p>
909 swift 1.61 Sometimes you have need of connecting the router to another LAN. Maybe you
910 swift 1.60 want to hook up a group of friends temporarily, or you're a neat freak and
911     want to section off different groups of computers, or you're just really
912 swift 1.61 really bored. Whatever the reasons, extending the router to other LAN
913     networks should be pretty straightforward. In the following examples, I will
914 swift 1.60 assume that this new network is connected via a third ethernet card, namely
915 vapier 1.38 <c>eth2</c>.
916     </p>
917    
918     <p>
919 swift 1.61 First you need to configure the interface. Just take the instructions in the
920 swift 1.60 <uri link="#doc_chap4_pre1">4.1 code listing</uri> and replace <c>eth0</c>
921 vapier 1.38 with <c>eth2</c> and <c>192.168.0</c> with <c>192.168.1</c>.
922     </p>
923    
924     <p>
925 swift 1.61 Then you need to tweak dnsmasq to service the new interface. Just edit the
926 swift 1.60 <path>/etc/conf.d/dnsmasq</path> file again and append <c>-i eth2</c> to
927 swift 1.61 DNSMASQ_OPTS; using -i multiple times is OK. Then edit
928 swift 1.60 <path>/etc/dnsmasq.conf</path> and add another line like the dhcp-range line
929     in the <uri link="#doc_chap5_pre1">5.1 code listing</uri>, replacing
930 swift 1.61 <c>192.168.0</c> with <c>192.168.1</c>. Having multiple dhcp-range lines is
931 vapier 1.38 OK too.
932     </p>
933    
934     <p>
935 swift 1.60 Finally, see the rules in the <uri link="#doc_chap5_pre2">5.2 code
936 swift 1.61 listing</uri> and duplicate the rules that have <c>-i ${LAN}</c> in them. You
937 vapier 1.38 may want to create another variable, say <c>LAN2</c>, to make things easier.
938     </p>
939    
940     </body>
941     </section>
942    
943 vapier 1.4 </chapter>
944    
945     <chapter>
946 vapier 1.30 <title>Troubleshooting</title>
947 vapier 1.27
948     <section>
949     <title>Useful Tools</title>
950     <body>
951    
952     <p>
953 swift 1.60 If you're having trouble getting your computers to communicate, you may way to
954     try out the following tools (they can all be found in the <c>net-analyzer</c>
955 vapier 1.27 portage category):
956     </p>
957    
958     <table>
959     <tr>
960 swift 1.61 <th>Utility</th>
961     <th>Description</th>
962 vapier 1.27 </tr>
963     <tr>
964 swift 1.61 <ti>wireshark</ti>
965     <ti>GUI tool to view all raw network data according to filters</ti>
966 vapier 1.27 </tr>
967     <tr>
968 swift 1.61 <ti>tcpdump</ti>
969     <ti>Console tool to dump all raw network data according to filters</ti>
970 vapier 1.27 </tr>
971     <tr>
972 swift 1.61 <ti>iptraf</ti>
973     <ti>ncurses based IP LAN monitor</ti>
974 vapier 1.27 </tr>
975     <tr>
976 swift 1.61 <ti>ettercap</ti>
977     <ti>ncurses based network monitor/control</ti>
978 vapier 1.27 </tr>
979     </table>
980    
981     </body>
982     </section>
983    
984     <section>
985 vapier 1.31 <title>DHCP Fails To Start</title>
986     <body>
987    
988     <p>
989 swift 1.60 When starting the dhcp init.d script for the first time, it may fail to load
990 vapier 1.31 but neglect to give you any useful info.
991     </p>
992    
993     <pre caption="DHCP Failing Example">
994     # <i>/etc/init.d/dhcp start</i>
995 swift 1.61 * Setting ownership on dhcp.leases ... [ ok ]
996     * Starting dhcpd ... [ !! ]
997 vapier 1.31 </pre>
998    
999     <p>
1000 swift 1.61 The trick is to know where dhcpd is sending its output. Simply browse to
1001     <path>/var/log</path> and read the log files. Since the exact log file depends
1002 rane 1.46 on the package you are using as a syslog, try running <c>grep -Rl dhcpd
1003 swift 1.61 /var/log</c> to narrow down the possibilities. Chances are you made a typo in
1004     your config file. You could also try running <c>dhcpd -d -f</c> (short for
1005 rane 1.46 debug / foreground) and debug the error based upon the output.
1006 vapier 1.31 </p>
1007    
1008     </body>
1009     </section>
1010    
1011     <section>
1012 vapier 1.27 <title>Incorrect MTU Value</title>
1013     <body>
1014    
1015     <p>
1016 vapier 1.52 If you experience odd errors (such as not being able to access some webpages
1017 swift 1.61 while others load fine), you may be having Path MTU Discovery trouble. The
1018 vapier 1.52 quick way to test is to run this iptables command:
1019 vapier 1.27 </p>
1020    
1021     <pre caption="Circumvent MTU issues">
1022     # <i>iptables -A FORWARD -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu</i>
1023     </pre>
1024    
1025     <p>
1026 nightmorph 1.54 This will affect all new connections, so just refresh the website you're having
1027     problems with in order to test. In case it helps, the standard MTU value for
1028     100mbit ethernet connections is <c>1500</c>; this value also applies to PPPoA.
1029     For PPPoE connections it is <c>1492</c>. For more info, you should read Chapter
1030     15 of the <uri link="http://lartc.org/howto/">Linux Advanced Routing &amp;
1031 vapier 1.27 Traffic Control HOWTO</uri>.
1032     </p>
1033    
1034 vapier 1.62 <p>
1035     If that command does not work for you, you may want to try putting the rule
1036     into the mangle table. Simply add <c>-t mangle</c> to the command.
1037     </p>
1038    
1039 vapier 1.27 </body>
1040     </section>
1041    
1042 vapier 1.47 <section>
1043     <title>Unable to connect two machines directly</title>
1044     <body>
1045    
1046     <p>
1047 swift 1.60 If (for whatever reason) you want to connect two machines directly together
1048 jkt 1.48 without a hub or switch, a regular ethernet cable will likely not work, unless
1049     you have an Auto MDI/MDI-X (also known as "autosensing") capable network
1050 swift 1.61 adapter. You will need a different cable called a crossover cable. This <uri
1051 vapier 1.47 link="http://en.wikipedia.org/wiki/Ethernet_crossover_cable">Wikipedia</uri>
1052     page explains the low level details.
1053     </p>
1054    
1055     </body>
1056     </section>
1057    
1058 vapier 1.27 </chapter>
1059    
1060     <chapter>
1061 vapier 1.4 <title>Final Notes</title>
1062 vapier 1.3 <section>
1063     <body>
1064 neysx 1.23
1065 vapier 1.3 <p>
1066 neysx 1.23 I have no final notes other than if you experience any troubles with the guide,
1067     please contact <mail link="vapier@gentoo.org">me</mail> or file a bug with <uri
1068 swift 1.61 link="http://bugs.gentoo.org/">Gentoo's Bugtracking Website</uri>. If you have
1069 neysx 1.23 some interesting bits you think would enhance this guide, by all means send it
1070     my way for inclusion.
1071 vapier 1.3 </p>
1072 neysx 1.23
1073 vapier 1.1 </body>
1074     </section>
1075     </chapter>
1076     </guide>

  ViewVC Help
Powered by ViewVC 1.1.20