update docs
[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 is half of a complete L2TP implementation. It supports only the
64 LNS side of the connection.<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>primary_dns</B> (ip address)
188 <LI><B>secondary_dns</B> (ip address)<BR>
189 Whenever a PPP connection is established, DNS servers will be sent to the
190 user, both a primary and a secondary. If either is set to 0.0.0.0, then that
191 one will not be sent.
192 </LI>
193
194 <LI><B>primary_radius</B> (ip address)
195 <LI><B>secondary_radius</B> (ip address)<BR>
196 Sets the RADIUS servers used for both authentication and accounting.
197 If the primary server does not respond, then the secondary RADIUS
198 server will be tried.<br>
199 <strong>Note:</strong> in addition to the source IP address and
200 identifier, the RADIUS server <strong>must</strong> include the source
201 port when detecting duplicates to supress (in order to cope with a
202 large number of sessions comming on-line simultaneously l2tpns uses a
203 set of udp sockets, each with a seperate identifier).
204 </LI>
205
206 <LI><B>primary_radius_port</B> (short)
207 <LI><B>secondary_radius_port</B> (short)<BR>
208 Sets the authentication ports for the primary and secondary RADIUS
209 servers. The accounting port is one more than the authentication
210 port. If no RADIUS ports are given, the authentication port defaults
211 to 1645, and the accounting port to 1646.
212 </LI>
213
214 <LI><B>radius_accounting</B> (boolean)<BR>
215 If set to true, then RADIUS accounting packets will be sent. This
216 means that a Start record will be sent when the session is
217 successfully authenticated, and a Stop record will be sent when the
218 session is closed.
219 </LI>
220
221 <LI><B>radius_secret</B> (string)<BR>
222 This secret will be used in all RADIUS queries. If this is not set then
223 RADIUS queries will fail.
224 </LI>
225
226 <LI><B>bind_address</B> (ip address)<BR>
227 When the tun interface is created, it is assigned the address
228 specified here. If no address is given, 1.1.1.1 is used. Packets
229 containing user traffic should be routed via this address if given,
230 otherwise the primary address of the machine.
231 </LI>
232
233 <LI><B>peer_address</B> (ip address)<BR>
234 Address to send to clients as the default gateway.
235 </L1>
236
237 <LI><B>send_garp</B> (boolean)<BR>
238 Determines whether or not to send a gratuitous ARP for the
239 bind_address when the server is ready to handle traffic (default:
240 true).<BR>
241 This value is ignored if BGP is configured.
242 </LI>
243
244 <LI><B>throttle_speed</B> (int)<BR>
245 Sets the default speed (in kbits/s) which sessions will be limited to.
246 If this is set to 0, then throttling will not be used at all. Note:
247 You can set this by the CLI, but changes will not affect currently
248 connected users.
249 </LI>
250
251 <LI><B>throttle_buckets</B> (int)<BR>
252 Number of token buckets to allocate for throttling. Each throttled
253 session requires two buckets (in and out).
254 </LI>
255
256 <LI><B>accounting_dir</B> (string)<BR>
257 If set to a directory, then every 5 minutes the current usage for
258 every connected use will be dumped to a file in this directory. Each
259 file dumped begins with a header, where each line is prefixed by #.
260 Following the header is a single line for every connected user, fields
261 separated by a space.<BR> The fields are username, ip, qos,
262 uptxoctets, downrxoctets. The qos field is 1 if a standard user, and
263 2 if the user is throttled.
264 </LI>
265
266 <LI><B>setuid</B> (int)<BR>
267 After starting up and binding the interface, change UID to this. This
268 doesn't work properly.
269 </LI>
270
271 <LI><B>dump_speed</B> (boolean)<BR>
272 If set to true, then the current bandwidth utilization will be logged every
273 second. Even if this is disabled, you can see this information by running
274 the <EM>uptime</EM> command on the CLI.
275 </LI>
276
277 <LI><B>cleanup_interval</B> (int)<BR>
278 Interval between regular cleanups (in seconds).
279 </LI>
280
281 <LI><B>multi_read_count</B> (int)<BR>
282 Number of packets to read off each of the UDP and TUN fds when
283 returned as readable by select (default: 10). Avoids incurring the
284 unnecessary system call overhead of select on busy servers.
285 </LI>
286
287 <LI><B>scheduler_fifo</B> (boolean)<BR>
288 Sets the scheduling policy for the l2tpns process to SCHED_FIFO. This
289 causes the kernel to immediately preempt any currently running SCHED_OTHER
290 (normal) process in favour of l2tpns when it becomes runnable.
291 Ignored on uniprocessor systems.
292 </LI>
293
294 <LI><B>lock_pages</B> (boolean)<BR>
295 Keep all pages mapped by the l2tpns process in memory.
296 </LI>
297
298 <LI><B>icmp_rate</B> (int)<BR>
299 Maximum number of host unreachable ICMP packets to send per second.
300 </LI>
301
302 <LI><B>packet_limit</B> (int><BR>
303 Maximum number of packets of downstream traffic to be handled each
304 tenth of a second per session. If zero, no limit is applied (default:
305 0). Intended as a DoS prevention mechanism and not a general
306 throttling control (packets are dropped, not queued).
307 </LI>
308
309 <LI><B>cluster_address</B> (ip address)<BR>
310 Multicast cluster address (default: 239.192.13.13). See the section
311 on <A HREF="#Clustering">Clustering</A> for more information.
312 </LI>
313
314 <LI><B>cluster_interface</B> (string)<BR>
315 Interface for cluster packets (default: eth0).
316 </LI>
317
318 <LI><B>cluster_hb_interval</B> (int)<BR>
319 Interval in tenths of a second between cluster heartbeat/pings.
320 </LI>
321
322 <LI><B>cluster_hb_timeout</B> (int)<BR>
323 Cluster heartbeat timeout in tenths of a second. A new master will be
324 elected when this interval has been passed without seeing a heartbeat
325 from the master.
326 </LI>
327 </UL>
328
329 <P>BGP routing configuration is entered by the command:
330 The routing configuration section is entered by the command
331 <DL><DD><B>router bgp</B> <I>as</I></DL>
332 where <I>as</I> specifies the local AS number.
333
334 <P>Subsequent lines prefixed with
335 <DL><DD><B>neighbour</B> <I>peer</I></DL>
336 define the attributes of BGP neighhbours. Valid commands are:
337 <DL>
338 <DD><B>neighbour</B> <I>peer</I> <B>remote-as</B> <I>as</I>
339 <DD><B>neighbout</B> <I>peer</I> <B>timers</B> <I>keepalive hold</I>
340 </DL>
341
342 Where <I>peer</I> specifies the BGP neighbour as either a hostname or
343 IP address, <I>as</I> is the remote AS number and <I>keepalive</I>,
344 <I>hold</I> are the timer values in seconds.
345
346 <P>Named access-lists are configured using one of the commands:
347 <DL>
348 <DD><B>ip access-list standard</B> <I>name</I>
349 <DD><B>ip access-list extended</B> <I>name</I>
350 </DL>
351
352 <P>Subsequent lines prefixed with <B>permit</B> or <B>deny</B>
353 define the body of the access-list. Standard access-list syntax:
354 <DL>
355 <DD>{<B>permit</B>|<B>deny</B>}
356 {<I>host</I>|<I>source source-wildcard</I>|<B>any</B>}
357 [{<I>host</I>|<I>destination destination-wildcard</I>|<B>any</B>}]
358 </DL>
359
360 Extended access-lists:
361
362 <DIV STYLE="margin-left: 4em; text-indent: -2em">
363 <P>{<B>permit</B>|<B>deny</B>} <B>ip</B>
364 {<I>host</I>|<I>source source-wildcard</I>|<B>any</B>}
365 {<I>host</I>|<I>destination destination-wildcard</I>|<B>any</B>} [<B>fragments</B>]
366 <P>{<B>permit</B>|<B>deny</B>} <B>udp</B>
367 {<I>host</I>|<I>source source-wildcard</I>|<B>any</B>}
368 [{<B>eq</B>|<B>neq</B>|<B>gt</B>|<B>lt</B>} <I>port</I>|<B>range</B> <I>from</I> <I>to</I>]
369 {<I>host</I>|<I>destination destination-wildcard</I>|<B>any</B>}
370 [{<B>eq</B>|<B>neq</B>|<B>gt</B>|<B>lt</B>} <I>port</I>|<B>range</B> <I>from</I> <I>to</I>]
371 [<B>fragments</B>]
372 <P>{<B>permit</B>|<B>deny</B>} <B>tcp</B>
373 {<I>host</I>|<I>source source-wildcard</I>|<B>any</B>}
374 [{<B>eq</B>|<B>neq</B>|<B>gt</B>|<B>lt</B>} <I>port</I>|<B>range</B> <I>from</I> <I>to</I>]
375 {<I>host</I>|<I>destination destination-wildcard</I>|<B>any</B>}
376 [{<B>eq</B>|<B>neq</B>|<B>gt</B>|<B>lt</B>} <I>port</I>|<B>range</B> <I>from</I> <I>to</I>]
377 [{<B>established</B>|{<B>match-any</B>|<B>match-all</B>}
378 {<B>+</B>|<B>-</B>}{<B>fin</B>|<B>syn</B>|<B>rst</B>|<B>psh</B>|<B>ack</B>|<B>urg</B>}
379 ...|<B>fragments</B>]
380 </DIV>
381
382 <H3 ID="users">users</H3>
383
384 Usernames and passwords for the command-line interface are stored in
385 this file. The format is <I>username</I><B>:</B><I>password</I> where
386 <I>password</I> may either by plain text, an MD5 digest (prefixed by
387 <B>$1</B><I>salt</I><B>$</B>) or a DES password, distinguished from
388 plain text by the prefix <B>{crypt}</B>.<P>
389
390 The username <B>enable</B> has a special meaning and is used to set
391 the enable password.<P>
392
393 <B>Note:</B> If this file doesn't exist, then anyone who can get to
394 port 23 will be allowed access without a username / password.<P>
395
396 <H3 ID="ip-pool">ip_pool</H3>
397
398 This file is used to configure the IP address pool which user
399 addresses are assigned from. This file should contain either an IP
400 address or a CIDR network per line. e.g.:<P>
401
402 <PRE>
403 192.168.1.1
404 192.168.1.2
405 192.168.1.3
406 192.168.4.0/24
407 172.16.0.0/16
408 10.0.0.0/8
409 </PRE>
410
411 Keep in mind that l2tpns can only handle 65535 connections per
412 process, so don't put more than 65535 IP addresses in the
413 configuration file. They will be wasted.
414
415 <H3 ID="build-garden">build-garden</H3>
416
417 The garden plugin on startup creates a NAT table called "garden" then
418 sources the <B>build-garden</B> script to populate that table. All
419 packets from gardened users will be sent through this table. Example:
420
421 <PRE>
422 iptables -t nat -A garden -p tcp -m tcp --dport 25 -j DNAT --to 192.168.1.1
423 iptables -t nat -A garden -p udp -m udp --dport 53 -j DNAT --to 192.168.1.1
424 iptables -t nat -A garden -p tcp -m tcp --dport 53 -j DNAT --to 192.168.1.1
425 iptables -t nat -A garden -p tcp -m tcp --dport 80 -j DNAT --to 192.168.1.1
426 iptables -t nat -A garden -p tcp -m tcp --dport 110 -j DNAT --to 192.168.1.1
427 iptables -t nat -A garden -p tcp -m tcp --dport 443 -j DNAT --to 192.168.1.1
428 iptables -t nat -A garden -p icmp -m icmp --icmp-type echo-request -j DNAT --to 192.168.1.1
429 iptables -t nat -A garden -p icmp -j ACCEPT
430 iptables -t nat -A garden -j DROP
431 </PRE>
432
433 <H2 ID="ControllingtheProcess">Controlling the Process</H2>
434
435 A running l2tpns process can be controlled in a number of ways. The primary
436 method of control is by the Command-Line Interface (CLI).<P>
437
438 You can also remotely send commands to modules via the nsctl client
439 provided.<P>
440
441 Also, there are a number of signals that l2tpns understands and takes action
442 when it receives them.
443
444 <H3 ID="Command-LineInterface">Command-Line Interface</H3>
445
446 You can access the command line interface by telnet'ing to port 23.
447 There is no IP address restriction, so it's a good idea to firewall
448 this port off from anyone who doesn't need access to it. See
449 <A HREF="#users">users</A> for information on restricting access based
450 on a username and password.<P>
451
452 The CLI gives you real-time control over almost everything in
453 the process. The interface is designed to look like a Cisco
454 device, and supports things like command history, line editing and
455 context sensitive help. This is provided by linking with the
456 <A HREF="http://sourceforge.net/projects/libcli">libcli</A>
457 library. Some general documentation of the interface is
458 <A HREF="http://sourceforge.net/docman/display_doc.php?docid=20501&group_id=79019">
459 here</A>.<P>
460
461 After you have connected to the telnet port (and perhaps logged in), you
462 will be presented with a <I>hostname</I><B>&gt;</B> prompt.<P>
463
464 Enter <EM>help</EM> to get a list of possible commands. A brief
465 overview of the more important commands follows:
466
467 <UL>
468 <LI><B>show session</B><BR>
469 Without specifying a session ID, this will list all tunnels currently
470 connected. If you specify a session ID, you will be given all
471 information on a single tunnel. Note that the full session list can
472 be around 185 columns wide, so you should probably use a wide terminal
473 to see the list properly.<P>
474 The columns listed in the overview are:
475 <TABLE>
476 <TR><TD><B>SID</B></TD><TD>Session ID</TD></TR>
477 <TR><TD><B>TID</B></TD><TD>Tunnel ID - Use with <EM>show tunnel tid</EM></TD></TR>
478 <TR><TD><B>Username</B></TD><TD>The username given in the PPP
479 authentication. If this is *, then LCP authentication has not
480 completed.</TD></TR>
481 <TR><TD><B>IP</B></TD><TD>The IP address given to the session. If
482 this is 0.0.0.0, LCP negotiation has not completed.</TD></TR>
483 <TR><TD><B>I</B></TD><TD>Intercept - Y or N depending on whether the
484 session is being snooped. See <EM>snoop</EM>.</TD></TR>
485 <TR><TD><B>T</B></TD><TD>Throttled - Y or N if the session is
486 currently throttled. See <EM>throttle</EM>.</TD></TR>
487 <TR><TD><B>G</B></TD><TD>Walled Garden - Y or N if the user is
488 trapped in the walled garden. This field is present even if the
489 garden module is not loaded.</TD></TR>
490 <TR><TD><B>opened</B></TD><TD>The number of seconds since the
491 session started</TD></TR>
492 <TR><TD><B>downloaded</B></TD><TD>Number of bytes downloaded by the user</TD></TR>
493 <TR><TD><B>uploaded</B></TD><TD>Number of bytes uploaded by the user</TD></TR>
494 <TR><TD><B>idle</B></TD><TD>The number of seconds since traffic was
495 detected on the session</TD></TR>
496 <TR><TD><B>LAC</B></TD><TD>The IP address of the LAC the session is
497 connected to.</TD></TR>
498 <TR><TD><B>CLI</B></TD><TD>The Calling-Line-Identification field
499 provided during the session setup. This field is generated by the
500 LAC.</TD></TR>
501 </TABLE>
502 <P>
503 </LI>
504
505 <LI><B>show users</B><BR>
506 With no arguments, display a list of currently connected users. If an
507 argument is given, the session details for the given username are
508 displayed.
509 </LI>
510
511 <LI><B>show tunnel</B><BR>
512 This will show all the open tunnels in a summary, or detail on a single
513 tunnel if you give a tunnel id.<P>
514 The columns listed in the overview are:
515 <TABLE>
516 <TR><TD><B>TID</B></TD><TD>Tunnel ID</TD></TR>
517 <TR><TD><B>Hostname</B></TD><TD>The hostname for the tunnel as
518 provided by the LAC. This has no relation to DNS, it is just
519 a text field.</TD></TR>
520 <TR><TD><B>IP</B></TD><TD>The IP address of the LAC</TD></TR>
521 <TR><TD><B>State</B></TD><TD>Tunnel state - Free, Open, Dieing,
522 Opening</TD></TR>
523 <TR><TD><B>Sessions</B></TD><TD>The number of open sessions on the
524 tunnel</TD></TR>
525 </TABLE>
526 <P>
527 </LI>
528
529 <LI><B>show pool</B><BR>
530 Displays the current IP address pool allocation. This will only display
531 addresses that are in use, or are reserved for re-allocation to a
532 disconnected user.<P>
533 If an address is not currently in use, but has been used, then in the User
534 column the username will be shown in square brackets, followed by the time
535 since the address was used:
536 <PRE>
537 IP Address Used Session User
538 192.168.100.6 N [joe.user] 1548s
539 </PRE>
540 <P>
541 </LI>
542
543 <LI><B>show radius</B><BR>
544 Show a summary of the in-use RADIUS sessions. This list should not be very
545 long, as RADIUS sessions should be cleaned up as soon as they are used. The
546 columns listed are:
547 <TABLE>
548 <TR><TD><B>Radius</B></TD><TD>The ID of the RADIUS request. This is
549 sent in the packet to the RADIUS server for identification.</TD></TR>
550 <TR><TD><B>State</B></TD><TD>The state of the request - WAIT, CHAP,
551 AUTH, IPCP, START, STOP, NULL.</TD></TR>
552 <TR><TD><B>Session</B></TD><TD>The session ID that this RADIUS
553 request is associated with</TD></TR>
554 <TR><TD><B>Retry</B></TD><TD>If a response does not appear to the
555 request, it will retry at this time. This is a unix timestamp.</TD></TR>
556 <TR><TD><B>Try</B></TD><TD>Retry count. The RADIUS request is
557 discarded after 3 retries.</TD></TR>
558 </TABLE>
559 <P>
560 </LI>
561
562 <LI><B>show running-config</B><BR>
563 This will list the current running configuration. This is in a format that
564 can either be pasted into the configuration file, or run directly at the
565 command line.
566 <P>
567 </LI>
568
569 <LI><B>show counters</B><BR>
570 Internally, counters are kept of key values, such as bytes and packets
571 transferred, as well as function call counters. This function displays all
572 these counters, and is probably only useful for debugging.<P>
573 You can reset these counters by running <EM>clear counters</EM>.
574 <P>
575 </LI>
576
577 <LI><B>show cluster</B><BR>
578 Show cluster status. Shows the cluster state for this server
579 (Master/Slave), information about known peers and (for slaves) the
580 master IP address, last packet seen and up-to-date status.<P>
581 See <A HREF="#Clustering">Clustering</A> for more information.
582 <P>
583 </LI>
584
585 <LI><B>write memory</B><BR>
586 This will write the current running configuration to the config file
587 <B>startup-config</B>, which will be run on a restart.
588 <P>
589 </LI>
590
591 <LI><B>snoop</B><BR>
592 You must specify a username, IP address and port. All packets for the
593 current session for that username will be forwarded to the given
594 host/port. Specify <EM>no snoop username</EM> to disable interception
595 for the session.<P>
596
597 If you want interception to be permanent, you will have to modify the RADIUS
598 response for the user. See <A HREF="#Interception">Interception</A>.
599 <P>
600 </LI>
601
602 <LI><B>throttle</B><BR>
603 You must specify a username, which will be throttled for the current
604 session. Specify <EM>no throttle username</EM> to disable throttling
605 for the current session.<P>
606
607 If you want throttling to be permanent, you will have to modify the
608 RADIUS response for the user. See <A HREF="#Throttling">Throttling</A>.
609 <P>
610 </LI>
611
612 <LI><B>drop session</B><BR>
613 This will cleanly disconnect a session. You must specify a session id, which
614 you can get from <EM>show session</EM>. This will send a disconnect message
615 to the remote end.
616 <P>
617 </LI>
618
619 <LI><B>drop tunnel</B><BR>
620 This will cleanly disconnect a tunnel, as well as all sessions on that
621 tunnel. It will send a disconnect message for each session individually, and
622 after 10 seconds it will send a tunnel disconnect message.
623 <P>
624 </LI>
625
626 <LI><B>uptime</B><BR>
627 This will show how long the l2tpns process has been running, and the current
628 bandwidth utilization:
629 <PRE>
630 17:10:35 up 8 days, 2212 users, load average: 0.21, 0.17, 0.16
631 Bandwidth: UDP-ETH:6/6 ETH-UDP:13/13 TOTAL:37.6 IN:3033 OUT:2569
632 </PRE>
633 The bandwidth line contains 4 sets of values.<BR>
634 UDP-ETH is the current bandwidth going from the LAC to the ethernet
635 (user uploads), in mbits/sec.<BR>
636 ETH-UDP is the current bandwidth going from ethernet to the LAC (user
637 downloads).<BR>
638 TOTAL is the total aggregate bandwidth in mbits/s.<BR>
639 IN and OUT are packets/per-second going between UDP-ETH and ETH-UDP.
640 <P>
641 These counters are updated every second.
642 <P>
643 </LI>
644
645 <LI><B>configure terminal</B><BR>
646 Enter configuration mode. Use <EM>exit</EM> or ^Z to exit this mode.
647 The following commands are valid in this mode:<P>
648 </LI>
649
650 <LI><B>load plugin</B><BR>
651 Load a plugin. You must specify the plugin name, and it will search in
652 /usr/lib/l2tpns for <EM>plugin</EM>.so. You can unload a loaded plugin with
653 <EM>remove plugin</EM>.
654 <P>
655 </LI>
656
657 <LI><B>set</B><BR>
658 Set a configuration variable. You must specify the variable name, and
659 the value. If the value contains any spaces, you should quote the
660 value with double (") or single (') quotes.<P>
661
662 You can set any <A HREF="#startup-config">startup-config</A> value in
663 this way, although some may require a restart to take effect.<P>
664 </LI>
665 </UL>
666
667 <H3 ID="nsctl">nsctl</H3>
668
669 nsctl allows messages to be passed to plugins.<P>
670
671 Arguments are <EM>command</EM> and optional <EM>args</EM>. See
672 <STRONG>nsctl</STRONG>(8) for more details.<P>
673
674 Built-in command are <EM>load_plugin</EM>, <EM>unload_plugin</EM> and
675 <EM>help</EM>. Any other commands are passed to plugins for processing.
676
677 <H3 ID="Signals">Signals</H3>
678
679 While the process is running, you can send it a few different signals, using
680 the kill command.
681 <PRE>
682 killall -HUP l2tpns
683 </PRE>
684
685 The signals understood are:
686 <UL>
687 <LI>SIGHUP - Reload the config from disk and re-open log file</LI>
688 <LI>SIGTERM / SIGINT - Shut down.</LI>
689 <LI>SIGQUIT - Shut down cleanly. This will send a disconnect message for
690 every active session and tunnel before shutting down.</LI>
691 </UL>
692
693 <H2 ID="Throttling">Throttling</H2>
694
695 l2tpns contains support for slowing down user sessions to whatever speed you
696 desire. You must first enable the global setting <EM>throttle_speed</EM>
697 before this will be activated.<P>
698
699 If you wish a session to be throttled permanently, you should set the
700 Vendor-Specific RADIUS value <B>Cisco-Avpair="throttle=yes"</B>, which
701 will be handled by the <EM>autothrottle</EM> module.<P>
702
703 Otherwise, you can enable and disable throttling an active session using
704 the <EM>throttle</EM> CLI command.<P>
705
706 <H2 ID="Interception">Interception</H2>
707
708 You may have to deal with legal requirements to be able to intercept a
709 user's traffic at any time. l2tpns allows you to begin and end interception
710 on the fly, as well as at authentication time.<P>
711
712 When a user is being intercepted, a copy of every packet they send and
713 receive will be sent wrapped in a UDP packet to the IP address and port set
714 in the <EM>snoop_host</EM> and <EM>snoop_port</EM> configuration
715 variables.<P>
716
717 The UDP packet contains just the raw IP frame, with no extra headers.<P>
718
719 To enable interception on a connected user, use the <EM>snoop username</EM>
720 and <EM>no snoop username</EM> CLI commands. These will enable interception
721 immediately.<P>
722
723 If you wish the user to be intercepted whenever they reconnect, you will
724 need to modify the RADIUS response to include the Vendor-Specific value
725 <B>Cisco-Avpair="intercept=yes"</B>. For this feature to be enabled,
726 you need to have the <EM>autosnoop</EM> module loaded.<P>
727
728 <H2 ID="Authentication">Authentication</H2>
729
730 Whenever a session connects, it is not fully set up until authentication is
731 completed. The remote end must send a PPP CHAP or PPP PAP authentication
732 request to l2tpns.<P>
733
734 This request is sent to the RADIUS server, which will hopefully respond with
735 Auth-Accept or Auth-Reject.<P>
736
737 If Auth-Accept is received, the session is set up and an IP address is
738 assigned. The RADIUS server can include a Framed-IP-Address field in the
739 reply, and that address will be assigned to the client. It can also include
740 specific DNS servers, and a Framed-Route if that is required.<P>
741
742 If Auth-Reject is received, then the client is sent a PPP AUTHNAK packet,
743 at which point they should disconnect. The exception to this is when the
744 walled garden module is loaded, in which case the user still receives the
745 PPP AUTHACK, but their session is flagged as being a garden'd user, and they
746 should not receive any service.<P>
747
748 The RADIUS reply can also contain a Vendor-Specific attribute called
749 Cisco-Avpair. This field is a freeform text field that most Cisco
750 devices understand to contain configuration instructions for the session. In
751 the case of l2tpns it is expected to be of the form
752 <PRE>
753 key=value,key2=value2,key3=value3,key<EM>n</EM>=<EM>value</EM>
754 </PRE>
755
756 Each key-value pair is separated and passed to any modules loaded. The
757 <EM>autosnoop</EM> and <EM>autothrottle</EM> understand the keys
758 <EM>intercept</EM> and <EM>throttle</EM> respectively. For example, to have
759 a user who is to be throttled and intercepted, the Cisco-Avpair value should
760 contain:
761 <PRE>
762 intercept=yes,throttle=yes
763 </PRE>
764
765 <H2 ID="Plugins">Plugins</H2>
766
767 So as to make l2tpns as flexible as possible (I know the core code is pretty
768 difficult to understand), it includes a plugin API, which you can use to
769 hook into certain events.<P>
770
771 There are a few example modules included - autosnoop, autothrottle and
772 garden.<P>
773
774 When an event happens that has a hook, l2tpns looks for a predefined
775 function name in every loaded module, and runs them in the order the modules
776 were loaded.<P>
777
778 The function should return <B>PLUGIN_RET_OK</B> if it is all OK. If it returns
779 <B>PLUGIN_RET_STOP</B>, then it is assumed to have worked, but that no further
780 modules should be run for this event.<P>
781 A return of <B>PLUGIN_RET_ERROR</B> means that this module failed, and
782 no further processing should be done for this event. <EM>Use this with care.</EM>
783
784 Every event function called takes a specific structure named
785 param_<EM>event</EM>, which varies in content with each event. The
786 function name for each event will be <B>plugin_<EM>event</EM></B>,
787 so for the event <EM>timer</EM>, the function declaration should look like:
788 <PRE>
789 int plugin_timer(struct param_timer *data);
790 </PRE>
791
792 A list of the available events follows, with a list of all the fields in the
793 supplied structure:
794 <TABLE CELLSPACING=0 CELLPADDING=0><TR BGCOLOR=LIGHTGREEN><TD>
795 <TABLE CELLSPACING=1 CELLPADDING=3>
796 <TR BGCOLOR=LIGHTGREEN><TH><B>Event</B></TH><TH><B>Description</B></TH><TH><B>Parameters</B></TH></TR>
797 <TR VALIGN=TOP BGCOLOR=WHITE><TD><B>pre_auth</B></TD>
798 <TD>This is called after a RADIUS response has been
799 received, but before it has been processed by the
800 code. This will allow you to modify the response in
801 some way.
802 </TD>
803 <TD>
804 <UL>
805 <LI>t - Tunnel ID</LI>
806 <LI>s - Session ID</LI>
807 <LI>username</LI>
808 <LI>password</LI>
809 <LI>protocol (0xC023 for PAP, 0xC223 for CHAP)</LI>
810 <LI>continue_auth - Set to 0 to stop processing authentication modules</LI>
811 </UL>
812 </TD>
813 </TR>
814 <TR VALIGN=TOP BGCOLOR=WHITE><TD><B>post_auth</B></TD>
815 <TD>This is called after a RADIUS response has been
816 received, and the basic checks have been performed. This
817 is what the garden module uses to force authentication
818 to be accepted.
819 </TD>
820 <TD>
821 <UL>
822 <LI>t - Tunnel ID</LI>
823 <LI>s - Session ID</LI>
824 <LI>username</LI>
825 <LI>auth_allowed - This is already set to true or
826 false depending on whether authentication has been
827 allowed so far. You can set this to 1 or 0 to force
828 allow or disallow authentication</LI>
829 <LI>protocol (0xC023 for PAP, 0xC223 for CHAP)</LI>
830 </UL>
831 </TD>
832 </TR>
833 <TR VALIGN=TOP BGCOLOR=WHITE><TD><B>packet_rx</B></TD>
834 <TD>This is called whenever a session receives a
835 packet. <FONT COLOR=RED>Use this sparingly, as this will
836 seriously slow down the system.</FONT>
837 </TD>
838 <TD>
839 <UL>
840 <LI>t - Tunnel ID</LI>
841 <LI>s - Session ID</LI>
842 <LI>buf - The raw packet data</LI>
843 <LI>len - The length of buf</LI>
844 </UL>
845 </TD>
846 </TR>
847 <TR VALIGN=TOP BGCOLOR=WHITE><TD><B>packet_tx</B></TD>
848 <TD>This is called whenever a session sends a
849 packet. <FONT COLOR=RED>Use this sparingly, as this will
850 seriously slow down the system.</FONT>
851 </TD>
852 <TD>
853 <UL>
854 <LI>t - Tunnel ID</LI>
855 <LI>s - Session ID</LI>
856 <LI>buf - The raw packet data</LI>
857 <LI>len - The length of buf</LI>
858 </UL>
859 </TD>
860 </TR>
861 <TR VALIGN=TOP BGCOLOR=WHITE><TD><B>timer</B></TD>
862 <TD>This is run every second, no matter what is happening.
863 This is called from a signal handler, so make sure anything
864 you do is reentrant.
865 </TD>
866 <TD>
867 <UL>
868 <LI>time_now - The current unix timestamp</LI>
869 </UL>
870 </TD>
871 </TR>
872 <TR VALIGN=TOP BGCOLOR=WHITE><TD><B>new_session</B></TD>
873 <TD>This is called after a session is fully set up. The
874 session is now ready to handle traffic.
875 </TD>
876 <TD>
877 <UL>
878 <LI>t - Tunnel ID</LI>
879 <LI>s - Session ID</LI>
880 </UL>
881 </TD>
882 </TR>
883 <TR VALIGN=TOP BGCOLOR=WHITE><TD><B>kill_session</B></TD>
884 <TD>This is called when a session is about to be shut down.
885 This may be called multiple times for the same session.
886 </TD>
887 <TD>
888 <UL>
889 <LI>t - Tunnel ID</LI>
890 <LI>s - Session ID</LI>
891 </UL>
892 </TD>
893 </TR>
894 <TR VALIGN=TOP BGCOLOR=WHITE><TD><B>radius_response</B></TD>
895 <TD>This is called whenever a RADIUS response includes a
896 Cisco-Avpair value. The value is split up into
897 <EM>key=value</EM> pairs, and each is processed through all
898 modules.
899 </TD>
900 <TD>
901 <UL>
902 <LI>t - Tunnel ID</LI>
903 <LI>s - Session ID</LI>
904 <LI>key</LI>
905 <LI>value</LI>
906 </UL>
907 </TD>
908 </TR>
909 <TR VALIGN=TOP BGCOLOR=WHITE><TD><B>control</B></TD>
910 <TD>This is called in whenever a nsctl packet is received.
911 This should handle the packet and form a response if
912 required.
913 </TD>
914 <TD>
915 <UL>
916 <LI>buf - The raw packet data</LI>
917 <LI>l - The raw packet data length</LI>
918 <LI>source_ip - Where the request came from</LI>
919 <LI>source_port - Where the request came from</LI>
920 <LI>response - Allocate a buffer and put your response in here</LI>
921 <LI>response_length - Length of response</LI>
922 <LI>send_response - true or false whether a response
923 should be sent. If you set this to true, you must
924 allocate a response buffer.</LI>
925 <LI>type - Type of request (see nsctl.c)</LI>
926 <LI>id - ID of request</LI>
927 <LI>data - I'm really not sure</LI>
928 <LI>data_length - Length of data</LI>
929 </UL>
930 </TD>
931 </TR>
932 </TABLE>
933 </TD></TR></TABLE>
934
935 <H2 ID="WalledGarden">Walled Garden</H2>
936
937 Walled Garden is implemented so that you can provide perhaps limited service
938 to sessions that incorrectly authenticate.<P>
939
940 Whenever a session provides incorrect authentication, and the
941 RADIUS server responds with Auth-Reject, the walled garden module
942 (if loaded) will force authentication to succeed, but set the flag
943 <EM>garden</EM> in the session structure, and adds an iptables rule to
944 the <B>garden_users</B> chain to force all packets for the session's IP
945 address to traverse the <B>garden</B> chain.<P>
946
947 This doesn't <EM>just work</EM>. To set this all up, you will to
948 setup the <B>garden</B> nat table with the
949 <A HREF="#build-garden">build-garden</A> script with rules to limit
950 user's traffic. For example, to force all traffic except DNS to be
951 forwarded to 192.168.1.1, add these entries to your
952 <EM>build-garden</EM>:
953 <PRE>
954 iptables -t nat -A garden -p tcp --dport ! 53 -j DNAT --to 192.168.1.1
955 iptables -t nat -A garden -p udp --dport ! 53 -j DNAT --to 192.168.1.1
956 </PRE>
957
958 l2tpns will add entries to the garden_users chain as appropriate.<P>
959
960 You can check the amount of traffic being captured using the following
961 command:
962 <PRE>
963 iptables -t nat -L garden -nvx
964 </PRE>
965
966 <H2 ID="Filtering">Filtering</H2>
967
968 Sessions may be filtered by specifying <B>Filter-Id</B> attributes in
969 the RADIUS reply. <I>filter</I>.<B>in</B> specifies that the named
970 access-list <I>filter</I> should be applied to traffic from the
971 customer, <I>filter</I>.<B>out</B> specifies a list for traffic to the
972 customer.
973
974 <H2 ID="Clustering">Clustering</H2>
975
976 An l2tpns cluster consists of of one* or more servers configured with
977 the same configuration, notably the multicast <B>cluster_address</B>.<P>
978
979 *A stand-alone server is simply a degraded cluster.<P>
980
981 Initially servers come up as cluster slaves, and periodically (every
982 <B>cluster_hb_interval</B>/10 seconds) send out ping packets
983 containing the start time of the process to the multicast
984 <B>cluster_address</B>.<P>
985
986 A cluster master sends heartbeat rather than ping packets, which
987 contain those session and tunnel changes since the last heartbeat.<P>
988
989 When a slave has not seen a heartbeat within
990 <B>cluster_hb_timeout</B>/10 seconds it "elects" a new master by
991 examining the list of peers it has seen pings from and determines
992 which of these and itself is the "best" candidate to be master.
993 "Best" in this context means the server with the highest uptime (the
994 highest IP address is used as a tie-breaker in the case of equal
995 uptimes).<P>
996
997 After discovering a master, and determining that it is up-to-date (has
998 seen an update for all in-use sessions and tunnels from heartbeat
999 packets) will raise a route (see <A HREF="#Routing">Routing</A>) for
1000 the <B>bind_address</B> and for all addresses/networks in
1001 <B>ip_pool</B>. Any packets recieved by the slave which would alter
1002 the session state, as well as packets for throttled or gardened
1003 sessions are forwarded to the master for handling. In addition, byte
1004 counters for session traffic are periodically forwarded.<P>
1005
1006 A master, when determining that it has at least one up-to-date slave
1007 will drop all routes (raising them again if all slaves disappear) and
1008 subsequently handle only packets forwarded to it by the slaves.<P>
1009
1010 <H2 ID="Routing">Routing</H2>
1011 If you are running a single instance, you may simply statically route
1012 the IP pools to the <B>bind_address</B> (l2tpns will send a gratuitous
1013 arp).<P>
1014
1015 For a cluster, configure the members as BGP neighbours on your router
1016 and configure multi-path load-balancing. Cisco uses "maximum-paths
1017 ibgp" for IBGP. If this is not supported by your IOS revision, you
1018 can use "maximum-paths" (which works for EBGP) and set
1019 <B>as_number</B> to a private value such as 64512.<P>
1020
1021 <H2 ID="Performance">Performance</H2>
1022
1023 Performance is great.<P>
1024
1025 I'd like to include some pretty graphs here that show a linear performance
1026 increase, with no impact by number of connected sessions.<P>
1027
1028 That's really what it looks like.<P>
1029
1030 <BR>
1031 David Parrish<BR>
1032 <A HREF="mailto:l2tpns-users@lists.sourceforge.net?subject=L2TPNS%20Documentation">l2tpns-users@lists.sourceforge.net</A>
1033 </BODY>
1034 </HTML>