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