serpent: Ad-hoc debugging facility
[secnet] / README
CommitLineData
558fa3fb
SE
1secnet - flexible VPN software
2
8dea8d37
SE
3* Copying
4
3b83c932 5secnet is Copyright (C) 1995--2003 Stephen Early <steve@greenend.org.uk>
8dea8d37
SE
6It is distributed under the terms of the GNU General Public License,
7version 2 or later. See the file COPYING for more information.
8
8dea8d37
SE
9The IP address handling library in ipaddr.py is Copyright (C)
101996--2000 Cendio Systems AB, and is distributed under the terms of
11the GPL.
12
558fa3fb
SE
13* Introduction
14
15secnet allows large virtual private networks to be constructed
16spanning multiple separate sites. It is designed for the case where a
17private network connecting many hosts is 'hidden' behind a single
18globally-routable IP address, but can also be applied in other
19circumstances. It communicates entirely using UDP, and works well
20with gateways that implement network address translation.
21
22If you are installing secnet to join an existing VPN, you should read
23the 'INSTALL' file and your particular VPN's documentation now. You
24may need to refer back to this file for information on the netlink and
25comm sections of the configuration file.
26
27If you are thinking about setting up a new VPN of any size (from one
28providing complete links between multiple sites to a simple
29laptop-to-host link), read the section in this file on 'Creating a
30VPN'.
31
469fd1d9
SE
32* Mailing lists and bug reporting
33
34There are two mailing lists associated with secnet: an 'announce' list
35and a 'discuss' list. Their addresses are:
36http://www.chiark.greenend.org.uk/mailman/listinfo/secnet-announce
37http://www.chiark.greenend.org.uk/mailman/listinfo/secnet-discuss
38
39The -announce list receives one message per secnet release. The
40-discuss list is for general discussion, including help with
41configuration, bug reports, feature requests, etc.
42
43Bug reports should be sent to <steve@greenend.org.uk>; they will be
44forwarded to the -discuss list by me.
45
558fa3fb
SE
46* Creating a VPN
47
48XXX TODO
49
50* secnet configuration file format
51
52By default secnet on linux reads /etc/secnet/secnet.conf. The default
53may be different on other platforms.
54
55This file defines a dictionary (a mapping from keys to values) full of
56configuration information for secnet. Two keys must be defined in
57this file for secnet to start. One is "system", a dictionary
58containing systemwide control parameters. The other is "sites", a
59list of all the sites that you intend to communicate with.
60
61The configuration file has a very simple syntax; keys are defined as
62follows:
63
64key definition;
65or
66key = definition;
67
68(the "=" is optional)
69
70Keys must match the following regular expression:
71[[:alpha:]_][[:alnum:]\-_]*
72
73i.e. the first character must be an alpha or an underscore, and the
74remaining characters may be alphanumeric, '-' or '_'.
75
76Keys can be defined to be a comma-separated list of any of the
77following types:
78
79 a boolean
80 a string, in quotes
81 a number, in decimal
82 a dictionary of definitions, enclosed in { }
83 a "closure", followed by arguments
84 a path to a key that already exists, to reference that definition
85
86Note that dictionaries can be nested: a key in one dictionary can
87refer to another dictionary. When secnet looks for a key in a
88particular directory and can't find it, it looks in the dictionary's
89lexical 'parents' in turn until it finds it (or fails to find it at
90all and stops with an error).
91
92Definitions can refer to previous definitions by naming them with a
93path. Paths are key1/key2/key3... (starting from wherever we find
94key1, i.e. in the current dictionary or any of its parents), or
95alternatively /key1/key2/key3... (to start from the root).
96Definitions cannot refer to future definitions.
97
98Example:
99
100a=1;
101b=2;
102c={ d=3; e=a; };
103f={ a=4; g=c; };
104
105The following paths are valid:
106a is 1
107b is 2
108c is a dictionary:
109 c/d is 3
110 c/e is 1
111f is a dictionary:
112 f/a is 4
113 f/g is a dictionary:
114 f/g/d is 3
115 f/g/e is 1
116
117Note that f/g/e is NOT 4.
118
558fa3fb
SE
119Elements that are lists are inserted into lists in definitions, not
120referenced by them (i.e. you can't have lists of lists).
121
122Some closures may be followed by an argument list in ( ), and may
123return any number of whatever type they like (including other
124closures). Some types of closure (typically those returned from
125invokations of other closures) cannot be invoked.
126
127closure { definitions } is short for closure({definitions}).
128
129The main body of secnet, and all the additional modules, predefine
130some keys in the root dictionary. The main ones are:
131
fe5e9cc4
SE
132 yes, true, True, TRUE, on: the boolean value True
133 no, false, False, FALSE, off: the boolean value False
558fa3fb
SE
134 makelist: turns a dictionary (arg1) into a list of definitions
135 (ignoring the keys)
136 readfile: reads a file (arg1) and returns it as a string
3b83c932
SE
137 map: applies the closure specified as arg1 to each of the
138 remaining elements in the list in turn. Returns a list
139 made up of the outputs of the closure.
558fa3fb
SE
140
141Keys defined by modules are described below, in the module
142documentation.
143
144Other configuration files can be included inline by writing "include
145filename" at the start of a line.
146
147After the configuration file is read, secnet looks for particular keys
148in configuration space to tell it what to do:
149
150 system: a dictionary which can contain the following keys:
151 log (log closure): a destination for system messages
152 userid (string): the userid for secnet to run as once it drops privileges
153 pidfile (string): where to store its PID
154
155 sites: a list of closures of type 'site', which define other tunnel
156 endpoints that secnet will attempt to communicate with
157
158* secnet command line options
159
469fd1d9
SE
160Usage: secnet [OPTION]...
161
162 -f, --silent, --quiet suppress error messages
163 -w, --nowarnings suppress warnings
164 -v, --verbose output extra diagnostics
165 -c, --config=filename specify a configuration file
166 -j, --just-check-config stop after reading configfile
167 -n, --nodetach do not run in background
168 -d, --debug=item,... set debug options
169 --help display this help and exit
170 --version output version information and exit
558fa3fb
SE
171
172* secnet builtin modules
173
174** resolver
175
176Defines:
177 adns (closure => resolver closure)
178
3454dce4
SE
179adns: dict argument
180 config (string): optional, a resolv.conf for ADNS to use
181
558fa3fb
SE
182** random
183
184Defines:
185 randomsrc (closure => randomsrc closure)
186
3454dce4
SE
187randomsrc: string[,bool]
188 arg1: filename of random source
189 arg2: if True then source is blocking
190
558fa3fb
SE
191** udp
192
193Defines:
194 udp (closure => comm closure)
195
3454dce4 196udp: dict argument
3b83c932 197 address (string): IP address to listen and send on
3454dce4
SE
198 port (integer): UDP port to listen and send on
199 buffer (buffer closure): buffer for incoming packets
b2a56f7c 200 authbind (string): optional, path to authbind-helper program
3454dce4 201
042a8da9 202** log
558fa3fb
SE
203
204Defines:
205 logfile (closure => log closure)
b2a56f7c 206 syslog (closure => log closure)
558fa3fb 207
b2a56f7c
SE
208logfile: dict argument
209 filename (string): where to log to
210 class (string list): what type of messages to log
211 { "debug-config", M_DEBUG_CONFIG },
212 { "debug-phase", M_DEBUG_PHASE },
213 { "debug", M_DEBUG },
214 { "all-debug", M_DEBUG|M_DEBUG_PHASE|M_DEBUG_CONFIG },
215 { "info", M_INFO },
216 { "notice", M_NOTICE },
217 { "warning", M_WARNING },
218 { "error", M_ERROR },
219 { "security", M_SECURITY },
220 { "fatal", M_FATAL },
221 { "default", M_WARNING|M_ERROR|M_SECURITY|M_FATAL },
222 { "verbose", M_INFO|M_NOTICE|M_WARNING|M_ERROR|M_SECURITY|M_FATAL },
223 { "quiet", M_FATAL }
224
042a8da9
SE
225logfile will close and reopen its file upon receipt of SIGHUP.
226
b2a56f7c
SE
227syslog: dict argument
228 ident (string): include this string in every log message
229 facility (string): facility to log as
230 { "authpriv", LOG_AUTHPRIV },
231 { "cron", LOG_CRON },
232 { "daemon", LOG_DAEMON },
233 { "kern", LOG_KERN },
234 { "local0", LOG_LOCAL0 },
235 { "local1", LOG_LOCAL1 },
236 { "local2", LOG_LOCAL2 },
237 { "local3", LOG_LOCAL3 },
238 { "local4", LOG_LOCAL4 },
239 { "local5", LOG_LOCAL5 },
240 { "local6", LOG_LOCAL6 },
241 { "local7", LOG_LOCAL7 },
242 { "lpr", LOG_LPR },
243 { "mail", LOG_MAIL },
244 { "news", LOG_NEWS },
245 { "syslog", LOG_SYSLOG },
246 { "user", LOG_USER },
247 { "uucp", LOG_UUCP }
248
042a8da9
SE
249** util
250
251Defines:
252 sysbuffer (closure => buffer closure)
253
b2a56f7c
SE
254sysbuffer: integer[,dict]
255 arg1: buffer length
256 arg2: options:
257 lockdown (boolean): if True, mlock() the buffer
258
558fa3fb
SE
259** site
260
261Defines:
262 site (closure => site closure)
263
3454dce4
SE
264site: dict argument
265 local-name (string): this site's name for itself
266 name (string): the name of the site's peer
469fd1d9 267 link (netlink closure)
59533c16
IJ
268 comm (one or more comm closures): if there is more than one, the
269 first one will be used for any key setups initiated by us using the
270 configured address. Others are only used if our peer talks to
271 them.
3454dce4
SE
272 resolver (resolver closure)
273 random (randomsrc closure)
274 local-key (rsaprivkey closure)
275 address (string): optional, DNS name used to find our peer
276 port (integer): mandatory if 'address' is specified: the port used
277 to contact our peer
3454dce4
SE
278 key (rsapubkey closure): our peer's public key
279 transform (transform closure): how to mangle packets sent between sites
280 dh (dh closure)
281 hash (hash closure)
e57264d6
IJ
282 key-lifetime (integer): max lifetime of a session key, in ms
283 [one hour; mobile: 2 days]
3454dce4 284 setup-retries (integer): max number of times to transmit a key negotiation
e57264d6 285 packet [5; mobile: 30]
3454dce4 286 setup-timeout (integer): time between retransmissions of key negotiation
e57264d6 287 packets, in ms [2000; mobile: 1000]
3454dce4 288 wait-time (integer): after failed key setup, wait this long (in ms) before
e57264d6 289 allowing another attempt [20000; mobile: 10000]
3454dce4 290 renegotiate-time (integer): if we see traffic on the link after this time
e7f8ec2a 291 then renegotiate another session key immediately (in ms)
e57264d6
IJ
292 [half key-lifetime, or key-lifetime minus 5 mins (mobile: 12 hours),
293 whichever is longer].
b98e450d
IJ
294 keepalive (bool): if True then attempt always to keep a valid session key.
295 Not actually currently implemented. [false]
3454dce4
SE
296 log-events (string list): types of events to log for this site
297 unexpected: unexpected key setup packets (may be late retransmissions)
298 setup-init: start of attempt to setup a session key
299 setup-timeout: failure of attempt to setup a session key, through timeout
300 activate-key: activation of a new session key
301 timeout-key: deletion of current session key through age
302 security: anything potentially suspicious
303 state-change: steps in the key setup protocol
304 packet-drop: whenever we throw away an outgoing packet
305 dump-packets: every key setup packet we see
306 errors: failure of name resolution, internal errors
446353cd 307 peer-addrs: changes to sets of peer addresses (interesting for mobile peers)
3454dce4 308 all: everything (too much!)
446353cd
IJ
309 mobile (bool): if True then peer is "mobile" ie we assume it may
310 change its apparent IP address and port number without either it
311 or us being aware of the change; so, we remember the last several
312 port/addr pairs we've seen and send packets to all of them
313 (subject to a timeout). We maintain one set of addresses for key
314 setup exchanges, and another for data traffic. Two communicating
315 peers must not each regard the other as mobile, or all the traffic
316 in each direction will be triplicated (strictly, transmitted
317 mobile-peers-max times) and anyway two peers whose public contact
318 address may suddenly change couldn't communicate reliably because
319 their contact addresses might both change at once. [false]
320 mobile-peers-max (integer): Maximum number of peer port/addr pairs we
321 remember and send to. Must be at least 1 and no more than 5. [3]
322 mobile-peer-expiry (integer): For "mobile" peers only, the length
323 of time (in seconds) for which we will keep sending to multiple
324 address/ports from which we have not seen incoming traffic. [120]
dba19f84
IJ
325 local-mobile (bool): if True then other peers have been told we are
326 "mobile". This should be True iff the peers' site configurations
327 for us have "mobile True" (and if we find a site configuration for
328 ourselves in the config, we insist on this). The effect is to
329 check that there are no links both ends of which are allegedly
e57264d6
IJ
330 mobile (which is not supported, so those links are ignored) and
331 to change some of the tuning parameter defaults. [false]
332
333Links involving mobile peers have some different tuning parameter
334default values, which are generally more aggressive about retrying key
335setup but more relaxed about using old keys. These are noted with
336"mobile:", above, and apply whether the mobile peer is local or
337remote.
3454dce4 338
558fa3fb
SE
339** transform
340
341Defines:
342 serpent256-cbc (closure => transform closure)
343
344** netlink
345
346Defines:
469fd1d9 347 null-netlink (closure => closure or netlink closure)
3454dce4
SE
348
349null-netlink: dict argument
350 name (string): name for netlink device, used in log messages
351 networks (string list): networks on the host side of the netlink device
0e212483
RK
352 remote-networks (string list): networks that may be claimed
353 by the remote site using this netlink device
3454dce4
SE
354 local-address (string): IP address of host's tunnel interface
355 secnet-address (string): IP address of this netlink device
c6f79b17 356 ptp-address (string): IP address of the other end of a point-to-point link
3454dce4
SE
357 mtu (integer): MTU of host's tunnel interface
358
469fd1d9
SE
359Only one of secnet-address or ptp-address may be specified. If
360point-to-point mode is in use then the "routes" option must also be
361specified, and netlink returns a netlink closure that should be used
362directly with the "link" option to the site closure. If
363point-to-point mode is not in use then netlink returns a closure that
364may be invoked using a dict argument with the following keys to yield
365a netlink closure:
366 routes (string list): networks reachable down the tunnel attached to
367 this instance of netlink
368 options (string list):
369 allow-route: allow packets coming from this tunnel to be routed to
370 other tunnels as well as the host (used for mobile devices like laptops)
0e212483 371 soft: remove these routes from the host's routing table when
469fd1d9 372 the tunnel link quality is zero
ff05a229 373 mtu (integer): default MTU over this link; may be updated by tunnel code
c6f79b17 374
042a8da9
SE
375Netlink will dump its current routing table to the system/log on
376receipt of SIGUSR1.
377
3454dce4
SE
378** slip
379
380Defines:
558fa3fb 381 userv-ipif (closure => netlink closure)
3454dce4
SE
382
383userv-ipif: dict argument
384 userv-path (string): optional, where to find userv ["userv"]
385 service-user (string): optional, username for userv-ipif service ["root"]
386 service-name (string): optional, name of userv-ipif service ["ipif"]
387 buffer (buffer closure): buffer for assembly of host->secnet packets
388 plus generic netlink options, as for 'null-netlink'
389
390** tun
391
392Defines:
558fa3fb
SE
393 tun (closure => netlink closure) [only on linux-2.4]
394 tun-old (closure => netlink closure)
3454dce4
SE
395
396tun: dict argument
ff05a229
SE
397 flavour (string): optional, type of TUN interface to use
398 ("guess","linux","bsd","streams")
3454dce4
SE
399 device (string): optional, path of TUN/TAP device file ["/dev/net/tun"]
400 interface (string): optional, name of tunnel network interface
401 ifconfig-path (string): optional, path to ifconfig command
402 route-path (string): optional, path to route command
ff05a229
SE
403 ifconfig-type (string): optional, how to perform ifconfig
404 route-type (string): optional, how to add and remove routes
405 types are: "guess", "ioctl", "bsd", "linux", "solaris-2.5"
3454dce4
SE
406 buffer (buffer closure): buffer for host->secnet packets
407 plus generic netlink options, as for 'null-netlink'
408
ff05a229
SE
409I recommend you don't specify the 'interface' option unless you're
410doing something that requires the interface name to be constant.
c6f79b17 411
558fa3fb
SE
412** rsa
413
414Defines:
415 rsa-private (closure => rsaprivkey closure)
416 rsa-public (closure => rsapubkey closure)
417
3454dce4
SE
418rsa-private: string[,bool]
419 arg1: filename of SSH private key file (version 1, no password)
420 arg2: whether to check that the key is usable [default True]
421
422rsa-public: string,string
423 arg1: encryption key (decimal)
424 arg2: modulus (decimal)
425
558fa3fb
SE
426** dh
427
428Defines:
429 diffie-hellman (closure => dh closure)
430
3454dce4
SE
431diffie-hellman: string,string[,bool]
432 arg1: modulus (hex)
433 arg2: generator (hex)
434 arg3: whether to check that the modulus is prime [default True]
435
558fa3fb
SE
436** md5
437
438Defines:
439 md5 (hash closure)
3454dce4
SE
440
441** sha1
442
443Defines:
444 sha1 (hash closure)
c6f79b17
SE
445
446** conffile
447
448Defines:
449 makelist (dictionary => list of definitions)
450 readfile (string => string)
451 map (closure,list => list)
452
453makelist: dictionary
454 returns a list consisting of the definitions in the dictionary. The keys
455 are discarded.
456
457readfile: string
458 reads the named file and returns its contents as a string
459
460map:
461 applies the closure specified as arg1 to each of the elements in the list.
462 Returns a list made up of the outputs of the closure.