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