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