Update changelog
[l2tpns.git] / Docs / manual.html
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
2 "http://www.w3.org/TR/html4/loose.dtd">
3
4 <HTML>
5 <HEAD>
6 <TITLE>L2TPNS Manual</TITLE>
7 <STYLE TYPE="text/css">
8 H1 {
9 text-align: center;
10 }
11
12 H2 {
13 border-top: 1px solid black;
14 border-bottom: 1px solid black;
15 background-color: lightblue;
16 padding-left: 10px;
17 }
18
19 H3 {
20 text-decoration: underline;
21 }
22 </STYLE>
23 </HEAD>
24 <BODY>
25 <H1>L2TPNS Manual</H1>
26 <OL>
27 <LI><A HREF="#Overview">Overview</A></LI>
28 <LI><A HREF="#Installation">Installation</A>
29 <OL>
30 <LI><A HREF="#Requirements">Requirements</A></LI>
31 <LI><A HREF="#Compile">Compile</A></LI>
32 <LI><A HREF="#Install">Install</A></LI>
33 <LI><A HREF="#Running">Running</A></LI>
34 </OL>
35 </LI>
36 <LI><A HREF="#Configuration">Configuration</A>
37 <OL>
38 <LI><A HREF="#startup-config">startup-config</A></LI>
39 <LI><A HREF="#users">users</A></LI>
40 <LI><A HREF="#ip-pool">ip_pool</A></LI>
41 <LI><A HREF="#build-garden">build-garden</A></LI>
42 </OL>
43 </LI>
44 <LI><A HREF="#ControllingtheProcess">Controlling the Process</A>
45 <OL>
46 <LI><A HREF="#Command-LineInterface">Command-Line Interface</A></LI>
47 <LI><A HREF="#nsctl">nsctl</A></LI>
48 <LI><A HREF="#Signals">Signals</A></LI>
49 </OL>
50 </LI>
51 <LI><A HREF="#Throttling">Throttling</A></LI>
52 <LI><A HREF="#Interception">Interception</A></LI>
53 <LI><A HREF="#Authentication">Authentication</A></LI>
54 <LI><A HREF="#Plugins">Plugins</A></LI>
55 <LI><A HREF="#WalledGarden">Walled Garden</A></LI>
56 <LI><A HREF="#Filtering">Filtering</A></LI>
57 <LI><A HREF="#Clustering">Clustering</A></LI>
58 <LI><A HREF="#Routing">Routing</A></LI>
59 <LI><A HREF="#Performance">Performance</A></LI>
60 </OL>
61
62 <H2 ID="Overview">Overview</H2>
63 l2tpns a complete L2TP implementation. It supports the LAC, LNS, PPPOE and DHCPv6 server.<P>
64
65 L2TP (Layer 2 Tunneling Protocol) is designed to allow any layer 2 protocol (e.g. Ethernet, PPP) to be tunneled over an IP connection. l2tpns implements PPP over L2TP only.<P>
66
67 There are a couple of other L2TP implementations, of which <A HREF="http://sourceforge.net/projects/l2tpd">l2tpd</A> is probably the most popular. l2tpd also will handle being either end of a tunnel, and is a lot more configurable than l2tpns. However, due to the way it works, it is nowhere near as scalable.<P>
68
69 l2tpns uses the TUN/TAP interface provided by the Linux kernel to receive and send packets. Using some packet manipulation it doesn't require a single interface per connection, as l2tpd does.<P>
70
71 This allows it to scale extremely well to very high loads and very high numbers of connections.<P>
72
73 It also has a plugin architecture which allows custom code to be run during processing. An example of this is in the walled garden module included.<P>
74
75 <BR>
76 <EM>Documentation is not my best skill. If you find any problems
77 with this document, or if you wish to contribute, please email <A
78 HREF="mailto:l2tpns-users@lists.sourceforge.net?subject=L2TPNS+Documentation">the mailing list</A>.</EM><P>
79
80 <H2 ID="Installation">Installation</H2>
81 <H3 ID="Requirements">Requirements</H3>
82
83 <OL>
84 <LI>Linux kernel version 2.4 or above, with the Tun/Tap interface either
85 compiled in, or as a module.</LI>
86
87 <LI>libcli 1.8.0 or greater.<BR>You can get this from <A
88 HREF="http://sourceforge.net/projects/libcli">http://sourceforge.net/projects/libcli</A></LI>
89 </OL>
90
91 <H3 ID="Compile">Compile</H3>
92
93 You can generally get away with just running <B>make</B> from the source
94 directory. This will compile the daemon, associated tools and any modules
95 shipped with the distribution.<P>
96
97 <H3 ID="Install">Install</H3>
98
99 After you have successfully compiled everything, run <B>make
100 install</B> to install it. By default, the binaries are installed into
101 <EM>/usr/sbin</EM>, the configuration into <EM>/etc/l2tpns</EM>, and the
102 modules into <EM>/usr/lib/l2tpns</EM>.<P>
103
104 You will definately need to edit the configuration files before you
105 start. See the <A HREF="#Configuration">Configuration</A> section for
106 more information.<P>
107
108 <H3 ID="Running">Running</H3>
109
110 You only need to run <B>/usr/sbin/l2tpns</B> as root to start it. It does
111 not detach to a daemon process, so you should perhaps run it from init.<P>
112
113 By default there is no log destination set, so all log messages will go to
114 stdout.<P>
115
116 <H2 ID="Configuration">Configuration</H2>
117
118 All configuration of the software is done from the files installed into
119 /etc/l2tpns.
120
121 <H3 ID="startup-config">startup-config</H3>
122
123 This is the main configuration file for l2tpns. The format of the file is a
124 list of commands that can be run through the command-line interface. This
125 file can also be written directly by the l2tpns process if a user runs the
126 <EM>write memory</EM> command, so any comments will be lost. However if your
127 policy is not to write the config by the program, then feel free to comment
128 the file with a # or ! at the beginning of the line.<P>
129
130 A list of the possible configuration directives follows. Each of these
131 should be set by a line like:<P>
132 <PRE>
133 set configstring "value"
134 set ipaddress 192.168.1.1
135 set boolean true
136 </PRE>
137
138 <P>
139 <UL>
140 <LI><B>debug</B> (int)<BR>
141 Sets the level of messages that will be written to the log file. The value
142 should be between 0 and 5, with 0 being no debugging, and 5 being the
143 highest. A rough description of the levels is:
144 <OL>
145 <LI VALUE=0>Critical Errors - Things are probably broken</LI>
146 <LI>Errors - Things might have gone wrong, but probably will recover</LI>
147 <LI>Warnings - Just in case you care what is not quite perfect</LI>
148 <LI>Information - Parameters of control packets</LI>
149 <LI>Calls - For tracing the execution of the code</LI>
150 <LI>Packets - Everything, including a hex dump of all packets processed... probably twice</LI>
151 </OL><P>
152 Note that the higher you set the debugging level, the slower the program
153 will run. Also, at level 5 a LOT of information will be logged. This should
154 only ever be used for working out why it doesn't work at all.
155 </LI>
156
157 <LI><B>log_file</B> (string)<BR>
158 This will be where all logging and debugging information is written to. This may be either a filename, such as <EM>/var/log/l2tpns</EM>, or the special magic string <EM>syslog:facility</EM>, where <EM>facility</EM> is any one of the syslog logging facilities, such as local5.
159 </LI>
160
161 <LI><B>pid_file</B> (string)<BR>
162 If set, the process id will be written to the specified file. The value must be an absolute path.
163 </LI>
164
165 <LI><B>random_device</B>B> (string)<BR>
166 Path to random data source (default /dev/urandom). Use "" to use the rand() library function.
167 </LI>
168
169 <LI><B>l2tp_secret</B> (string)<BR>
170 The secret used by l2tpns for authenticating tunnel request. Must be
171 the same as the LAC, or authentication will fail. Only actually be
172 used if the LAC requests authentication.
173 </LI>
174
175 <LI><B>l2tp_mtu</B> (int)<BR>
176 MTU of interface for L2TP traffic (default: 1500). Used to set link MRU and adjust TCP MSS.
177 </LI>
178
179 <LI><B>ppp_restart_time</B> (int)<BR>
180 <B>ppp_max_configure</B> (int)<BR>
181 <B>ppp_max_failure</B> (int)<BR>
182 PPP counter and timer values, as described in &sect;4.1 of
183 <a href="ftp://ftp.rfc-editor.org/in-notes/rfc1661.txt">RFC1661</a>.
184 </LI>
185
186 <LI><B>primary_dns</B> (ip address)
187 <LI><B>secondary_dns</B> (ip address)<BR>
188 Whenever a PPP connection is established, DNS servers will be sent to the
189 user, both a primary and a secondary. If either is set to 0.0.0.0, then that
190 one will not be sent.
191 </LI>
192
193 <LI><B>primary_radius</B> (ip address)
194 <LI><B>secondary_radius</B> (ip address)<BR>
195 Sets the RADIUS servers used for both authentication and accounting.
196 If the primary server does not respond, then the secondary RADIUS
197 server will be tried.<br>
198 <strong>Note:</strong> in addition to the source IP address and
199 identifier, the RADIUS server <strong>must</strong> include the source
200 port when detecting duplicates to supress (in order to cope with a
201 large number of sessions comming on-line simultaneously l2tpns uses a
202 set of udp sockets, each with a seperate identifier).
203 </LI>
204
205 <LI><B>primary_radius_port</B> (short)
206 <LI><B>secondary_radius_port</B> (short)<BR>
207 Sets the authentication ports for the primary and secondary RADIUS
208 servers. The accounting port is one more than the authentication
209 port. If no RADIUS ports are given, the authentication port defaults
210 to 1645, and the accounting port to 1646.
211 </LI>
212
213 <LI><B>radius_accounting</B> (boolean)<BR>
214 If set to true, then RADIUS accounting packets will be sent. This
215 means that a Start record will be sent when the session is
216 successfully authenticated, and a Stop record will be sent when the
217 session is closed.
218 </LI>
219
220 <LI><B>radius_secret</B> (string)<BR>
221 This secret will be used in all RADIUS queries. If this is not set then RADIUS queries will fail.
222 </LI>
223
224 <LI><B>radius_authtypes</B> (string)</BR>
225 A comma separated list of supported RADIUS authentication methods
226 (<B>pap</B> or <B>chap</B>), in order of preference (default <B>pap</B>).
227 </LI>
228
229 <LI><B>radius_dae_port</B> (short)<BR>
230 Port for DAE RADIUS (Packet of Death/Disconnect, Change of Authorization)
231 requests (default: <B>3799</B>).
232 </LI>
233
234 <LI><B>allow_duplicate_users</B> (boolean)</BR>
235 Allow multiple logins with the same username. If false (the default),
236 any prior session with the same username will be dropped when a new
237 session is established.
238 </LI>
239
240 <LI><B>bind_address</B> (ip address)<BR>
241 It's the listen address of the l2tp udp protocol sent and received to LAC. This address is also assigned to the tun interface if no iftun_address is specified. Packets containing user traffic should be routed via this address if given, otherwise the primary address of the machine.
242 </LI>
243
244 <LI><B>iftun_address</B> (ip address)<BR>
245 This parameter is used when you want a tun interface address different
246 from the address of "bind_address" (For use in cases of specific configuration).
247 If no address is given to iftun_address and bind_address, 1.1.1.1 is used.
248 </LI>
249
250 <LI><B>bind_multi_address</B> (ip address)<BR>
251 This parameter permit to listen several addresss of the l2tp udp protocol
252 (and set several address to the tun interface).
253 <BR>
254 WHEN this parameter is set, It OVERWRITE the parameters "bind_address"
255 and "iftun_address".
256 <BR>
257 these can be interesting when you want do load-balancing in cluster mode
258 of the uploaded from the LAC. For example you can set a bgp.prepend(MY_AS)
259 for Address1 on LNS1 and a bgp.prepend(MY_AS) for Address2 on LNS2
260 (see BGP AS-path prepending).
261 <BR>
262 example of use with 2 address:
263 <BR>
264 set bind_multi_address "64.14.13.41, 64.14.13.42"
265 </LI>
266
267 <LI><B>tundevicename</B> (string)<BR>
268 Name of the tun interface (default: "tun0").
269 </LI>
270
271 <LI><B>peer_address</B> (ip address)<BR>
272 Address to send to clients as the default gateway.
273 </LI>
274
275 <LI><B>send_garp</B> (boolean)<BR>
276 Determines whether or not to send a gratuitous ARP for the
277 bind_address when the server is ready to handle traffic (default:
278 true).<BR>
279 This value is ignored if BGP is configured.
280 </LI>
281
282 <LI><B>throttle_speed</B> (int)<BR>
283 Sets the default speed (in kbits/s) which sessions will be limited to.
284 If this is set to 0, then throttling will not be used at all. Note:
285 You can set this by the CLI, but changes will not affect currently
286 connected users.
287 </LI>
288
289 <LI><B>throttle_buckets</B> (int)<BR>
290 Number of token buckets to allocate for throttling. Each throttled
291 session requires two buckets (in and out).
292 </LI>
293
294 <LI><B>accounting_dir</B> (string)<BR>
295 If set to a directory, then every 5 minutes the current usage for
296 every connected use will be dumped to a file in this directory. Each
297 file dumped begins with a header, where each line is prefixed by #.
298 Following the header is a single line for every connected user, fields
299 separated by a space.<BR> The fields are username, ip, qos,
300 uptxoctets, downrxoctets, origin (optional). The qos field is 1 if a standard user, and
301 2 if the user is throttled. The origin field is dump if account_all_origin is set to true
302 (origin value: L=LAC data, R=Remote LNS data, P=PPPOE data).
303 </LI>
304
305 <LI><B>account_all_origin</B> (boolean)<BR>
306 If set to true, all origin of the usage is dumped to the accounting file (LAC+Remote LNS+PPPOE)(default false).
307 </LI>
308
309 <LI><B>dump_speed</B> (boolean)<BR>
310 If set to true, then the current bandwidth utilization will be logged every
311 second. Even if this is disabled, you can see this information by running
312 the <EM>uptime</EM> command on the CLI.
313 </LI>
314
315 <LI><B>multi_read_count</B> (int)<BR>
316 Number of packets to read off each of the UDP and TUN fds when
317 returned as readable by select (default: 10). Avoids incurring the
318 unnecessary system call overhead of select on busy servers.
319 </LI>
320
321 <LI><B>scheduler_fifo</B> (boolean)<BR>
322 Sets the scheduling policy for the l2tpns process to SCHED_FIFO. This
323 causes the kernel to immediately preempt any currently running SCHED_OTHER
324 (normal) process in favour of l2tpns when it becomes runnable.
325 Ignored on uniprocessor systems.
326 </LI>
327
328 <LI><B>lock_pages</B> (boolean)<BR>
329 Keep all pages mapped by the l2tpns process in memory.
330 </LI>
331
332 <LI><B>icmp_rate</B> (int)<BR>
333 Maximum number of host unreachable ICMP packets to send per second.
334 </LI>
335
336 <LI><B>packet_limit</B> (int><BR>
337 Maximum number of packets of downstream traffic to be handled each
338 tenth of a second per session. If zero, no limit is applied (default:
339 0). Intended as a DoS prevention mechanism and not a general
340 throttling control (packets are dropped, not queued).
341 </LI>
342
343 <LI><B>cluster_address</B> (ip address)<BR>
344 Multicast cluster address (default: 239.192.13.13). See the section
345 on <A HREF="#Clustering">Clustering</A> for more information.
346 </LI>
347
348 <LI><B>cluster_port</B> (int udp port)<BR>
349 UDP cluster port (default: 32792). See the section on
350 <A HREF="#Clustering">Clustering</A> for more information.
351 </LI>
352
353 <LI><B>cluster_interface</B> (string)<BR>
354 Interface for cluster packets (default: eth0).
355 </LI>
356
357 <LI><B>cluster_mcast_ttl</B> (int)<BR>
358 TTL for multicast packets (default: 1).
359 </LI>
360
361 <LI><B>cluster_hb_interval</B> (int)<BR>
362 Interval in tenths of a second between cluster heartbeat/pings.
363 </LI>
364
365 <LI><B>cluster_hb_timeout</B> (int)<BR>
366 Cluster heartbeat timeout in tenths of a second. A new master will be
367 elected when this interval has been passed without seeing a heartbeat
368 from the master.
369 </LI>
370
371 <LI><B>cluster_master_min_adv</B> (int)<BR>
372 Determines the minumum number of up to date slaves required before the
373 master will drop routes (default: 1).
374 </LI>
375
376 <LI><B>echo_timeout</B> (int)<BR>
377 Time between last packet sent and LCP ECHO generation
378 (default: 10 (seconds)).
379 </LI>
380
381 <LI><B>idle_echo_timeout</B> (int)<BR>
382 Drop sessions who have not responded within idle_echo_timeout seconds
383 (default: 240 (seconds))
384 </LI>
385
386 <LI><B>ppp_keepalive</B> (int)<BR>
387 Change this value to no to force generation of LCP ECHO every
388 echo_timeout seconds, even there are activity on the link.
389 (default: yes)
390 </LI>
391
392 <LI><B>auth_tunnel_change_addr_src</B> (boolean)<BR>
393 This parameter authorize to change the source IP of the tunnels l2tp.
394 This parameter can be used when the remotes BAS/LAC are l2tpns server
395 configured in cluster mode, but that the interface to remote LNS are
396 not clustered (the tunnel can be coming from different source IP)
397 (default: no).
398 </LI>
399
400 <LI><B>disable_sending_hello</B> (boolean)<BR>
401 Disable l2tp sending HELLO message for Apple compatibility.
402 Some OS X implementation of l2tp no manage the L2TP "HELLO message".
403 (default: no).
404 </LI>
405
406 </UL>
407
408 <P><U><B>LAC configuration</B></U></P>
409 <UL>
410 <LI><B>bind_address_remotelns</B> (ip address)<BR>
411 Address of the interface to listen the remote LNS tunnels.
412 If no address is given, all interfaces are listened (Any Address).
413 </LI>
414
415 <LI><B>bind_portremotelns</B> (short)<BR>
416 Port to bind for the Remote LNS (default: 65432).
417 </LI>
418
419 </UL>
420
421 <P>A static REMOTES LNS configuration can be entered by the command:</P>
422 <DL> <DD><B>setforward</B> <I>MASK</I> <I>IP</I> <I>PORT</I> <I>SECRET</I> </DL>
423
424 where <I>MASK</I> specifies the mask of users who have forwarded to
425 remote LNS (ex: "/friendISP@company.com").</BR>
426 where <I>IP</I> specifies the IP of the remote LNS (ex: "66.66.66.55").</BR>
427 where <I>PORT</I> specifies the L2TP Port of the remote LNS
428 (Normally should be 1701) (ex: 1701).</BR>
429 where <I>SECRET</I> specifies the secret password the remote LNS (ex: mysecret).</BR>
430 </BR>
431 The static Remote LNS configuration can be used when the friend ISP not
432 have a proxied Radius.</BR>
433 If the proxied Radius is used, It will return the RADIUS attributes:</BR>
434 Tunnel-Type: 1 = L2TP</BR>
435 Tunnel-Medium-Type: 1 = IPv4</BR>
436 Tunnel-Password: 1 = "LESECRETL2TP"</BR>
437 Tunnel-Server-Endpoint: 1 = "88.xx.xx.x1"</BR>
438 Tunnel-Assignment-Id: 1 = "friendisp_lns1"</BR>
439 Tunnel-Type: 2 = L2TP</BR>
440 Tunnel-Medium-Type: 2 = IPv4</BR>
441 Tunnel-Password: 2 = "LESECRETL2TP"</BR>
442 Tunnel-Server-Endpoint: 2 = "88.xx.xx.x2"</BR>
443 Tunnel-Assignment-Id: 2 = "friendisp_lns2"</BR>
444
445 <P><U><B>PPPOE configuration</B></U></P>
446
447 <UL>
448 <LI><B>pppoe_if_to_bind</B> (string)<BR>
449 PPPOE server interface to bind (ex: "eth0.12"), If not specified the server PPPOE is not enabled.
450 For the pppoe clustering, all the interfaces PPPOE of the clusters must use the same HW address (MAC address).
451 </LI>
452
453 <LI><B>pppoe_service_name</B> (string)<BR>
454 PPPOE service name (default: NULL).
455 </LI>
456
457 <LI><B>pppoe_ac_name</B> (string)<BR>
458 PPPOE access concentrator name (default: "l2tpns-pppoe").
459 </LI>
460
461 <LI><B>pppoe_only_equal_svc_name</B> (boolean)<BR>
462 If set to yes, the PPPOE server only accepts clients with a "service-name"
463 different from NULL and a "service-name" equal to server "service-name" (default: no).
464 </LI>
465
466 </UL>
467
468 <P><U><B>BGP configuration</B></U></P>
469
470 <P>BGP routing configuration is entered by the command:
471 The routing configuration section is entered by the command
472 <DL><DD><B>router bgp</B> <I>as</I></DL>
473 where <I>as</I> specifies the local AS number.
474
475 <P>Subsequent lines prefixed with
476 <DL><DD><B>neighbour</B> <I>peer</I></DL>
477 define the attributes of BGP neighhbours. Valid commands are:
478 <DL>
479 <DD><B>neighbour</B> <I>peer</I> <B>remote-as</B> <I>as</I>
480 <DD><B>neighbout</B> <I>peer</I> <B>timers</B> <I>keepalive hold</I>
481 </DL>
482
483 Where <I>peer</I> specifies the BGP neighbour as either a hostname or
484 IP address, <I>as</I> is the remote AS number and <I>keepalive</I>,
485 <I>hold</I> are the timer values in seconds.
486
487 <P>Named access-lists are configured using one of the commands:
488 <DL>
489 <DD><B>ip access-list standard</B> <I>name</I>
490 <DD><B>ip access-list extended</B> <I>name</I>
491 </DL>
492
493 <P>Subsequent lines prefixed with <B>permit</B> or <B>deny</B>
494 define the body of the access-list. Standard access-list syntax:
495 <DL>
496 <DD>{<B>permit</B>|<B>deny</B>}
497 {<I>host</I>|<I>source source-wildcard</I>|<B>any</B>}
498 [{<I>host</I>|<I>destination destination-wildcard</I>|<B>any</B>}]
499 </DL>
500
501 Extended access-lists:
502
503 <DIV STYLE="margin-left: 4em; text-indent: -2em">
504 <P>{<B>permit</B>|<B>deny</B>} <B>ip</B>
505 {<I>host</I>|<I>source source-wildcard</I>|<B>any</B>}
506 {<I>host</I>|<I>destination destination-wildcard</I>|<B>any</B>} [<B>fragments</B>]
507 <P>{<B>permit</B>|<B>deny</B>} <B>udp</B>
508 {<I>host</I>|<I>source source-wildcard</I>|<B>any</B>}
509 [{<B>eq</B>|<B>neq</B>|<B>gt</B>|<B>lt</B>} <I>port</I>|<B>range</B> <I>from</I> <I>to</I>]
510 {<I>host</I>|<I>destination destination-wildcard</I>|<B>any</B>}
511 [{<B>eq</B>|<B>neq</B>|<B>gt</B>|<B>lt</B>} <I>port</I>|<B>range</B> <I>from</I> <I>to</I>]
512 [<B>fragments</B>]
513 <P>{<B>permit</B>|<B>deny</B>} <B>tcp</B>
514 {<I>host</I>|<I>source source-wildcard</I>|<B>any</B>}
515 [{<B>eq</B>|<B>neq</B>|<B>gt</B>|<B>lt</B>} <I>port</I>|<B>range</B> <I>from</I> <I>to</I>]
516 {<I>host</I>|<I>destination destination-wildcard</I>|<B>any</B>}
517 [{<B>eq</B>|<B>neq</B>|<B>gt</B>|<B>lt</B>} <I>port</I>|<B>range</B> <I>from</I> <I>to</I>]
518 [{<B>established</B>|{<B>match-any</B>|<B>match-all</B>}
519 {<B>+</B>|<B>-</B>}{<B>fin</B>|<B>syn</B>|<B>rst</B>|<B>psh</B>|<B>ack</B>|<B>urg</B>}
520 ...|<B>fragments</B>]
521 </DIV>
522
523 <H3 ID="users">users</H3>
524
525 Usernames and passwords for the command-line interface are stored in
526 this file. The format is <I>username</I><B>:</B><I>password</I> where
527 <I>password</I> may either by plain text, an MD5 digest (prefixed by
528 <B>$1</B><I>salt</I><B>$</B>) or a DES password, distinguished from
529 plain text by the prefix <B>{crypt}</B>.<P>
530
531 The username <B>enable</B> has a special meaning and is used to set
532 the enable password.<P>
533
534 <B>Note:</B> If this file doesn't exist, then anyone who can get to
535 port 23 will be allowed access without a username / password.<P>
536
537 <H3 ID="ip-pool">ip_pool</H3>
538
539 This file is used to configure the IP address pool which user
540 addresses are assigned from. This file should contain either an IP
541 address or a CIDR network per line. e.g.:<P>
542
543 <PRE>
544 192.168.1.1
545 192.168.1.2
546 192.168.1.3
547 192.168.4.0/24
548 172.16.0.0/16
549 10.0.0.0/8
550 </PRE>
551
552 Keep in mind that l2tpns can only handle 65535 connections per
553 process, so don't put more than 65535 IP addresses in the
554 configuration file. They will be wasted.
555
556 <H3 ID="build-garden">build-garden</H3>
557
558 The garden plugin on startup creates a NAT table called "garden" then
559 sources the <B>build-garden</B> script to populate that table. All
560 packets from gardened users will be sent through this table. Example:
561
562 <PRE>
563 iptables -t nat -A garden -p tcp -m tcp --dport 25 -j DNAT --to 192.168.1.1
564 iptables -t nat -A garden -p udp -m udp --dport 53 -j DNAT --to 192.168.1.1
565 iptables -t nat -A garden -p tcp -m tcp --dport 53 -j DNAT --to 192.168.1.1
566 iptables -t nat -A garden -p tcp -m tcp --dport 80 -j DNAT --to 192.168.1.1
567 iptables -t nat -A garden -p tcp -m tcp --dport 110 -j DNAT --to 192.168.1.1
568 iptables -t nat -A garden -p tcp -m tcp --dport 443 -j DNAT --to 192.168.1.1
569 iptables -t nat -A garden -p icmp -m icmp --icmp-type echo-request -j DNAT --to 192.168.1.1
570 iptables -t nat -A garden -p icmp -j ACCEPT
571 iptables -t nat -A garden -j DROP
572 </PRE>
573
574 <H2 ID="ControllingtheProcess">Controlling the Process</H2>
575
576 A running l2tpns process can be controlled in a number of ways. The primary
577 method of control is by the Command-Line Interface (CLI).<P>
578
579 You can also remotely send commands to modules via the nsctl client
580 provided.<P>
581
582 Also, there are a number of signals that l2tpns understands and takes action
583 when it receives them.
584
585 <H3 ID="Command-LineInterface">Command-Line Interface</H3>
586
587 You can access the command line interface by telnet'ing to port 23.
588 There is no IP address restriction, so it's a good idea to firewall
589 this port off from anyone who doesn't need access to it. See
590 <A HREF="#users">users</A> for information on restricting access based
591 on a username and password.<P>
592
593 The CLI gives you real-time control over almost everything in
594 the process. The interface is designed to look like a Cisco
595 device, and supports things like command history, line editing and
596 context sensitive help. This is provided by linking with the
597 <A HREF="http://sourceforge.net/projects/libcli">libcli</A>
598 library. Some general documentation of the interface is
599 <A HREF="http://sourceforge.net/docman/display_doc.php?docid=20501&group_id=79019">
600 here</A>.<P>
601
602 After you have connected to the telnet port (and perhaps logged in), you
603 will be presented with a <I>hostname</I><B>&gt;</B> prompt.<P>
604
605 Enter <EM>help</EM> to get a list of possible commands. A brief
606 overview of the more important commands follows:
607
608 <UL>
609 <LI><B>show session</B><BR>
610 Without specifying a session ID, this will list all tunnels currently
611 connected. If you specify a session ID, you will be given all
612 information on a single tunnel. Note that the full session list can
613 be around 185 columns wide, so you should probably use a wide terminal
614 to see the list properly.<P>
615 The columns listed in the overview are:
616 <TABLE>
617 <TR><TD><B>SID</B></TD><TD>Session ID</TD></TR>
618 <TR><TD><B>TID</B></TD><TD>Tunnel ID - Use with <EM>show tunnel tid</EM></TD></TR>
619 <TR><TD><B>Username</B></TD><TD>The username given in the PPP
620 authentication. If this is *, then LCP authentication has not
621 completed.</TD></TR>
622 <TR><TD><B>IP</B></TD><TD>The IP address given to the session. If
623 this is 0.0.0.0, LCP negotiation has not completed.</TD></TR>
624 <TR><TD><B>I</B></TD><TD>Intercept - Y or N depending on whether the
625 session is being snooped. See <EM>snoop</EM>.</TD></TR>
626 <TR><TD><B>T</B></TD><TD>Throttled - Y or N if the session is
627 currently throttled. See <EM>throttle</EM>.</TD></TR>
628 <TR><TD><B>G</B></TD><TD>Walled Garden - Y or N if the user is
629 trapped in the walled garden. This field is present even if the
630 garden module is not loaded.</TD></TR>
631 <TR><TD><B>opened</B></TD><TD>The number of seconds since the
632 session started</TD></TR>
633 <TR><TD><B>downloaded</B></TD><TD>Number of bytes downloaded by the user</TD></TR>
634 <TR><TD><B>uploaded</B></TD><TD>Number of bytes uploaded by the user</TD></TR>
635 <TR><TD><B>idle</B></TD><TD>The number of seconds since traffic was
636 detected on the session</TD></TR>
637 <TR><TD><B>LAC</B></TD><TD>The IP address of the LAC the session is
638 connected to.</TD></TR>
639 <TR><TD><B>CLI</B></TD><TD>The Calling-Line-Identification field
640 provided during the session setup. This field is generated by the
641 LAC.</TD></TR>
642 </TABLE>
643 <P>
644 </LI>
645
646 <LI><B>show users</B><BR>
647 With no arguments, display a list of currently connected users. If an
648 argument is given, the session details for the given username are
649 displayed.
650 </LI>
651
652 <LI><B>show tunnel</B><BR>
653 This will show all the open tunnels in a summary, or detail on a single
654 tunnel if you give a tunnel id.<P>
655 The columns listed in the overview are:
656 <TABLE>
657 <TR><TD><B>TID</B></TD><TD>Tunnel ID</TD></TR>
658 <TR><TD><B>Hostname</B></TD><TD>The hostname for the tunnel as
659 provided by the LAC. This has no relation to DNS, it is just
660 a text field.</TD></TR>
661 <TR><TD><B>IP</B></TD><TD>The IP address of the LAC</TD></TR>
662 <TR><TD><B>State</B></TD><TD>Tunnel state - Free, Open, Dieing,
663 Opening</TD></TR>
664 <TR><TD><B>Sessions</B></TD><TD>The number of open sessions on the
665 tunnel</TD></TR>
666 </TABLE>
667 <P>
668 </LI>
669
670 <LI><B>show pool</B><BR>
671 Displays the current IP address pool allocation. This will only display
672 addresses that are in use, or are reserved for re-allocation to a
673 disconnected user.<P>
674 If an address is not currently in use, but has been used, then in the User
675 column the username will be shown in square brackets, followed by the time
676 since the address was used:
677 <PRE>
678 IP Address Used Session User
679 192.168.100.6 N [joe.user] 1548s
680 </PRE>
681 <P>
682 </LI>
683
684 <LI><B>show radius</B><BR>
685 Show a summary of the in-use RADIUS sessions. This list should not be very
686 long, as RADIUS sessions should be cleaned up as soon as they are used. The
687 columns listed are:
688 <TABLE>
689 <TR><TD><B>Radius</B></TD><TD>The ID of the RADIUS request. This is
690 sent in the packet to the RADIUS server for identification.</TD></TR>
691 <TR><TD><B>State</B></TD><TD>The state of the request - WAIT, CHAP,
692 AUTH, IPCP, START, STOP, NULL.</TD></TR>
693 <TR><TD><B>Session</B></TD><TD>The session ID that this RADIUS
694 request is associated with</TD></TR>
695 <TR><TD><B>Retry</B></TD><TD>If a response does not appear to the
696 request, it will retry at this time. This is a unix timestamp.</TD></TR>
697 <TR><TD><B>Try</B></TD><TD>Retry count. The RADIUS request is
698 discarded after 3 retries.</TD></TR>
699 </TABLE>
700 <P>
701 </LI>
702
703 <LI><B>show running-config</B><BR>
704 This will list the current running configuration. This is in a format that
705 can either be pasted into the configuration file, or run directly at the
706 command line.
707 <P>
708 </LI>
709
710 <LI><B>show counters</B><BR>
711 Internally, counters are kept of key values, such as bytes and packets
712 transferred, as well as function call counters. This function displays all
713 these counters, and is probably only useful for debugging.<P>
714 You can reset these counters by running <EM>clear counters</EM>.
715 <P>
716 </LI>
717
718 <LI><B>show cluster</B><BR>
719 Show cluster status. Shows the cluster state for this server
720 (Master/Slave), information about known peers and (for slaves) the
721 master IP address, last packet seen and up-to-date status.<P>
722 See <A HREF="#Clustering">Clustering</A> for more information.
723 <P>
724 </LI>
725
726 <LI><B>write memory</B><BR>
727 This will write the current running configuration to the config file
728 <B>startup-config</B>, which will be run on a restart.
729 <P>
730 </LI>
731
732 <LI><B>snoop</B><BR>
733 You must specify a username, IP address and port. All packets for the
734 current session for that username will be forwarded to the given
735 host/port. Specify <EM>no snoop username</EM> to disable interception
736 for the session.<P>
737
738 If you want interception to be permanent, you will have to modify the RADIUS
739 response for the user. See <A HREF="#Interception">Interception</A>.
740 <P>
741 </LI>
742
743 <LI><B>throttle</B><BR>
744 You must specify a username, which will be throttled for the current
745 session. Specify <EM>no throttle username</EM> to disable throttling
746 for the current session.<P>
747
748 If you want throttling to be permanent, you will have to modify the
749 RADIUS response for the user. See <A HREF="#Throttling">Throttling</A>.
750 <P>
751 </LI>
752
753 <LI><B>drop session</B><BR>
754 This will cleanly disconnect a session. You must specify a session id, which
755 you can get from <EM>show session</EM>. This will send a disconnect message
756 to the remote end.
757 <P>
758 </LI>
759
760 <LI><B>drop tunnel</B><BR>
761 This will cleanly disconnect a tunnel, as well as all sessions on that
762 tunnel. It will send a disconnect message for each session individually, and
763 after 10 seconds it will send a tunnel disconnect message.
764 <P>
765 </LI>
766
767 <LI><B>uptime</B><BR>
768 This will show how long the l2tpns process has been running, and the current
769 bandwidth utilization:
770 <PRE>
771 17:10:35 up 8 days, 2212 users, load average: 0.21, 0.17, 0.16
772 Bandwidth: UDP-ETH:6/6 ETH-UDP:13/13 TOTAL:37.6 IN:3033 OUT:2569
773 </PRE>
774 The bandwidth line contains 4 sets of values.<BR>
775 UDP-ETH is the current bandwidth going from the LAC to the ethernet
776 (user uploads), in mbits/sec.<BR>
777 ETH-UDP is the current bandwidth going from ethernet to the LAC (user
778 downloads).<BR>
779 TOTAL is the total aggregate bandwidth in mbits/s.<BR>
780 IN and OUT are packets/per-second going between UDP-ETH and ETH-UDP.
781 <P>
782 These counters are updated every second.
783 <P>
784 </LI>
785
786 <LI><B>configure terminal</B><BR>
787 Enter configuration mode. Use <EM>exit</EM> or ^Z to exit this mode.
788 The following commands are valid in this mode:<P>
789 </LI>
790
791 <LI><B>load plugin</B><BR>
792 Load a plugin. You must specify the plugin name, and it will search in
793 /usr/lib/l2tpns for <EM>plugin</EM>.so. You can unload a loaded plugin with
794 <EM>remove plugin</EM>.
795 <P>
796 </LI>
797
798 <LI><B>set</B><BR>
799 Set a configuration variable. You must specify the variable name, and
800 the value. If the value contains any spaces, you should quote the
801 value with double (") or single (') quotes.<P>
802
803 You can set any <A HREF="#startup-config">startup-config</A> value in
804 this way, although some may require a restart to take effect.<P>
805 </LI>
806 </UL>
807
808 <H3 ID="nsctl">nsctl</H3>
809
810 nsctl allows messages to be passed to plugins.<P>
811
812 Arguments are <EM>command</EM> and optional <EM>args</EM>. See
813 <STRONG>nsctl</STRONG>(8) for more details.<P>
814
815 Built-in command are <EM>load_plugin</EM>, <EM>unload_plugin</EM> and
816 <EM>help</EM>. Any other commands are passed to plugins for processing.
817
818 <H3 ID="Signals">Signals</H3>
819
820 While the process is running, you can send it a few different signals, using
821 the kill command.
822 <PRE>
823 killall -HUP l2tpns
824 </PRE>
825
826 The signals understood are:
827 <DL>
828 <DT>SIGHUP</DT><DD>Reload the config from disk and re-open log file.</DD>
829 <DT>SIGTERM, SIGINT</DT><DD>Stop process. Tunnels and sessions are not
830 terminated. This signal should be used to stop l2tpns on a
831 <A HREF="#Clustering">cluster node</A> where there are other machines to
832 continue handling traffic.</DD>
833 <DT>SIGQUIT</DT><DD>Shut down tunnels and sessions, exit process when
834 complete.</DD>
835 </DL>
836
837 <H2 ID="Throttling">Throttling</H2>
838
839 l2tpns contains support for slowing down user sessions to whatever speed you
840 desire. You must first enable the global setting <EM>throttle_speed</EM>
841 before this will be activated.<P>
842
843 If you wish a session to be throttled permanently, you should set the
844 Vendor-Specific RADIUS value <B>Cisco-Avpair="throttle=yes"</B>, which
845 will be handled by the <EM>autothrottle</EM> module.<P>
846
847 Otherwise, you can enable and disable throttling an active session using
848 the <EM>throttle</EM> CLI command.<P>
849
850 <H2 ID="Interception">Interception</H2>
851
852 You may have to deal with legal requirements to be able to intercept a
853 user's traffic at any time. l2tpns allows you to begin and end interception
854 on the fly, as well as at authentication time.<P>
855
856 When a user is being intercepted, a copy of every packet they send and
857 receive will be sent wrapped in a UDP packet to the IP address and port set
858 in the <EM>snoop_host</EM> and <EM>snoop_port</EM> configuration
859 variables.<P>
860
861 The UDP packet contains just the raw IP frame, with no extra headers.<P>
862
863 To enable interception on a connected user, use the <EM>snoop username</EM>
864 and <EM>no snoop username</EM> CLI commands. These will enable interception
865 immediately.<P>
866
867 If you wish the user to be intercepted whenever they reconnect, you will
868 need to modify the RADIUS response to include the Vendor-Specific value
869 <B>Cisco-Avpair="intercept=yes"</B>. For this feature to be enabled,
870 you need to have the <EM>autosnoop</EM> module loaded.<P>
871
872 <H2 ID="Authentication">Authentication</H2>
873
874 Whenever a session connects, it is not fully set up until authentication is
875 completed. The remote end must send a PPP CHAP or PPP PAP authentication
876 request to l2tpns.<P>
877
878 This request is sent to the RADIUS server, which will hopefully respond with
879 Auth-Accept or Auth-Reject.<P>
880
881 If Auth-Accept is received, the session is set up and an IP address is
882 assigned. The RADIUS server can include a Framed-IP-Address field in the
883 reply, and that address will be assigned to the client. It can also include
884 specific DNS servers, and a Framed-Route if that is required.<P>
885
886 If Auth-Reject is received, then the client is sent a PPP AUTHNAK packet,
887 at which point they should disconnect. The exception to this is when the
888 walled garden module is loaded, in which case the user still receives the
889 PPP AUTHACK, but their session is flagged as being a garden'd user, and they
890 should not receive any service.<P>
891
892 The RADIUS reply can also contain a Vendor-Specific attribute called
893 Cisco-Avpair. This field is a freeform text field that most Cisco
894 devices understand to contain configuration instructions for the session. In
895 the case of l2tpns it is expected to be of the form
896 <PRE>
897 key=value,key2=value2,key3=value3,key<EM>n</EM>=<EM>value</EM>
898 </PRE>
899
900 Each key-value pair is separated and passed to any modules loaded. The
901 <EM>autosnoop</EM> and <EM>autothrottle</EM> understand the keys
902 <EM>intercept</EM> and <EM>throttle</EM> respectively. For example, to have
903 a user who is to be throttled and intercepted, the Cisco-Avpair value should
904 contain:
905 <PRE>
906 intercept=yes,throttle=yes
907 </PRE>
908
909 <H2 ID="Plugins">Plugins</H2>
910
911 So as to make l2tpns as flexible as possible (I know the core code is pretty
912 difficult to understand), it includes a plugin API, which you can use to
913 hook into certain events.<P>
914
915 There are a few example modules included - autosnoop, autothrottle and
916 garden.<P>
917
918 When an event happens that has a hook, l2tpns looks for a predefined
919 function name in every loaded module, and runs them in the order the modules
920 were loaded.<P>
921
922 The function should return <B>PLUGIN_RET_OK</B> if it is all OK. If it returns
923 <B>PLUGIN_RET_STOP</B>, then it is assumed to have worked, but that no further
924 modules should be run for this event.<P>
925 A return of <B>PLUGIN_RET_ERROR</B> means that this module failed, and
926 no further processing should be done for this event. <EM>Use this with care.</EM>
927
928 Every event function called takes a specific structure named
929 param_<EM>event</EM>, which varies in content with each event. The
930 function name for each event will be <B>plugin_<EM>event</EM></B>,
931 so for the event <EM>timer</EM>, the function declaration should look like:
932 <PRE>
933 int plugin_timer(struct param_timer *data);
934 </PRE>
935
936 A list of the available events follows, with a list of all the fields in the
937 supplied structure:
938 <TABLE CELLSPACING=0 CELLPADDING=0><TR BGCOLOR=LIGHTGREEN><TD>
939 <TABLE CELLSPACING=1 CELLPADDING=3>
940 <TR BGCOLOR=LIGHTGREEN><TH><B>Event</B></TH><TH><B>Description</B></TH><TH><B>Parameters</B></TH></TR>
941 <TR VALIGN=TOP BGCOLOR=WHITE><TD><B>pre_auth</B></TD>
942 <TD>This is called after a RADIUS response has been
943 received, but before it has been processed by the
944 code. This will allow you to modify the response in
945 some way.
946 </TD>
947 <TD>
948 <DL>
949 <DT>t<DD>Tunnel
950 <DT>s<DD>Session
951 <DT>username
952 <DT>password
953 <DT>protocol<DD>0xC023 for PAP, 0xC223 for CHAP
954 <DT>continue_auth<DD>Set to 0 to stop processing authentication modules
955 </DL>
956 </TD>
957 </TR>
958 <TR VALIGN=TOP BGCOLOR=WHITE><TD><B>post_auth</B></TD>
959 <TD>This is called after a RADIUS response has been
960 received, and the basic checks have been performed. This
961 is what the garden module uses to force authentication
962 to be accepted.
963 </TD>
964 <TD>
965 <DL>
966 <DT>t<DD>Tunnel
967 <DT>s<DD>Session
968 <DT>username
969 <DT>auth_allowed<DD>This is already set to true or
970 false depending on whether authentication has been
971 allowed so far. You can set this to 1 or 0 to force
972 allow or disallow authentication
973 <DT>protocol<DD>0xC023 for PAP, 0xC223 for CHAP
974 </DL>
975 </TD>
976 </TR>
977 <TR VALIGN=TOP BGCOLOR=WHITE><TD><B>packet_rx</B></TD>
978 <TD>This is called whenever a session receives a
979 packet. <FONT COLOR=RED>Use this sparingly, as this will
980 seriously slow down the system.</FONT>
981 </TD>
982 <TD>
983 <DL>
984 <DT>t<DD>Tunnel
985 <DT>s<DD>Session
986 <DT>buf<DD>The raw packet data
987 <DT>len<DD>The length of buf
988 </DL>
989 </TD>
990 </TR>
991 <TR VALIGN=TOP BGCOLOR=WHITE><TD><B>packet_tx</B></TD>
992 <TD>This is called whenever a session sends a
993 packet. <FONT COLOR=RED>Use this sparingly, as this will
994 seriously slow down the system.</FONT>
995 </TD>
996 <TD>
997 <DL>
998 <DT>t<DD>Tunnel
999 <DT>s<DD>Session
1000 <DT>buf<DD>The raw packet data
1001 <DT>len<DD>The length of buf
1002 </DL>
1003 </TD>
1004 </TR>
1005 <TR VALIGN=TOP BGCOLOR=WHITE><TD><B>timer</B></TD>
1006 <TD>This is run every second, no matter what is happening.
1007 This is called from a signal handler, so make sure anything
1008 you do is reentrant.
1009 </TD>
1010 <TD>
1011 <DL>
1012 <DT>time_now<DD>The current unix timestamp
1013 </DL>
1014 </TD>
1015 </TR>
1016 <TR VALIGN=TOP BGCOLOR=WHITE><TD><B>new_session</B></TD>
1017 <TD>This is called after a session is fully set up. The
1018 session is now ready to handle traffic.
1019 </TD>
1020 <TD>
1021 <DL>
1022 <DT>t<DD>Tunnel
1023 <DT>s<DD>Session
1024 </DL>
1025 </TD>
1026 </TR>
1027 <TR VALIGN=TOP BGCOLOR=WHITE><TD><B>kill_session</B></TD>
1028 <TD>This is called when a session is about to be shut down.
1029 This may be called multiple times for the same session.
1030 </TD>
1031 <TD>
1032 <DL>
1033 <DT>t<DD>Tunnel
1034 <DT>s<DD>Session
1035 </DL>
1036 </TD>
1037 </TR>
1038 <TR VALIGN=TOP BGCOLOR=WHITE><TD><B>radius_response</B></TD>
1039 <TD>This is called whenever a RADIUS response includes a
1040 Cisco-Avpair value. The value is split up into
1041 <EM>key=value</EM> pairs, and each is processed through all
1042 modules.
1043 </TD>
1044 <TD>
1045 <DL>
1046 <DT>t<DD>Tunnel
1047 <DT>s<DD>Session
1048 <DT>key
1049 <DT>value
1050 </DL>
1051 </TD>
1052 </TR>
1053 <TR VALIGN=TOP BGCOLOR=WHITE><TD><B>radius_reset</B></TD>
1054 <TD>This is called whenever a RADIUS CoA request is
1055 received to reset any options to default values before
1056 the new values are applied.
1057 </TD>
1058 <TD>
1059 <DL>
1060 <DT>t<DD>Tunnel
1061 <DT>s<DD>Session
1062 </DL>
1063 </TD>
1064 </TR>
1065 <TR VALIGN=TOP BGCOLOR=WHITE><TD><B>control</B></TD>
1066 <TD>This is called in whenever a nsctl packet is received.
1067 This should handle the packet and form a response if
1068 required.
1069 </TD>
1070 <TD>
1071 <DL>
1072 <DT>iam_master<DD>Cluster master status
1073 <DT>argc<DD>The number of arguments
1074 <DT>argv<DD>Arguments
1075 <DT>response<DD>Return value: NSCTL_RES_OK or NSCTL_RES_ERR
1076 <DT>additional<DD>Extended response text
1077 </DL>
1078 </TD>
1079 </TR>
1080 </TABLE>
1081 </TD></TR></TABLE>
1082
1083 <H2 ID="WalledGarden">Walled Garden</H2>
1084
1085 Walled Garden is implemented so that you can provide perhaps limited service
1086 to sessions that incorrectly authenticate.<P>
1087
1088 Whenever a session provides incorrect authentication, and the
1089 RADIUS server responds with Auth-Reject, the walled garden module
1090 (if loaded) will force authentication to succeed, but set the flag
1091 <EM>garden</EM> in the session structure, and adds an iptables rule to
1092 the <B>garden_users</B> chain to force all packets for the session's IP
1093 address to traverse the <B>garden</B> chain.<P>
1094
1095 This doesn't <EM>just work</EM>. To set this all up, you will to
1096 setup the <B>garden</B> nat table with the
1097 <A HREF="#build-garden">build-garden</A> script with rules to limit
1098 user's traffic. For example, to force all traffic except DNS to be
1099 forwarded to 192.168.1.1, add these entries to your
1100 <EM>build-garden</EM>:
1101 <PRE>
1102 iptables -t nat -A garden -p tcp --dport ! 53 -j DNAT --to 192.168.1.1
1103 iptables -t nat -A garden -p udp --dport ! 53 -j DNAT --to 192.168.1.1
1104 </PRE>
1105
1106 l2tpns will add entries to the garden_users chain as appropriate.<P>
1107
1108 You can check the amount of traffic being captured using the following
1109 command:
1110 <PRE>
1111 iptables -t nat -L garden -nvx
1112 </PRE>
1113
1114 <H2 ID="Filtering">Filtering</H2>
1115
1116 Sessions may be filtered by specifying <B>Filter-Id</B> attributes in
1117 the RADIUS reply. <I>filter</I>.<B>in</B> specifies that the named
1118 access-list <I>filter</I> should be applied to traffic from the
1119 customer, <I>filter</I>.<B>out</B> specifies a list for traffic to the
1120 customer.
1121
1122 <H2 ID="Clustering">Clustering</H2>
1123
1124 An l2tpns cluster consists of of one* or more servers configured with
1125 the same configuration, notably the multicast <B>cluster_address</B>.<P>
1126
1127 *A stand-alone server is simply a degraded cluster.<P>
1128
1129 Initially servers come up as cluster slaves, and periodically (every
1130 <B>cluster_hb_interval</B>/10 seconds) send out ping packets
1131 containing the start time of the process to the multicast
1132 <B>cluster_address</B>.<P>
1133
1134 A cluster master sends heartbeat rather than ping packets, which
1135 contain those session and tunnel changes since the last heartbeat.<P>
1136
1137 When a slave has not seen a heartbeat within
1138 <B>cluster_hb_timeout</B>/10 seconds it "elects" a new master by
1139 examining the list of peers it has seen pings from and determines
1140 which of these and itself is the "best" candidate to be master.
1141 "Best" in this context means the server with the highest uptime (the
1142 highest IP address is used as a tie-breaker in the case of equal
1143 uptimes).<P>
1144
1145 After discovering a master, and determining that it is up-to-date (has
1146 seen an update for all in-use sessions and tunnels from heartbeat
1147 packets) will raise a route (see <A HREF="#Routing">Routing</A>) for
1148 the <B>bind_address</B> and for all addresses/networks in
1149 <B>ip_pool</B>. Any packets recieved by the slave which would alter
1150 the session state, as well as packets for throttled or gardened
1151 sessions are forwarded to the master for handling. In addition, byte
1152 counters for session traffic are periodically forwarded.<P>
1153
1154 A master, when determining that it has at least one up-to-date slave
1155 will drop all routes (raising them again if all slaves disappear) and
1156 subsequently handle only packets forwarded to it by the slaves.<P>
1157
1158 *Configurable with <B>cluster_master_min_adv</B><P>
1159
1160 Multiple clusters can be run on the same network by just using different
1161 multicast <B>cluster_address</B>. However, for a given host to be part
1162 of multiple clusters without mixing the clusters,
1163 <B>cluster_port</B> must be different for each cluster.<B>
1164
1165 <H2 ID="Routing">Routing</H2>
1166 If you are running a single instance, you may simply statically route
1167 the IP pools to the <B>bind_address</B> (l2tpns will send a gratuitous
1168 arp).<P>
1169
1170 For a cluster, configure the members as BGP neighbours on your router
1171 and configure multi-path load-balancing. Cisco uses "maximum-paths
1172 ibgp" for IBGP. If this is not supported by your IOS revision, you
1173 can use "maximum-paths" (which works for EBGP) and set
1174 <B>as_number</B> to a private value such as 64512.<P>
1175
1176 <H2 ID="Performance">Performance</H2>
1177
1178 Performance is great.<P>
1179
1180 I'd like to include some pretty graphs here that show a linear performance
1181 increase, with no impact by number of connected sessions.<P>
1182
1183 That's really what it looks like.<P>
1184
1185 <BR>
1186 David Parrish<BR>
1187 <A HREF="mailto:l2tpns-users@lists.sourceforge.net?subject=L2TPNS%20Documentation">l2tpns-users@lists.sourceforge.net</A>
1188 </BODY>
1189 </HTML>