chiark / gitweb /
admin: Rename the unknown-service error.
[tripe] / doc / tripe.8
CommitLineData
74eb47db 1.\" -*-nroff-*-
2.\".
3.de hP
4.IP
5\h'-\w'\fB\\$1\ \fP'u'\fB\\$1\ \fP\c
6..
7.de VS
8.sp 1
9.RS
10.nf
11.ft B
12..
13.de VE
14.ft R
15.fi
16.RE
17.sp 1
18..
19.ie t \{\
20. ds o \(bu
21. ds ss \s8\u
22. ds se \d\s0
23. if \n(.g \{\
24. fam P
25. \}
26.\}
27.el \{\
28. ds o o
29. ds ss ^
d6623498 30. ds se
74eb47db 31.\}
32.TH tripe 8 "10 February 2001" "Straylight/Edgeware" "TrIPE: Trivial IP Encryption"
33.SH "NAME"
34tripe \- a simple VPN daemon
35.SH "SYNOPSIS"
36.B tripe
37.RB [ \-D ]
74eb47db 38.RB [ \-d
39.IR dir ]
d13e5724 40.RB [ \-b
41.IR addr ]
33ced0d3 42.RB [ \-p
43.IR port ]
42da2a58 44.RB [ \-n
45.IR tunnel ]
d13e5724 46.br
47
33ced0d3 48.RB [ \-U
49.IR user ]
50.RB [ \-G
51.IR group ]
d13e5724 52.RB [ \-a
53.IR socket ]
54.RB [ \-T
55.IR trace-opts ]
74eb47db 56.br
57
58.RB [ \-k
59.IR priv-keyring ]
60.RB [ \-K
61.IR pub-keyring ]
62.RB [ \-t
63.IR key-tag ]
64.SH "DESCRIPTION"
65The
66.B tripe
67program is a server which can provide strong IP-level encryption and
1a19f865 68authentication between co-operating hosts. The program and its protocol
69are deliberately very simple, to make analysing them easy and to help
70build trust rapidly in the system.
74eb47db 71.SS "Overview"
72The
73.B tripe
74server manages a number of secure connections to other `peer' hosts.
75Each daemon is given a private key of its own, and a file of public keys
76for the peers with which it is meant to communicate. It is responsible
77for negotiating sets of symmetric keys with its peers, and for
78encrypting, encapsulating and sending IP packets to its peers, and
79decrypting, checking and de-encapsulating packets it receives from
80them.
81.PP
82When the server starts, it creates a Unix-domain socket on which it
83listens for administration commands. It also logs warnings and
84diagnostic information to the programs connected to its admin socket.
85Clients connected to the socket can add new peers, and remove or find
86out about existing peers. The textual protocol used to give the
87.B tripe
88server admin commands is described in
89.BR tripe\-admin (5).
90A client program
91.BR tripectl (1)
92is provided to allow commands to be sent to the server either
93interactively or by simple scripts.
94.SS "Command-line arguments"
95If not given any command-line arguments,
96.B tripe
97will initialize by following these steps:
1a19f865 98.hP 1.
99It sets the directory named by the
100.B TRIPEDIR
101environment variable (or
102.B /var/lib/tripe
103if the variable is unset) as the current directory.
104.hP 2.
74eb47db 105It acquires a UDP socket with an arbitrary kernel-selected port number.
106It will use this socket to send and receive all communications with its
107peer servers. The port chosen may be discovered by means of the
108.B PORT
109admin command (see
110.BR tripe\-admin (5)).
1a19f865 111.hP 3.
74eb47db 112It loads the private key with the tag or type name
113.B tripe\-dh
114from the Catacomb-format file
115.BR keyring ,
116and loads the file
117.B keyring.pub
118ready for extracting the public keys of peers as they're introduced.
119(The format of these files is described in
120.BR keyring (5).
121They are maintained using the program
122.BR key (1)
123provided with the Catacomb distribution.)
1a19f865 124.hP 4.
74eb47db 125It creates and listens to the Unix-domain socket
126.BR tripesock .
127.PP
128Following this, the server enters its main loop, accepting admin
129connections and obeying any administrative commands, and communicating
130with peers. It also treats its standard input and standard output
131streams as an admin connection, reading commands from standard input and
33ced0d3 132writing responses and diagnostics messages to standard output. Finally,
133it will reload keys from its keyring files if it notices that they've
134changed (it checks inode number and modification time) \- there's no
135need to send a signal.
74eb47db 136.PP
137Much of this behaviour may be altered by giving
138.B tripe
139suitable command-line options:
140.TP
141.B "\-h, \-\-help"
142Writes a brief description of the command-line options available to
143standard output and exits with status 0.
144.TP
145.B "\-v, \-\-version"
146Writes
147.BR tripe 's
148version number to standard output and exits with status 0.
149.TP
150.B "\-u, \-\-usage"
151Writes a brief usage summary to standard output and exits with status 0.
152.TP
42da2a58 153.B "\-\-tunnels"
154Writes to standard output a list of the configured tunnel drivers, one
155per line, and exits with status 0. This is intended for the use of the
3cdc3f3a 156start-up script, so that it can check that it will actually work.
157.TP
74eb47db 158.B "\-D, \-\-daemon"
159Dissociates from its terminal and starts running in the background after
160completing the initialization procedure described above. If running as
161a daemon,
162.B tripe
163will not read commands from standard input or write diagnostics to
164standard output. A better way to start
165.B tripe
166in the background is with
167.BR tripectl (1).
168.TP
169.BI "\-d, \-\-directory=" dir
170Makes
171.I dir
172the current directory, instead of
173.BR /var/lib/tripe .
174Give a current directory of
175.B .
176if you don't want it to change directory at all.
177.TP
d13e5724 178.BI "\-b, \-\-bind-address="addr
179Bind the UDP socket to IP address
180.I addr
181rather than the default of
182.BR INADDR_ANY .
183This is useful if your main globally-routable IP address is one you want
184to tunnel through the VPN.
185.TP
74eb47db 186.BI "\-p, \-\-port=" port
187Use the specified UDP port for all communications with peers, rather
188than an arbitarary kernel-assigned port.
189.TP
42da2a58 190.BI "\-n, \-\-tunnel=" tunnel
191Use the specified tunnel driver for new peers by default.
192.TP
33ced0d3 193.BI "\-U, \-\-setuid=" user
194Set uid to that of
195.I user
196(either a user name or integer uid) after initialization. Also set gid
197to
198.IR user 's
199primary group, unless overridden by a
200.B \-G
201option.
202.TP
203.BI "\-G, \-\-setgid=" group
204Set gid to that of
205.I group
206(either a group name or integer gid) after initialization.
207.TP
74eb47db 208.BI "\-k, \-\-priv\-keyring=" file
209Reads the private key from
210.I file
211rather than the default
212.BR keyring .
213.TP
214.BI "\-K, \-\-pub\-keyring=" file
215Reads public keys from
216.I file
217rather than the default
218.BR keyring.pub .
219This can be the same as the private keyring, but that's not recommended.
220.TP
221.BI "\-t, \-\-tag=" tag
222Uses the private key whose tag or type is
223.I tag
224rather than the default
225.BR tripe\-dh .
226.TP
227.BI "\-a, \-\-admin\-socket=" socket
228Accept admin connections to a Unix-domain socket named
229.I socket
230rather than the default
231.BR tripesock .
232.TP
233.BI "\-T, \-\-trace=" trace-opts
234Allows the enabling or disabling of various internal diagnostics. See
235below for the list of options.
d6623498 236.SS "Setting up a VPN with tripe"
237The
238.B tripe
239server identifies peers by name. While it's
240.I possible
241for each host to maintain its own naming system for its peers, this is
242likely to lead to confusion, and it's more sensible to organize a naming
243system that works everywhere. How you manage this naming is up to you.
244The only restriction on the format of names is that they must be valid
245Catacomb key tags, since this is how
246.B tripe
247identifies which public key to use for a particular peer: they may not
248contain whitespace characters, or a colon
249.RB ` : '
250or dot
251.RB ` . ',
252.PP
253Allocating IP addresses for VPNs can get quite complicated. I'll
254attempt to illustrate with a relatively simple example. Our objective
255will be to set up a virtual private network between two sites of
256.BR example.com .
257The two sites are using distinct IP address ranges from the private
258address space described in RFC1918: site A is using addresses from
25910.0.1.0/24 and site B is using 10.0.2.0/24. Each site has a gateway
260host set up with both an address on the site's private network, and an
261externally-routable address from the public IP address space. Site A's
262gateway machine,
263.BR alice ,
264has the addresses 10.0.1.1 and 200.0.1.1; site B's gateway is
265.B bob
266and has addresses 10.0.2.1 and 200.0.2.1.
d6623498 267.hP 1.
268Install
269.B tripe
270on both of the gateway hosts. Create the directory
271.BR /var/lib/tripe .
272.hP 2.
273On
274.BR alice ,
275make
276.B /var/lib/tripe
277the current directory and generate a Diffie-Hellman group:
278.RS
74eb47db 279.VS
280key add \-adh\-param \-LS \-b2048 \-B256 \e
281 \-eforever \-tparam tripe\-dh\-param
282.VE
d6623498 283(See
284.BR key (1)
285from the Catacomb distribution for details about the
286.B key
287command.) Also generate a private key for
288.BR alice :
289.VS
290key add \-adh \-pparam \-talice \e
291 \-e"now + 1 year" tripe\-dh
292.VE
293Extract the group parameters and
294.BR alice 's
295public key to
296.I separate
297files, and put the public key in
298.BR keyring.pub :
74eb47db 299.VS
300key extract param param
37075862 301key extract \-f\-secret alice.pub alice
d6623498 302key \-kkeyring.pub merge alice.pub
74eb47db 303.VE
d6623498 304Send the files
305.B param
306and
307.B alice.pub
308to
309.B bob
310in some secure way (e.g., in PGP-signed email, or by using SSH), so that
311you can be sure they've not been altered in transit.
312.RE
313.hP 3.
314On
315.B bob
316now, make
317.B /var/lib/tripe
318the current directory, and import the key material from
319.BR alice :
320.RS
74eb47db 321.VS
322key merge param
d6623498 323key \-kkeyring.pub merge alice.pub
74eb47db 324.VE
d6623498 325Generate a private key for
326.B bob
327and extract the public half, as before:
74eb47db 328.VS
d6623498 329key add \-adh \-pparam \-tbob \e
330 \-e"now + 1 year" tripe\-dh
383f2a0b 331key extract \-f\-secret bob.pub bob
d6623498 332key \-kkeyring.pub merge bob.pub
74eb47db 333.VE
d6623498 334and send
335.B bob.pub
336back to
337.B alice
338using some secure method.
339.RE
340.hP 4
341On
342.BR alice ,
343merge
344.B bob 's
345key into the public keyring. Now, on each host, run
346.RS
347.VS
348key \-kkeyring.pub fingerprint
349.VE
350and check that the hashes match. If the two sites have separate
351administrators, they should read the hashes to each other over the
352telephone (assuming that they can recognize each other's voices).
353.RE
354.hP 5.
355Start the
356.B tripe
357servers up. Run
358.RS
359.VS
1f68dfc5 360tripectl \-slD \-S\-p22003
d6623498 361.VE
362on each of
363.B alice
364and
365.BR bob .
366(The
1f68dfc5 367.RB ` \-p22003 '
368forces the server to use UDP port 22003: use some other number if 22003
369is inappropriate for your requirements. I chose it by taking the first
37016 bits of the RIPEMD160 hash of
371.RB ` TrIPE '.
d6623498 372.RE
373.hP 6.
374To get
375.B alice
376talking to
377.BR bob ,
378run this shell script (or one like it):
379.RS
380.VS
381#! /bin/sh
74eb47db 382
1f68dfc5 383tripectl add bob 200.0.2.1 22003
d6623498 384ifname=`tripectl ifname bob`
1f68dfc5 385ifconfig $ifname 10.0.1.1 pointopoint 10.0.2.1
d6623498 386route add -net \e
387 10.0.2.0 netmask 255.255.255.0 \e
1f68dfc5 388 gw 10.0.2.1
d6623498 389.VE
390Read
391.BR ifconfig (8)
392and
393.BR route (8)
394to find out about your system's variants of these commands. The
395versions shown above assume a Linux system.
396Run a similar script on
397.BR bob ,
398to tell its
399.B tripe
400server to talk to
401.BR alice .
402.RE
403.hP 7.
404Congratulations. The two servers will exchange keys and begin sending
405packets almost immediately. You've set up a virtual private network.
52c03a2a 406.SS "Using elliptic curve keys"
407The
408.B tripe
409server can use elliptic curve Diffie-Hellman for key exchange, rather
410than traditional integer Diffie-Hellman. Given current public
411knowledge, elliptic curves can provide similar or better security to
412systems based on integer discrete log problems, faster, and with less
413transmitted data. It's a matter of controversy whether this will
414continue to be the case. The author uses elliptic curves.
415.PP
416The server works out which it
417should be doing based on the key type, which is either
418.B tripe\-dh
419for standard Diffie-Hellman, or
420.B tripe\-ec
421for elliptic curves. To create elliptic curve keys, say something like
422.VS
423key add \-aec\-param \-Cnist-p192 \-eforever \e
424 \-tparam tripe\-ec\-param
425.VE
426to construct a parameters key, using your preferred elliptic curve in
427the
428.B \-C
429option (see
430.BR key (1)
431for details); and create the private keys by
432.VS
433key add \-aec \-pparam \-talice \e
434 \-e"now + 1 year" tripe\-ec
435.VE
436Now start
437.B tripe
438with the
439.B \-ttripe\-ec
440option, and all should be well.
b5c45da1 441.SS "Using other symmetric algorithms"
442The default symmetric algorithms
443.B tripe
444uses are Blowfish (by Schneier) for symmetric encryption, and RIPEMD-160
445(by Dobbertin, Bosselaers and Preneel) for hashing and as a MAC (in HMAC
446mode, designed by Bellare, Canetti and Krawczyk). These can all be
447overridden by setting attributes on your private key, as follows.
448.TP
449.B cipher
450Names the symmetric encryption scheme to use. The default is
451.BR blowfish\-cbc .
452.TP
453.B hash
454Names the hash function to use. The default is
455.BR rmd160 .
456.TP
457.B mac
458Names the message authentication code to use. The name of the MAC may
459be followed by a
460.RB ` / '
461and the desired tag length in bits. The default is
462.IB hash \-hmac
463at half the underlying hash function's output length.
464.TP
465.B mgf
466A `mask-generation function', used in the key-exchange. The default is
467.IB hash \-mgf
468and there's no good reason to change it.
b9066fbb 469.SS "Using SLIP interfaces"
470Though not for the faint of heart, it is possible to get
471.B tripe
472to read and write network packets to a pair of file descriptors using
473SLIP encapsulation. No fancy header compression of any kind is
98fdb08d 474supported.
475.PP
476Two usage modes are supported: a preallocation system, whereby SLIP
477interfaces are created and passed to the
478.B tripe
479server at startup; and a dynamic system, where the server runs a script
480to allocate a new SLIP interface when it needs one. It is possible to
481use a mixture of these two modes, starting
b9066fbb 482.B tripe
98fdb08d 483with a few preallocated interfaces and having it allocate more
484dynamically as it needs them.
485.PP
486The behaviour of
487.BR tripe 's
488SLIP driver is controlled by the
489.B TRIPE_SLIPIF
1f68dfc5 490environment variable. The server will not create SLIP tunnels if this
491variable is not defined. The variable's value is a colon-delimited list
492of preallocated interfaces, followed optionally by the filename of a
493script to run to dynamically allocate more interfaces.
b9066fbb 494.PP
98fdb08d 495A static allocation entry has the form
b9066fbb 496.IR infd [ \c
497.BI , outfd \c
498.RB ] \c
499.BI = \c
98fdb08d 500.IR ifname ,
b9066fbb 501If the
502.I outfd
503is omitted, the same file descriptor is used for input and output.
504.PP
98fdb08d 505The dynamic allocation script must be named by an absolute or relative
506pathname, beginning with
507.RB ` / '
508or
509.RB ` . '.
510The server will pass the script an argument, which is the name of the
511peer for which the interface is being created. The script should
512allocate a new SLIP interface (presumably by creating a pty pair),
513configure it appropriately, and write the interface's name to its
514standard output, followed by a newline. It should then read and write
515SLIP packets on its stdin and stdout. The script's stdin will be closed
516when the interface is no longer needed, and the server will attempt to
517send it a
518.B SIGTERM
519signal (though this may fail if the script runs with higher privileges
520than the server).
521.PP
b9066fbb 522The output file descriptor should not block unless it really needs to:
523the
524.B tripe
1f68dfc5 525daemon assumes that it won't, and will get wedged waiting for it to
526accept output.
74eb47db 527.SS "About the name"
528The program's name is
529.BR tripe ,
530all in lower-case. The name of the protocol it uses is `TrIPE', with
531four capital letters and one lower-case. The name stands for `Trivial
532IP Encryption'.
533.SH "BUGS"
74eb47db 534The code hasn't been audited. It may contain security bugs. If you
535find one, please inform the author
536.IR immediately .
537.SH "SEE ALSO"
538.BR key (1),
539.BR tripectl (1),
540.BR tripe\-admin (5).
541.PP
542.IR "The Trivial IP Encryption Protocol" ,
543.IR "The Wrestlers Protocol" .
544.SH "AUTHOR"
d36eda2a 545Mark Wooding, <mdw@distorted.org.uk>