Typo
[linux_from_scratch_hints.git] / OLD / dsl-router.txt
blobd7302ba50e3202c47916ec4f48699e347651270e
1 TITLE:          How To Build A DSL-Router
2 LFS VERSION:    All
3 AUTHOR:         Florin Boariu <florin@bnv-bamberg.de>
5 SYNOPSIS:
6         This hint explains how to set up your own PPPoE/DSL gateway.
7 Or Better: it explains how _I_ did it and assumes that you could
8 do it the same ;)
11 HINT:
12 You will need three things:
14 o A Linux System with two configured NICs
15 o A Kernel Capable of PPP and PPPoE (PPP-over-Ethernet)
16 o A PPP Daemon Capable of PPPoE and DoD (Dial-on-Demand)
19 The Linux System
20 ----------------
22 Check the LFS Book, it should explain it quite clearly. What it
23 doesn't explain is how to add a second NIC: no problem, just make sure
24 you have compiled the correct driver and add the folllowing lines to
25 your /etc/inet.d/network (or whatever your network-up-script is).
28 # these lines should already be present if you
29 # have one working network interface
30 # for all computers in your network, this will
31 # be the router/gateway address.
33 ifconfig eth0 10.1.1.200
34 route add net 10.1.1.0 netmask 255.255.255.0
37 # add this line to configure the second interface
39 ifconfig eth1 10.10.10.254
42 The Kernel
43 ----------
45 Following options should be enabled in the kernel (either 'm' for
46 'module' or 'y' for 'yes'):
48 CONFIG_NETDEVICES=y
50 CONFIG_PPP=y
51 CONFIG_PPPOE=y
53 You don't need to enable any kind of compression/deflate support for
54 PPP, since PPPoE only works with turned-off compression (at least here
55 in Germany -- your mileage may vary).
57 And don't forget to make sure the respective modules get loaded, in
58 case you compiled anything as a module.
60 Of course, the kernel should also have the drivers needed for your
61 NICs enabled, for example
63 CONFIG_ETHERNET=y
64 CONFIG_NET_PCI=y
65 CONFIG_8139TOO=y
67 Then you'll have to enable routing support for your kernel. I'm not
68 quite sure about all the options, but the following work for me (2.4
69 kernel, ipv4). Some of them I knew, others I guessed, probably some
70 are superfluous.
72 If someone knows better, please correct these.
74 Anyway, here my settings:
76 CONFIG_PACKET=y
77 CONFIG_PACKET_MMAP=y
78 CONFIG_NETLINK=y
79 CONFIG_RNETLINK=y
80 CONFIG_NETLINKDEV=y
81 CONFIG_UNIX=y
82 CONFIG_INET=y
83 CONFIG_IP_ADVANCED_ROUTER=y
84 CONFIG_IP_MULTIPLE_TABLES=y
85 CONFIG_IP_ROUTE_FWMARK=y
86 CONFIG_IP_ROUTE_NAT=y
87 CONFIG_IP_ROUTE_MULTIPATH=y
88 CONFIG_IP_ROUTE_TOS=y
89 CONFIG_NET_IPIP=y
90 CONFIG_SYN_COOKIES=y
92 # Netfilter Configuration 
93 <well... I marked everything, partly as
94  built-in, partly as loadable modules.  do whatever fits best to your
95  purposes.  however, CONFIG_IP_NF_TARGET_BALANCE will cause some
96  compile problems as of kernel version 2.4.3, so you might want to
97  choose not to enable it>
100 The PPPoE Daemon with Dial-on-Demand
101 ------------------------------------
103 In order to dial-on-demand you will need a pppd-2.4.1, patched with
104 the pppoe4 patch. I couldn't find that patch on the net, it was sent
105 to me by the author Michal Ostrowski
106 <mostrows@styx.uwaterloo.ca>. Note that a pppd-2.4.0-pppoe3 will _not_
107 work! It will work for _normal_ pppoe use, but not for dial-on-demand.
109 As of now (2001-07-01) I wasn't able to find the pppoe4-patched pppd
110 available for download, so you might aswell have to email to Michal.
111 Alternately, you cold have a look at http://www.linuxfromscratch.org/
112 -- it might be available for download there meanwhile...
114 Just install the new pppd and write the following to your
115 /etc/ppp/options file:
118 # /etc/ppp/options: <cut_here>
120 plugin /usr/lib/pppd/plugins/pppoe.so
122 demand
123 connect /bin/true
124 ipcp-accept-remote
125 ipcp-accept-local
127 # the idle time in seconds -- you might want to adjust this
128 idle 600
129 noipdefault
130 defaultroute
131 user <yourusername@yourprovidersnost.com>
132 hide-password
133 noaccomp
134 nopcomp
135 nocrtscts
136 lcp-echo-interval 10
137 lcp-echo-failure 3
138 lock
139 nodetach
141 # /etc/ppp/options: </cut_here>
144 You will also need a /etc/ppp/pap-secrets file, with a valid password
145 for <yourusername@yourprovidershost.com>.
147 Next, you'll have to start the daemon as root. Simply call
149 # pppd eth0
151 From now on, you should be able to trigger a connect by simply pinging
152 an outside host:
154 # ping 195.30.20.19
156 If it does not work, you've done something wrong. You might want to
157 read the PPP howto or some docs that come with pppd-2.4.1... good
158 luck!
160 If it does work, then the link should be automagically terminated
161 after the specified idle time. Then you should be able to connect
162 again by ping.  Don't laugh, there's a reason why I'm telling this:
163 the 2.4.0 version of pppd, pppoe patched, does not connect for the
164 second time. It blocks!  You _need_ pppd-2.4.1-pppoe4 or higher!
166 Now you might want to trigger the start of your pppd from somewhere in
167 /etc/init.d/ (/etc/rcX.d/).
170 Do The Routing
171 --------------
173 Your box can now dial itself into the internet, but it still takes
174 some more lines in order to have a router. You have to install
175 iptables (http://netfilter.samba.org/).  The installation of Iptables
176 seemed quite special to me. It didn't make any trouble, but it looked
177 like some software which could lead to trouble -- I happened to guess
178 the correct settings, but I'm far from understanding the software
179 deeply, so you're basically on your own ... :-/ There's one thing I
180 can tell, though: you'll need to start the patch-o-matic ('make
181 patch-o-matic') and apply the TCPMSS patch.  This has something to do
182 with the MTU (maximum transmit unit) of the clients, but I never
183 really understood what.
185 When you suceeded the installation, execute the following:
187 --------<cut-here>-----------
190 # prepare the kernel for ip forwarding and dynamic ip addresses
192 /bin/echo "1" /proc/sys/net/ipv4/ip_forward
193 /bin/echo "1" /proc/sys/net/ipv4/ip_dynaddr
196 # enable FORWARD target for all packets comming from 10.x.x.x
197 # via eth0 (from the inside) or via ppp0 (outside)
198 # aswell as INPUT packets from eth0 (inside)
200 /usr/sbin/iptables -A FORWARD -i eth0 -s 10.1.1.0/24 -j ACCEPT
201 /usr/sbin/iptables -A FORWARD -i ppp0 -s 10.1.1.0/24 -j ACCEPT
202 /usr/sbin/iptables -A INPUT -i eth0 -s 10.1.1.0/24 -j ACCEPT
205 # set default policy to DROP all other INPUT or FORWARD packets
207 /usr/sbin/iptables -P INPUT DROP
208 /usr/sbin/iptables -P FORWARD DROP
211 # enable masquerading for all packets from 10.x.x.x
213 /usr/sbin/iptables -t nat -A POSTROUTING -s 10.1.1.0/24 -j MASQUERADE
216 # set the MTU of the interfaces to the correct size. this is usually
217 # smaller than usual, since pppoe does some more encapsulating.  If you
218 # don't, ping to the outside world should work, but almost any other
219 # TCP connection (like FTP or HTTP) will fail.  Accorting to Daniel
220 # Roethlingsberger, this can also be done at interface level (try
221 # 'ifconfig mtu XXX'), but there's nothing wrong with taking the
222 # following line in your iptables, too.
224 /usr/sbin/iptables -I FORWARD -p tcp --tcp-flags SYN,RST SYN -j \
225                         TCPMSS --clamp-mss-to-pmtu
227 -----------</cut-here>-------------
229 This will give you basic routing support. For troubleshooting and/or
230 more advanced iptables flags (if you're interested in making a
231 firewall out of your router), see the iptables-HOWTO:
232 http://www.linuxgrill.com/anonymous/fire/netfilter/iptables-HOWTO.html.
234 You might also want to search http://www.linuxdoc.org/ for the keyword
235 'iptables' for some more advanced docs on routing and/or transparent
236 proxying ;)
238 Good Luck!
240 Florin Boariu <florin@bnv-bamberg.de>