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