Merged PROTOCOL, NETWORK and SECURITY2 with the texinfo manual.
[tinc] / doc / tinc.texi
1 \input texinfo   @c -*-texinfo-*-
2 @c $Id: tinc.texi,v 1.8.4.18 2001/05/25 12:45:37 guus Exp $
3 @c %**start of header
4 @setfilename tinc.info
5 @settitle tinc Manual
6 @setchapternewpage odd
7 @c %**end of header
8
9 @ifinfo
10 @direntry
11 * tinc: (tinc).              The tinc Manual.
12 @end direntry
13
14 This is the info manual for tinc, a Virtual Private Network daemon.
15
16 Copyright @copyright{} 1998-2001 Ivo Timmermans
17 <itimmermans@@bigfoot.com>, Guus Sliepen <guus@@sliepen.warande.net> and
18 Wessel Dankers <wsl@@nl.linux.org>.
19
20 $Id: tinc.texi,v 1.8.4.18 2001/05/25 12:45:37 guus Exp $
21
22 Permission is granted to make and distribute verbatim copies of this
23 manual provided the copyright notice and this permission notice are
24 preserved on all copies.
25
26 Permission is granted to copy and distribute modified versions of this
27 manual under the conditions for verbatim copying, provided that the
28 entire resulting derived work is distributed under the terms of a
29 permission notice identical to this one.
30
31 @end ifinfo
32
33 @titlepage
34 @title tinc Manual
35 @subtitle Setting up a Virtual Private Network with tinc
36 @author Ivo Timmermans and Guus Sliepen
37
38 @page
39 @vskip 0pt plus 1filll
40 @cindex copyright
41 Copyright @copyright{} 1998-2001 Ivo Timmermans
42 <itimmermans@@bigfoot.com>, Guus Sliepen <guus@@sliepen.warande.net> and
43 Wessel Dankers <wsl@@nl.linux.org>.
44
45 $Id: tinc.texi,v 1.8.4.18 2001/05/25 12:45:37 guus Exp $
46
47 Permission is granted to make and distribute verbatim copies of this
48 manual provided the copyright notice and this permission notice are
49 preserved on all copies.
50
51 Permission is granted to copy and distribute modified versions of this
52 manual under the conditions for verbatim copying, provided that the
53 entire resulting derived work is distributed under the terms of a
54 permission notice identical to this one.
55
56 @end titlepage
57
58 @c ==================================================================
59 @node Top, Introduction, (dir), (dir)
60
61 @menu
62 * Introduction::                Introduction
63 * Preparations::
64 * Installation::
65 * Configuration::
66 * Running tinc::
67 * Technical information::
68 * About us::
69 * Concept Index::               All used terms explained
70 @end menu
71
72
73 @contents
74
75 @c ==================================================================
76 @node    Introduction, Preparations, Top, Top
77 @chapter Introduction
78
79 @cindex tinc
80 tinc is a Virtual Private Network (VPN) daemon that uses tunneling and
81 encryption to create a secure private network between hosts on the
82 Internet.
83
84 Because the tunnel appears to the IP level network code as a normal
85 network device, there is no need to adapt any existing software.
86 The encrypted tunnels allows VPN sites to share information with each other
87 over the Internet without exposing any information to others.
88
89 This document is the manual for tinc.  Included are chapters on how to
90 configure your computer to use tinc, as well as the configuration
91 process of tinc itself.
92
93 @menu
94 * VPNs::                        Virtual Private Networks in general
95 * tinc::                        about tinc
96 * Supported platforms::
97 @end menu
98
99 @c ==================================================================
100 @node    VPNs, tinc, Introduction, Introduction
101 @section Virtual Private Networks
102
103 @cindex VPN
104 A Virtual Private Network or VPN is a network that can only be accessed
105 by a few elected computers that participate.  This goal is achievable in
106 more than just one way.
107
108 @cindex private
109 Private networks can consist of a single stand-alone Ethernet LAN.  Or
110 even two computers hooked up using a null-modem cable.  In these cases,
111 it is
112 obvious that the network is @emph{private}, no one can access it from the
113 outside.  But if your computers are linked to the Internet, the network
114 is not private anymore, unless one uses firewalls to block all private
115 traffic.  But then, there is no way to send private data to trusted
116 computers on the other end of the Internet.
117
118 @cindex virtual
119 This problem can be solved by using @emph{virtual} networks.  Virtual
120 networks can live on top of other networks, but they use encapsulation to
121 keep using their private address space so they do not interfere with
122 the Internet.  Mostly, virtual networks appear like a singe LAN, even though
123 they can span the entire world.  But virtual networks can't be secured
124 by using firewalls, because the traffic that flows through it has to go
125 through the Internet, where other people can look at it.
126
127 As is the case with either type of VPN, anybody could eavesdrop.  Or
128 worse, alter data.  Hence it's probably advisable to encrypt the data
129 that flows over the network.
130
131 When one introduces encryption, we can form a true VPN.  Other people may
132 see encrypted traffic, but if they don't know how to decipher it (they
133 need to know the key for that), they cannot read the information that flows
134 through the VPN.  This is what tinc was made for.
135
136
137 @c ==================================================================
138 @node    tinc, Supported platforms, VPNs, Introduction
139 @section tinc
140
141 @cindex vpnd
142 I really don't quite remember what got us started, but it must have been
143 Guus' idea.  He wrote a simple implementation (about 50 lines of C) that
144 used the ethertap device that Linux knows of since somewhere
145 about kernel 2.1.60.  It didn't work immediately and he improved it a
146 bit.  At this stage, the project was still simply called @samp{vpnd}.
147
148 Since then, a lot has changed---to say the least.
149
150 @cindex tincd
151 tinc now supports encryption, it consists of a single daemon (tincd) for
152 both the receiving and sending end, it has become largely
153 runtime-configurable---in short, it has become a full-fledged
154 professional package.
155
156 @cindex Traditional VPNs
157 @cindex scalability
158 tinc also allows more than two sites to connect to eachother and form a single VPN.
159 Traditionally VPNs are created by making tunnels, which only have two endpoints.
160 Larger VPNs with more sites are created by adding more tunnels.
161 tinc takes another approach: only endpoints are specified,
162 the software itself will take care of creating the tunnels.
163 This allows for easier configuration and improved scalability.
164
165 A lot can---and will be---changed. We have a number of things that we would like to
166 see in the future releases of tinc.  Not everything will be available in
167 the near future.  Our first objective is to make tinc work perfectly as
168 it stands, and then add more advanced features.
169
170 Meanwhile, we're always open-minded towards new ideas.  And we're
171 available too.
172
173
174 @c ==================================================================
175 @node    Supported platforms,  , tinc, Introduction
176 @section Supported platforms
177
178 @cindex platforms
179 tinc has been verified to work under Linux, FreeBSD and Solaris, with
180 various hardware architectures.  These are the three platforms
181 that are supported by the universial TUN/TAP device driver, so if
182 support for other operating systems is added to this driver, perhaps
183 tinc will run on them as well.  Without this driver, tinc will most
184 likely compile and run, but it will not be able to send or receive data
185 packets.
186
187 @cindex release
188 The official release only truly supports Linux.
189 For an up to date list of supported platforms, please check the list on
190 our website:
191 @uref{http://tinc.nl.linux.org/platforms.html}.
192
193
194 @c ==================================================================
195 @subsection Linux
196
197 @cindex Linux
198 tinc was first written for Linux running on an intel x86 processor, so
199 this is the best supported platform.  The protocol however, and actually
200 anything about tinc, has been rewritten to support random byte ordering
201 and arbitrary word length.  So in theory it should run on other
202 processors that Linux runs on.  It has already been verified to run on
203 alpha and sparc processors as well.
204
205 tinc uses the ethertap device or the universal TUN/TAP driver. The former is provided in the standard kernel
206 from version 2.1.60 up to 2.3.x, but has been replaced in favour of the TUN/TAP driver in kernel versions 2.4.0 and later.
207
208
209 @c ==================================================================
210 @subsection FreeBSD
211
212 @cindex FreeBSD
213 tinc on FreeBSD relies on the universial TUN/TAP driver for its data
214 acquisition from the kernel.  Therefore, tinc will work on the same platforms
215 as this driver.  These are: FreeBSD 3.x, 4.x, 5.x.
216
217
218 @c ==================================================================
219 @subsection Solaris
220
221 @cindex Solaris
222 tinc on Solaris relies on the universial TUN/TAP driver for its data
223 acquisition from the kernel.  Therefore, tinc will work on the same platforms
224 as this driver.  These are: Solaris, 2.1.x.
225
226
227 @c
228 @c
229 @c
230 @c
231 @c
232 @c
233 @c       Preparing your system
234 @c
235 @c
236 @c
237 @c
238 @c
239
240 @c ==================================================================
241 @node    Preparations, Installation, Introduction, Top
242 @chapter Preparations
243
244 This chapter contains information on how to prepare your system to
245 support tinc.
246
247 @menu
248 * Configuring the kernel::
249 * Libraries::
250 @end menu
251
252
253 @c ==================================================================
254 @node    Configuring the kernel, Libraries, Preparations, Preparations
255 @section Configuring the kernel
256
257 @cindex RedHat
258 @cindex Debian
259 @cindex netlink_dev
260 @cindex tun
261 @cindex ethertap
262 If you are running Linux, chances are good that your kernel already supports
263 all the devices that tinc needs for proper operation.  For example, the
264 standard kernel from Redhat Linux already has support for ethertap and netlink
265 compiled in.  Debian users can use the modconf utility to select the modules.
266 If your Linux distribution supports this method of selecting devices, look out
267 for something called `ethertap', and `netlink_dev' if it is using a kernel
268 version prior to 2.4.0. In that case you will need both these devices.  If you
269 are using kernel 2.4.0 or later, you need to select `tun'.
270
271 @cindex Kernel-HOWTO
272 If you can install these devices in a similar manner, you may skip this section.
273 Otherwise, you will have to recompile the kernel in order to turn on the required features.
274 If you are unfamiliar with the process of configuring and compiling a new kernel,
275 you should read the @uref{http://howto.linuxberg.com/LDP/HOWTO/Kernel-HOWTO.html, Kernel HOWTO} first.
276
277 @menu
278 * Configuration of Linux kernels 2.1.60 up to 2.4.0::
279 * Configuration of Linux kernels 2.4.0 and higher::
280 * Configuration of FreeBSD kernels::
281 * Configuration of Solaris kernels::
282 @end menu
283
284
285 @c ==================================================================
286 @node       Configuration of Linux kernels 2.1.60 up to 2.4.0, Configuration of Linux kernels 2.4.0 and higher, Configuring the kernel, Configuring the kernel
287 @subsection Configuration of Linux kernels 2.1.60 up to 2.4.0
288
289 Here are the options you have to turn on when configuring a new kernel:
290
291 @example
292 Code maturity level options
293 [*] Prompt for development and/or incomplete code/drivers
294 Networking options
295 [*] Kernel/User netlink socket
296 <M> Netlink device emulation
297 Network device support
298 <M> Ethertap network tap
299 @end example
300
301 If you want to run more than one instance of tinc or other programs that use
302 the ethertap, you have to compile the ethertap driver as a module, otherwise
303 you can also choose to compile it directly into the kernel.
304
305 If you decide to build any of these as dynamic kernel modules, it's a good idea
306 to add these lines to @file{/etc/modules.conf}:
307
308 @example
309 alias char-major-36 netlink_dev
310 alias tap0 ethertap
311 options tap0 -o tap0 unit=0
312 alias tap1 ethertap
313 options tap1 -o tap1 unit=1
314 ...
315 alias tap@emph{N} ethertap
316 options tap@emph{N} -o tap@emph{N} unit=@emph{N}
317 @end example
318
319 Add as much alias/options lines as necessary.
320
321
322 @c ==================================================================
323 @node       Configuration of Linux kernels 2.4.0 and higher, Configuration of FreeBSD kernels, Configuration of Linux kernels 2.1.60 up to 2.4.0, Configuring the kernel
324 @subsection Configuration of Linux kernels 2.4.0 and higher
325
326 Here are the options you have to turn on when configuring a new kernel:
327
328 @example
329 Code maturity level options
330 [*] Prompt for development and/or incomplete code/drivers
331 Network device support
332 <M> Universal TUN/TAP device driver support
333 @end example
334
335 It's not necessary to compile this driver as a module, even if you are going to
336 run more than one instance of tinc.
337
338 If you have an early 2.4 kernel, you can choose both the TUN/TAP driver and the
339 `Ethertap network tap' device.  This latter is marked obsolete, and chances are
340 that it won't even function correctly anymore.  Make sure you select the
341 universal TUN/TAP driver.
342
343 If you decide to build the TUN/TAP driver as a kernel module, add these lines
344 to @file{/etc/modules.conf}:
345
346 @example
347 alias char-major-10-200 tun
348 @end example
349
350
351 @c ==================================================================
352 @node       Configuration of FreeBSD kernels, Configuration of Solaris kernels, Configuration of Linux kernels 2.4.0 and higher, Configuring the kernel
353 @subsection Configuration of FreeBSD kernels
354
355 This section will contain information on how to configure your FreeBSD
356 kernel to support the universal TUN/TAP device.  For 5.0 and 4.1
357 systems, this is included in the kernel configuration, for earlier
358 systems (4.0 and 3.x), you need to install the universal TUN/TAP driver
359 yourself.
360
361 Unfortunately somebody still has to write the text.
362
363
364 @c ==================================================================
365 @node       Configuration of Solaris kernels,  , Configuration of FreeBSD kernels, Configuring the kernel
366 @subsection Configuration of Solaris kernels
367
368 This section will contain information on how to configure your Solaris
369 kernel to support the universal TUN/TAP device.  You need to install
370 this driver yourself.
371
372 Unfortunately somebody still has to write the text.
373
374
375 @c ==================================================================
376 @node    Libraries,  , Configuring the kernel, Preparations
377 @section Libraries
378
379 @cindex requirements
380 @cindex libraries
381 Before you can configure or build tinc, you need to have the OpenSSL
382 library installed on your system.  If you try to configure tinc without
383 having installed it, configure will give you an error message, and stop.
384
385 @menu
386 * OpenSSL::
387 @end menu
388
389
390 @c ==================================================================
391 @node       OpenSSL,  , Libraries, Libraries
392 @subsection OpenSSL
393
394 @cindex OpenSSL
395 For all cryptography-related functions, tinc uses the functions provided
396 by the OpenSSL library.
397
398 If this library is not installed, you wil get an error when configuring
399 tinc for build.  Support for running tinc without having OpenSSL
400 installed @emph{may} be added in the future.
401
402 You can use your operating system's package manager to install this if
403 available.  Make sure you install the development AND runtime versions
404 of this package.
405
406 If you have to install OpenSSL manually, you can get the source code
407 from @url{http://www.openssl.org/}.  Instructions on how to configure,
408 build and install this package are included within the package.  Please
409 make sure you build development and runtime libraries (which is the
410 default).
411
412 If you installed the OpenSSL libraries from source, it may be necessary
413 to let configure know where they are, by passing configure one of the
414 --with-openssl-* parameters.
415
416 @example
417 --with-openssl=DIR      OpenSSL library and headers prefix
418 --with-openssl-include=DIR OpenSSL headers directory
419                         (Default is OPENSSL_DIR/include)
420 --with-openssl-lib=DIR  OpenSSL library directory
421                         (Default is OPENSSL_DIR/lib)
422 @end example
423
424
425 @subsubheading License
426
427 @cindex license
428 Since the license under which OpenSSL is distributed is not directly
429 compatible with the terms of the GNU GPL
430 @uref{http://www.openssl.org/support/faq.html#LEGAL2}, therefore we
431 include an addition to the GPL (see also the file COPYING.README):
432
433 @quotation
434 This program is released under the GPL with the additional exemption
435 that compiling, linking, and/or using OpenSSL is allowed.  You may
436 provide binary packages linked to the OpenSSL libraries, provided that
437 all other requirements of the GPL are met.
438 @end quotation
439
440
441 @c
442 @c
443 @c
444 @c      Installing tinc
445 @c
446 @c
447 @c
448 @c
449
450 @c ==================================================================
451 @node    Installation, Configuration, Preparations, Top
452 @chapter Installation
453
454 If you use Redhat or Debian, you may want to install one of the
455 precompiled packages for your system.  These packages are equipped with
456 system startup scripts and sample configurations.
457
458 If you don't run either of these systems, or you want to compile tinc
459 for yourself, you can use the source.  The source is distributed under
460 the GNU General Public License (GPL).  Download the source from the
461 @uref{http://tinc.nl.linux.org/download.html, download page}, which has
462 the checksums of these files listed; you may wish to check these with
463 md5sum before continuing.
464
465 tinc comes in a convenient autoconf/automake package, which you can just
466 treat the same as any other package.  Which is just untar it, type
467 `configure' and then `make'.
468 More detailed instructions are in the file @file{INSTALL}, which is
469 included in the source distribution.
470
471 @menu
472 * Building and installing tinc::
473 * System files::
474 @end menu
475
476
477 @c ==================================================================
478 @node    Building and installing tinc, System files, Installation, Installation
479 @section Building and installing tinc
480
481 Detailed instructions on configuring the source, building tinc and installing tinc
482 can be found in the file called @file{INSTALL}.
483
484 @cindex binary package
485 If you happen to have a binary package for tinc for your distribution,
486 you can use the package management tools of that distribution to install tinc.
487 The documentation that comes along with your distribution will tell you how to do that.
488
489
490 @c ==================================================================
491 @node    System files,  , Building and installing tinc, Installation
492 @section System files
493
494 Before you can run tinc, you must make sure you have all the needed
495 files on your system.
496
497 @menu
498 * Device files::
499 * Other files::
500 @end menu
501
502
503 @c ==================================================================
504 @node       Device files, Other files, System files, System files
505 @subsection Device files
506
507 @cindex device files
508 First, you'll need the special device file(s) that form the interface
509 between the kernel and the daemon.
510
511 The permissions for these files have to be such that only the super user
512 may read/write to this file.  You'd want this, because otherwise
513 eavesdropping would become a bit too easy.  This does, however, imply
514 that you'd have to run tincd as root.
515
516 If you use Linux and have a kernel version prior to 2.4.0, you have to make the
517 ethertap devices:
518
519 @example
520 mknod -m 600 /dev/tap0 c 36 16
521 chown 0.0 /dev/tap0
522 mknod -m 600 /dev/tap1 c 36 17
523 chown 0.0 /dev/tap0
524 ...
525 mknod -m 600 /dev/tap@emph{N} c 36 @emph{N+16}
526 chown 0.0 /dev/tap@emph{N}
527 @end example
528
529 There is a maximum of 16 ethertap devices.
530
531 If you use the universal TUN/TAP driver, you have to create the
532 following device file (unless it already exist):
533
534 @example
535 mknod -m 600 /dev/tun c 10 200
536 chown 0.0 /dev/tun
537 @end example
538
539 If you use Linux, and you run the new 2.4 kernel using the devfs filesystem,
540 then the TUN/TAP device will probably be automatically generated as
541 @file{/dev/net/tun}.
542
543 Unlike the ethertap device, you do not need multiple device files if
544 you are planning to run multiple tinc daemons.
545
546
547 @c ==================================================================
548 @node       Other files,  , Device files, System files
549 @subsection Other files
550
551 @subsubheading @file{/etc/networks}
552
553 You may add a line to @file{/etc/networks} so that your VPN will get a
554 symbolic name.  For example:
555
556 @example
557 myvpn 10.0.0.0
558 @end example
559
560 @subsubheading @file{/etc/services}
561
562 @cindex port numbers
563 You may add this line to @file{/etc/services}.  The effect is that you
564 may supply a @samp{tinc} as a valid port number to some programs.  The
565 number 655 is registered with the IANA.
566
567 @example
568 tinc            655/tcp    TINC
569 tinc            655/udp    TINC
570 #                          Ivo Timmermans <itimmermans@@bigfoot.com>
571 @end example
572
573
574 @c
575 @c
576 @c
577 @c
578 @c         Configuring tinc
579 @c
580 @c
581 @c
582 @c
583
584
585 @c ==================================================================
586 @node    Configuration, Running tinc, Installation, Top
587 @chapter Configuration
588
589 @menu
590 * Configuration introduction::
591 * Multiple networks::
592 * How connections work::
593 * Configuration files::
594 * Generating keypairs::
595 * Network interfaces::
596 * Example configuration::
597 @end menu
598
599 @c ==================================================================
600 @node    Configuration introduction, Multiple networks, Configuration, Configuration
601 @section Configuration introduction
602
603 @cindex Network Administrators Guide
604 Before actually starting to configure tinc and editing files,
605 make sure you have read this entire section so you know what to expect.
606 Then, make it clear to yourself how you want to organize your VPN:
607 What are the nodes (computers running tinc)?
608 What IP addresses/subnets do they have?
609 What is the network mask of the entire VPN?
610 Do you need special firewall rules?
611 Do you have to set up masquerading or forwarding rules?
612 These questions can only be answered by yourself,
613 you will not find the answers in this documentation.
614 Make sure you have an adequate understanding of networks in general.
615 A good resource on networking is the
616 @uref{http://www.linuxdoc.org/LDP/nag2/, Linux Network Administrators Guide}.
617
618 If you have everything clearly pictured in your mind,
619 proceed in the following order:
620 First, generate the configuration files (tinc.conf, your host configuration file, tinc-up and perhaps tinc-down).
621 Then generate the keypairs.
622 Finally, distribute the host configuration files.
623 These steps are described in the subsections below.
624
625
626 @c ==================================================================
627 @node    Multiple networks, How connections work, Configuration introduction, Configuration
628 @section Multiple networks
629
630 @cindex multiple networks
631 @cindex netname
632 In order to allow you to run more than one tinc daemon on one computer,
633 for instance if your computer is part of more than one VPN,
634 you can assign a ``netname'' to your VPN.
635 It is not required if you only run one tinc daemon,
636 it doesn't even have to be the same on all the sites of your VPN,
637 but it is recommended that you choose one anyway.
638
639 We will asume you use a netname throughout this document.
640 This means that you call tincd with the -n argument,
641 which will assign a netname to this daemon.
642
643 The effect of this is that the daemon will set its configuration
644 ``root'' to /etc/tinc/netname/, where netname is your argument to the -n
645 option.  You'll notice that it appears in syslog as ``tinc.netname''.
646
647 However, it is not strictly necessary that you call tinc with the -n
648 option.  In this case, the network name would just be empty, and it will
649 be used as such.  tinc now looks for files in /etc/tinc/, instead of
650 /etc/tinc/netname/; the configuration file should be /etc/tinc/tinc.conf,
651 and the host configuration files are now expected to be in /etc/tinc/hosts/.
652
653 But it is highly recommended that you use this feature of tinc, because
654 it will be so much clearer whom your daemon talks to.  Hence, we will
655 assume that you use it.
656
657
658 @c ==================================================================
659 @node    How connections work, Configuration files, Multiple networks, Configuration
660 @section How connections work
661
662 When tinc starts up, it parses the command-line options and then
663 reads in the configuration file.
664 If it sees a `ConnectTo' value pointing to another tinc daemon in the file,
665 it will try to connect to that other one.
666 Whether this succeeds or not and whether `ConnectTo' is specified or not,
667 tinc will listen for incoming connection from other deamons.
668 If you did specify a `ConnectTo' value and the other side is not responding,
669 tinc will keep retrying.
670 This means that once started, tinc will stay running until you tell it to stop,
671 and failures to connect to other tinc daemons will not stop your tinc daemon
672 for trying again later.
673 This means you don't have to intervene if there are any network problems.
674
675 @cindex client
676 @cindex server
677 There is no real distinction between a server and a client in tinc.
678 If you wish, you can view a tinc daemon without a `ConnectTo' value as a server,
679 and one which does specify such a value as a client.
680 It does not matter if two tinc daemons have a `ConnectTo' value pointing to eachother however.
681
682
683 @c ==================================================================
684 @node    Configuration files, Generating keypairs, How connections work, Configuration
685 @section Configuration files
686
687 The actual configuration of the daemon is done in the file
688 @file{/etc/tinc/netname/tinc.conf} and at least one other file in the directory
689 @file{/etc/tinc/netname/hosts/}.
690
691 These file consists of comments (lines started with a #) or assignments
692 in the form of
693
694 @example
695 Variable = Value.
696 @end example
697
698 The variable names are case insensitive, and any spaces, tabs, newlines
699 and carriage returns are ignored.  Note: it is not required that you put
700 in the `=' sign, but doing so improves readability.  If you leave it
701 out, remember to replace it with at least one space character.
702
703 In this section all valid variables are listed in alphabetical order.
704 The default value is given between parentheses,
705 other comments are between square brackets and
706 required directives are given in @strong{bold}.
707
708 @menu
709 * Main configuration variables::
710 * Host configuration variables::
711 * How to configure::
712 @end menu
713
714
715 @c ==================================================================
716 @node    Main configuration variables, Host configuration variables, Configuration files, Configuration files
717 @subsection Main configuration variables
718
719 @table @asis
720 @item @strong{ConnectTo = <name>}
721 @cindex ConnectTo
722 Specifies which host to connect to on startup.  Multiple ConnectTo
723 variables may be specified, if connecting to the first one fails then
724 tinc will try the next one, and so on.  It is possible to specify
725 hostnames for dynamic IP addresses (like those given on dyndns.org),
726 tinc will not cache the resolved IP address.
727
728 If you don't specify a host with ConnectTo, regardless of whether a
729 value for ConnectPort is given, tinc won't connect at all, and will
730 instead just listen for incoming connections.
731
732 @item Hostnames = <yes|no> (no)
733 @cindex Hostnames
734 This option selects whether IP addresses (both real and on the VPN)
735 should be resolved.  Since DNS lookups are blocking, it might affect
736 tinc's efficiency, even stopping the daemon for a few seconds everytime
737 it does a lookup if your DNS server is not responding.
738
739 This does not affect resolving hostnames to IP addresses from the
740 configuration file.
741
742 @item Interface = <device>
743 @cindex Interface
744 If you have more than one network interface in your computer, tinc will
745 by default listen on all of them for incoming connections.  It is
746 possible to bind tinc to a single interface like eth0 or ppp0 with this
747 variable.
748
749 @item InterfaceIP = <local address>
750 @cindex InterfaceIP
751 If your computer has more than one IP address on a single interface (for
752 example if you are running virtual hosts), tinc will by default listen
753 on all of them for incoming connections.  It is possible to bind tinc to
754 a single IP address with this variable.  It is still possible to listen
755 on several interfaces at the same time though, if they share the same IP
756 address.
757
758 @item KeyExpire = <seconds> (3600)
759 @cindex KeyExpire
760 This option controls the time the encryption keys used to encrypt the data
761 are valid.  It is common practice to change keys at regular intervals to
762 make it even harder for crackers, even though it is thought to be nearly
763 impossible to crack a single key.
764
765 @item @strong{Name = <name>}
766 @cindex Name
767 This is a symbolic name for this connection.  It can be anything
768
769 @item PingTimeout = <seconds> (60)
770 @cindex PingTimeout
771 The number of seconds of inactivity that tinc will wait before sending a
772 probe to the other end.  If that other end doesn't answer within that
773 same amount of seconds, the connection is terminated, and the others
774 will be notified of this.
775
776 @item PrivateKey = <key> [obsolete]
777 @cindex PrivateKey
778 This is the RSA private key for tinc. However, for safety reasons it is
779 advised to store private keys of any kind in separate files. This prevents
780 accidental eavesdropping if you are editting the configuration file.
781
782 @item @strong{PrivateKeyFile = <path>} [recommended]
783 @cindex PrivateKeyFile
784 This is the full path name of the RSA private key file that was
785 generated by ``tincd --generate-keys''.  It must be a full path, not a
786 relative directory.
787
788 @item @strong{TapDevice = <device>} (/dev/tap0 or /dev/net/tun)
789 @cindex TapDevice
790 The ethertap device to use.  Note that you can only use one device per
791 daemon.  The info pages of the tinc package contain more information
792 about configuring an ethertap device for Linux.
793
794 @end table
795
796
797 @c ==================================================================
798 @node    Host configuration variables, How to configure, Main configuration variables, Configuration files
799 @subsection Host configuration variables
800
801 @table @asis
802 @item @strong{Address = <IP address|hostname>} [recommended]
803 @cindex Address
804 This variable is only required if you want to connect to this host.  It
805 must resolve to the external IP address where the host can be reached,
806 not the one that is internal to the VPN.
807
808 @item IndirectData = <yes|no> (no) [experimental]
809 @cindex IndirectData
810 This option specifies whether other tinc daemons besides the one you
811 specified with ConnectTo can make a direct connection to you.  This is
812 especially useful if you are behind a firewall and it is impossible to
813 make a connection from the outside to your tinc daemon.  Otherwise, it
814 is best to leave this option out or set it to no.
815
816 @item Port = <port> (655)
817 @cindex Port
818 Connect to the upstream host (given with the ConnectTo directive) on
819 port port.  port may be given in decimal (default), octal (when preceded
820 by a single zero) o hexadecimal (prefixed with 0x).  port is the port
821 number for both the UDP and the TCP (meta) connections.
822
823 @item PublicKey = <key> [obsolete]
824 @cindex PublicKey
825 This is the RSA public key for this host.
826
827 @item PublicKeyFile = <path> [obsolete]
828 @cindex PublicKeyFile
829 This is the full path name of the RSA public key file that was generated
830 by ``tincd --generate-keys''.  It must be a full path, not a relative
831 directory.
832
833 @cindex PEM format
834 From version 1.0pre4 on tinc will store the public key directly into the
835 host configuration file in PEM format, the above two options then are not
836 necessary. Either the PEM format is used, or exactly
837 @strong{one of the above two options} must be specified
838 in each host configuration file, if you want to be able to establish a
839 connection with that host.
840
841 @item Subnet = <IP address/maskbits>
842 @cindex Subnet
843 This is the subnet range of all IP addresses that will be accepted by
844 the host that defines it.
845
846 The range must be contained in the IP address range of the tap device,
847 not the real IP address of the host running tincd.
848
849 @cindex CIDR notation
850 maskbits is the number of bits set to 1 in the netmask part; for
851 example: netmask 255.255.255.0 would become /24, 255.255.252.0 becomes
852 /22. This conforms to standard CIDR notation as described in
853 @uref{ftp://ftp.isi.edu/in-notes/rfc1519.txt, RFC1519}
854
855 @item TCPonly = <yes|no> (no) [experimental]
856 @cindex TCPonly
857 If this variable is set to yes, then the packets are tunnelled over a
858 TCP connection instead of a UDP connection.  This is especially useful
859 for those who want to run a tinc daemon from behind a masquerading
860 firewall, or if UDP packet routing is disabled somehow. This is
861 experimental code, try this at your own risk. It may not work at all.
862 Setting this options also implicitly sets IndirectData.
863 @end table
864
865
866 @c ==================================================================
867 @node    How to configure,  , Host configuration variables, Configuration files
868 @subsection How to configure
869
870 @subsubheading Step 1.  Creating the main configuration file
871
872 The main configuration file will be called @file{/etc/tinc/netname/tinc.conf}.
873 Adapt the following example to create a basic configuration file:
874
875 @example
876 Name = @emph{yourname}
877 TapDevice = @emph{/dev/tap0}
878 PrivateKeyFile = /etc/tinc/@emph{netname}/rsa_key.priv
879 @end example
880
881 Then, if you know to which other tinc daemon(s) yours is going to connect,
882 add `ConnectTo' values.
883
884 @subsubheading Step 2.  Creating your host configuration file
885
886 If you added a line containing `Name = yourname' in the main configuarion file,
887 you will need to create a host configuration file @file{/etc/tinc/netname/hosts/yourname}.
888 Adapt the following example to create a host configuration file:
889
890 @example
891 Address = @emph{your.real.hostname.org}
892 Subnet = @emph{192.168.1.0/24}
893 @end example
894
895 You can also use an IP address instead of a hostname.
896 The `Subnet' specifies the address range that is local for @emph{your part of the VPN only}.
897 If you have multiple address ranges you can specify more than one `Subnet'.
898 You might also need to add a `Port' if you want your tinc daemon to run on a different port number than the default (655).
899
900
901 @c ==================================================================
902 @node    Generating keypairs, Network interfaces, Configuration files, Configuration
903 @section Generating keypairs
904
905 @cindex key generation
906 Now that you have already created the main configuration file and your host configuration file,
907 you can easily create a public/private keypair by entering the following command:
908
909 @example
910 tincd -n @emph{netname} -K
911 @end example
912
913 tinc will generate a public and a private key and ask you where to put them.
914 Just press enter to accept the defaults.
915
916
917 @c ==================================================================
918 @node    Network interfaces, Example configuration, Generating keypairs, Configuration
919 @section Network interfaces
920
921 Before tinc can start transmitting data over the tunnel, it must
922 set up the ethertap network devices.
923
924 First, decide which IP addresses you want to have associated with these
925 devices, and what network mask they must have.
926
927 tinc will open an ethertap device or TUN/TAP device, which will also
928 create a network interface called `tap0', or `tap1', and so on if you are using
929 the ethertap driver, or a network interface with the same name as netname
930 if you are using the universal TUN/TAP driver.
931
932 @cindex tinc-up
933 You can configure that device by putting ordinary ifconfig, route, and other commands
934 to a script named @file{/etc/tinc/netname/tinc-up}. When tinc starts, this script
935 will be executed. When tinc exits, it will execute the script named
936 @file{/etc/tinc/netname/tinc-down}, but normally you don't need to create that script.
937
938 An example @file{tinc-up} script when using the TUN/TAP driver:
939
940 @example
941 #!/bin/sh
942 ifconfig $NETNAME hw ether fe:fd:00:00:00:00
943 ifconfig $NETNAME @emph{xx}.@emph{xx}.@emph{xx}.@emph{xx} netmask @emph{mask}
944 ifconfig $NETNAME -arp
945 @end example
946
947 @cindex MAC address
948 @cindex hardware address
949 The first line sets up the MAC address of the network interface.
950 Due to the nature of how Ethernet and tinc work, it has to be set to fe:fd:00:00:00:00.
951 (tinc versions prior to 1.0pre3 required that the MAC address matched the IP address.)
952 You can use the environment variable $NETNAME to get the name of the interface.
953 If you are using the ethertap driver however, you need to replace it with tap@emph{N},
954 corresponding to the device file name.
955
956 @cindex ifconfig
957 The next line gives the interface an IP address and a netmask.
958 The kernel will also automatically add a route to this interface, so normally you don't need
959 to add route commands to the @file{tinc-up} script.
960 The kernel will also bring the interface up after this command.
961 @cindex netmask
962 The netmask is the mask of the @emph{entire} VPN network, not just your
963 own subnet.
964
965 @cindex arp
966 The last line tells the kernel not to use ARP on that interface.
967 Again this has to do with how Ethernet and tinc work. Don't forget to add this line.
968
969
970 @c ==================================================================
971 @node    Example configuration,  , Network interfaces, Configuration
972 @section Example configuration
973
974
975 @cindex example
976 Imagine the following situation.  Branch A of our example `company' wants to connect
977 three branch offices in B, C and D using the Internet.  All four offices
978 have a 24/7 connection to the Internet.
979
980 A is going to serve as the center of the network.  B and C will connect
981 to A, and D will connect to C.  Each office will be assigned their own IP
982 network, 10.x.0.0.
983
984 @example
985 A: net 10.1.0.0 mask 255.255.0.0 gateway 10.1.54.1 internet IP 1.2.3.4
986 B: net 10.2.0.0 mask 255.255.0.0 gateway 10.2.1.12 internet IP 2.3.4.5
987 C: net 10.3.0.0 mask 255.255.0.0 gateway 10.3.69.254 internet IP 3.4.5.6
988 D: net 10.4.0.0 mask 255.255.0.0 gateway 10.4.3.32 internet IP 4.5.6.7
989 @end example
990
991 ``gateway'' is the VPN IP address of the machine that is running the
992 tincd.  ``internet IP'' is the IP address of the firewall, which does not
993 need to run tincd, but it must do a port forwarding of TCP&UDP on port
994 655 (unless otherwise configured).
995
996 In this example, it is assumed that eth0 is the interface that points to
997 the inner (physical) LAN of the office, although this could also be the
998 same as the interface that leads to the Internet.  The configuration of
999 the real interface is also shown as a comment, to give you an idea of
1000 how these example host is set up. All branches use the netname `company'
1001 for this particular VPN.
1002
1003 @subsubheading For Branch A
1004
1005 @emph{BranchA} would be configured like this:
1006
1007 In @file{/etc/tinc/company/tinc-up}:
1008
1009 @example
1010 # Real interface of internal network:
1011 # ifconfig eth0 10.1.54.1 netmask 255.255.0.0 broadcast 10.1.255.255
1012
1013 ifconfig tap0 hw ether fe:fd:00:00:00:00
1014 ifconfig tap0 10.1.54.1 netmask 255.0.0.0
1015 ifconfig tap0 -arp
1016 @end example
1017
1018 and in @file{/etc/tinc/company/tinc.conf}:
1019
1020 @example
1021 Name = BranchA
1022 PrivateKey = /etc/tinc/company/rsa_key.priv
1023 TapDevice = /dev/tap0
1024 @end example
1025
1026 On all hosts, /etc/tinc/company/hosts/BranchA contains:
1027
1028 @example
1029 Subnet = 10.1.0.0/16
1030 Address = 1.2.3.4
1031
1032 Note that the IP addresses of eth0 and tap0 are the same.
1033 This is quite possible, if you make sure that the netmasks of the interfaces are different.
1034 It is in fact recommended to give give both real internal network interfaces and tap interfaces the same IP address,
1035 since that will make things a lot easier to remember and set up.
1036
1037 -----BEGIN RSA PUBLIC KEY-----
1038 ...
1039 -----END RSA PUBLIC KEY-----
1040 @end example
1041
1042
1043 @subsubheading For Branch B
1044
1045 In @file{/etc/tinc/company/tinc-up}:
1046
1047 @example
1048 # Real interface of internal network:
1049 # ifconfig eth0 10.2.43.8 netmask 255.255.0.0 broadcast 10.2.255.255
1050
1051 ifconfig tap0 hw ether fe:fd:00:00:00:00
1052 ifconfig tap0 10.2.1.12 netmask 255.0.0.0
1053 ifconfig tap0 -arp
1054 @end example
1055
1056 and in @file{/etc/tinc/company/tinc.conf}:
1057
1058 @example
1059 Name = BranchB
1060 ConnectTo = BranchA
1061 PrivateKey = /etc/tinc/company/rsa_key.priv
1062 @end example
1063
1064 Note here that the internal address (on eth0) doesn't have to be the
1065 same as on the tap0 device.  Also, ConnectTo is given so that no-one can
1066 connect to this node.
1067
1068 On all hosts, in @file{/etc/tinc/company/hosts/BranchB}:
1069
1070 @example
1071 Subnet = 10.2.0.0/16
1072 Address = 2.3.4.5
1073
1074 -----BEGIN RSA PUBLIC KEY-----
1075 ...
1076 -----END RSA PUBLIC KEY-----
1077 @end example
1078
1079
1080 @subsubheading For Branch C
1081
1082 In @file{/etc/tinc/company/tinc-up}:
1083
1084 @example
1085 # Real interface of internal network:
1086 # ifconfig eth0 10.3.69.254 netmask 255.255.0.0 broadcast 10.3.255.255
1087
1088 ifconfig tap1 hw ether fe:fd:00:00:00:00
1089 ifconfig tap1 10.3.69.254 netmask 255.0.0.0
1090 ifconfig tap1 -arp
1091 @end example
1092
1093 and in @file{/etc/tinc/company/tinc.conf}:
1094
1095 @example
1096 Name = BranchC
1097 ConnectTo = BranchA
1098 TapDevice = /dev/tap1
1099 @end example
1100
1101 C already has another daemon that runs on port 655, so they have to
1102 reserve another port for tinc. It knows the portnumber it has to listen on
1103 from it's own host configuration file.
1104
1105 On all hosts, in @file{/etc/tinc/company/hosts/BranchC}:
1106
1107 @example
1108 Address = 3.4.5.6
1109 Subnet = 10.3.0.0/16
1110 Port = 2000
1111
1112 -----BEGIN RSA PUBLIC KEY-----
1113 ...
1114 -----END RSA PUBLIC KEY-----
1115 @end example
1116
1117
1118 @subsubheading For Branch D
1119
1120 In @file{/etc/tinc/company/tinc-up}:
1121
1122 @example
1123 # Real interface of internal network:
1124 # ifconfig eth0 10.4.3.32 netmask 255.255.0.0 broadcast 10.4.255.255
1125
1126 ifconfig company hw ether fe:fd:0a:04:03:20
1127 ifconfig company 10.4.3.32 netmask 255.0.0.0
1128 ifconfig company -arp
1129 @end example
1130
1131 and in @file{/etc/tinc/company/tinc.conf}:
1132
1133 @example
1134 Name = BranchD
1135 ConnectTo = BranchC
1136 TapDevice = /dev/net/tun
1137 PrivateKeyFile = /etc/tinc/company/rsa_key.priv
1138 @end example
1139
1140 D will be connecting to C, which has a tincd running for this network on
1141 port 2000. It knows the port number from the host configuration file.
1142 Also note that since D uses the TUN/TAP driver, the network interface
1143 will not be called `tun' or `tap0' or something like that, but will
1144 have the same name as netname.
1145
1146 On all hosts, in @file{/etc/tinc/company/hosts/BranchD}:
1147
1148 @example
1149 Subnet = 10.4.0.0/16
1150 Address = 4.5.6.7
1151
1152 -----BEGIN RSA PUBLIC KEY-----
1153 ...
1154 -----END RSA PUBLIC KEY-----
1155 @end example
1156
1157 @subsubheading Key files
1158
1159 A, B, C and D all have generated a public/private keypair with the following command:
1160
1161 @example
1162 tincd -n company -K
1163 @end example
1164
1165 The private key is stored in @file{/etc/tinc/company/rsa_key.priv},
1166 the public key is put into the host configuration file in the @file{/etc/tinc/company/hosts/} directory.
1167 During key generation, tinc automatically guesses the right filenames based on the -n option and
1168 the Name directive in the @file{tinc.conf} file (if it is available).
1169
1170 @subsubheading Starting
1171
1172 After each branch has finished configuration and they have distributed
1173 the host configuration files amongst them, they can start their tinc daemons.
1174 They don't necessarily have to wait for the other branches to have started
1175 their daemons, tinc will try connecting until they are available.
1176
1177
1178 @c ==================================================================
1179 @node    Running tinc, Technical information, Configuration, Top
1180 @chapter Running tinc
1181
1182 If everything else is done, you can start tinc by typing the following command:
1183
1184 @example
1185 tincd -n @emph{netname}
1186 @end example
1187
1188 @cindex daemon
1189 tinc will detach from the terminal and continue to run in the background like a good daemon.
1190 If there are any problems however you can try to increase the debug level
1191 and look in the syslog to find out what the problems are.
1192
1193 @menu
1194 * Runtime options::
1195 * Error messages::
1196 @end menu
1197
1198
1199 @c ==================================================================
1200 @node    Runtime options, Error messages,  , Running tinc
1201 @section Runtime options
1202
1203 Besides the settings in the configuration file, tinc also accepts some
1204 command line options.
1205
1206 This list is a longer version of that in the manpage.  The latter is
1207 generated automatically, so may be more up-to-date.
1208
1209 @cindex command line
1210 @cindex runtime options
1211 @cindex options
1212 @c from the manpage
1213 @table @samp
1214 @item -c, --config=PATH
1215 Read configuration options from the directory PATH.  The default is
1216 @file{/etc/tinc/netname/}.
1217
1218 @cindex debug level
1219 @item -d
1220 Increase debug level.  The higher it gets, the more gets
1221 logged.  Everything goes via syslog.
1222
1223 0 is the default, only some basic information connection attempts get
1224 logged.  Setting it to 1 will log a bit more, still not very
1225 disturbing.  With two -d's tincd will log protocol information, which can
1226 get pretty noisy.  Three or more -d's will output every single packet
1227 that goes out or comes in, which probably generates more data than the
1228 packets themselves.
1229
1230 @item -k, --kill
1231 Attempt to kill a running tincd and exit.  A TERM signal (15) gets sent
1232 to the daemon that his its PID in /var/run/tinc.pid.
1233
1234 Because it kills only one tinc daemon, you should use -n here if you
1235 started it that way.  It will then read the PID from
1236 @file{/var/run/tinc.NETNAME.pid}.
1237
1238 @item -n, --net=NETNAME
1239 Connect to net NETNAME.  @xref{Multiple networks}.
1240
1241 @item -K, --generate-keys[=BITS]
1242 Generate public/private keypair of BITS length. If BITS is not specified,
1243 1024 is the default. tinc will ask where you want to store the files,
1244 but will default to the configuration directory (you can use the -c or -n option
1245 in combination with -K). After that, tinc will quit.
1246
1247 @item --help
1248 Display a short reminder of these runtime options and terminate.
1249
1250 @item --version
1251 Output version information and exit.
1252
1253 @end table
1254
1255
1256 @c ==================================================================
1257 @node    Error messages,  , Runtime options, Running tinc
1258 @section Error messages
1259
1260 What follows is a list of the most common error messages you can see
1261 when configuring tinc.  Most of these messages are visible in the syslog
1262 only, so keep an eye on it!
1263
1264 @table @strong
1265 @item Could not open /dev/tap0: No such device
1266
1267 @itemize
1268 @item You forgot to `modprobe netlink_dev' or `modprobe ethertap'.
1269 @item You forgot to compile `Netlink device emulation' in the kernel.
1270 @end itemize
1271
1272 @item Can't write to /dev/net/tun: No such device
1273
1274 @itemize
1275 @item You forgot to `modprobe tun'.
1276 @item You forgot to compile `Universal TUN/TAP driver' in the kernel.
1277 @end itemize
1278
1279 @item Packet with destination 1.2.3.4 is looping back to us!
1280
1281 @itemize
1282 @item Something is not configured right. Packets are being sent out to the
1283 tap device, but according to the Subnet directives in your host configuration
1284 file, those packets should go to your own host. Most common mistake is that
1285 you have a Subnet line in your host configuration file with a netmask which is
1286 just as large as the netmask of the tap device. The latter should in almost all
1287 cases be larger. Rethink your configuration.
1288 Note that you will only see this message if you specified a debug
1289 level of 5 or higher!
1290 @item Chances are that a `Subnet = ...' line in the host configuration file of this tinc daemon is wrong.
1291 Change it to a subnet that is accepted locally by another interface,
1292 or if that is not the case, try changing the prefix length into /32. 
1293 @end itemize
1294
1295 @item Network doesn't work, syslog shows only packets of length 46
1296
1297 @cindex arp
1298 @example
1299 Jan 1 12:00:00 host tinc.net[1234]: Read packet of length 46 from tap device
1300 Jan 1 12:00:00 host tinc.net[1234]: Trying to look up 0.0.192.168 in connection list failed!
1301 @end example
1302 @itemize
1303 @item Add the `ifconfig $NETNAME -arp' to tinc-up.
1304 @end itemize
1305
1306 @item Network address and subnet mask do not match!
1307
1308 @itemize
1309 @item The Subnet field must contain a @emph{network} address.
1310 @item If you only want to use one IP address, set the netmask to /32.
1311 @end itemize
1312
1313 @item This is a bug: net.c:253: 24: Some error
1314
1315 @itemize
1316 @item This is something that should not have happened.
1317 Please report this, and tell us exactly what went wrong before you got
1318 this message.  In normal operation, these errors should not occur.
1319 @end itemize
1320
1321 @item Error reading RSA key file `rsa_key.priv': No such file or directory
1322
1323 @itemize
1324 @item You must specify the complete pathname.
1325 Specifying a relative path does not make sense here.  tinc changes its
1326 directory to / when starting (to avoid keeping a mount point busy); and
1327 even if we built in a default directory to look for these files, the key
1328 files are bound to be in a different directory.
1329 @end itemize
1330
1331 @end table
1332
1333 @c ==================================================================
1334 @node    Technical information, About us, Running tinc, Top
1335 @chapter Technical information
1336
1337
1338 @menu
1339 * The connection::
1340 * The meta-protocol::
1341 * Security::
1342 @end menu
1343
1344
1345 @c ==================================================================
1346 @node    The connection, The meta-protocol, Technical information, Technical information
1347 @section The connection
1348
1349 @cindex connection
1350 tinc is a daemon that takes VPN data and transmit that to another host
1351 computer over the existing Internet infrastructure.
1352
1353 @menu
1354 * The UDP tunnel::
1355 * The meta-connection::
1356 @end menu
1357
1358
1359 @c ==================================================================
1360 @node    The UDP tunnel, The meta-connection, The connection, The connection
1361 @subsection The UDP tunnel
1362
1363 @cindex ethertap
1364 @cindex frame type
1365 The data itself is read from a character device file, the so-called
1366 @emph{ethertap} device.  This device is associated with a network
1367 interface.  Any data sent to this interface can be read from the device,
1368 and any data written to the device gets sent from the interface.  Data to
1369 and from the device is formatted as if it were a normal Ethernet card,
1370 so a frame is preceded by two MAC addresses and a @emph{frame type}
1371 field.
1372
1373 So when tinc reads an Ethernet frame from the device, it determines its
1374 type.  Right now, tinc can only handle Internet Protocol version 4 (IPv4)
1375 frames, because it needs IP headers for routing.
1376 Plans to support other protocols and switching instead of routing are being made.
1377 (Some code for IPv6 routing and switching is already present but nonfunctional.)
1378 When tinc knows
1379 which type of frame it has read, it can also read the source and
1380 destination address from it.
1381
1382 Now it is time that the frame gets encrypted.  Currently the only
1383 encryption algorithm available is blowfish.
1384
1385 @cindex encapsulating
1386 @cindex UDP
1387 When the encryption is ready, time has come to actually transport the
1388 packet to the destination computer.  We do this by sending the packet
1389 over an UDP connection to the destination host.  This is called
1390 @emph{encapsulating}, the VPN packet (though now encrypted) is
1391 encapsulated in another IP datagram.
1392
1393 When the destination receives this packet, the same thing happens, only
1394 in reverse.  So it does a decrypt on the contents of the UDP datagram,
1395 and it writes the decrypted information to its own ethertap device.
1396
1397 To let the kernel on the receiving end accept the packet, the destination MAC
1398 address must match that of the tap interface. Because of the routing nature
1399 of tinc, ARP is not possible. tinc solves this by always overwriting the
1400 destination MAC address with fe:fd:0:0:0:0. That is also the reason why you must
1401 set the MAC address of your tap interface to that address.
1402
1403
1404 @c ==================================================================
1405 @node    The meta-connection,  , The UDP tunnel, The connection
1406 @subsection The meta-connection
1407
1408 Having only an UDP connection available is not enough.  Though suitable
1409 for transmitting data, we want to be able to reliably send other
1410 information, such as routing and session key information to somebody.
1411
1412 @cindex TCP
1413 TCP is a better alternative, because it already contains protection
1414 against information being lost, unlike UDP.
1415
1416 So we establish two connections.  One for the encrypted VPN data, and one
1417 for other information, the meta-data.  Hence, we call the second
1418 connection the meta-connection.  We can now be sure that the
1419 meta-information doesn't get lost on the way to another computer.
1420
1421 @cindex data-protocol
1422 @cindex meta-protocol
1423 Like with any communication, we must have a protocol, so that everybody
1424 knows what everything stands for, and how she should react.  Because we
1425 have two connections, we also have two protocols.  The protocol used for
1426 the UDP data is the ``data-protocol,'' the other one is the
1427 ``meta-protocol.''
1428
1429 The reason we don't use TCP for both protocols is that UDP is much
1430 better for encapsulation, even while it is less reliable.  The real
1431 problem is that when TCP would be used to encapsulate a TCP stream
1432 that's on the private network, for every packet sent there would be
1433 three ACKs sent instead of just one.  Furthermore, if there would be
1434 a timeout, both TCP streams would sense the timeout, and both would
1435 start re-sending packets.
1436
1437
1438 @c ==================================================================
1439 @node    The meta-protocol, Security, The connection, Technical information
1440 @section The meta-protocol
1441
1442 The meta protocol is used to tie all tinc daemons together, and
1443 exchange information about which tinc daemon serves which virtual
1444 subnet.
1445
1446 The meta protocol consists of requests that can be sent to the other
1447 side.  Each request has a unique number and several parameters.  All
1448 requests are represented in the standard ASCII character set.  It is
1449 possible to use tools such as telnet or netcat to connect to a tinc
1450 daemon and to read and write requests by hand, provided that one
1451 understands the numeric codes sent.
1452
1453 The authentication scheme is described in @ref{Authentication protocol}. After a
1454 succesful authentication, the server and the client will exchange all the
1455 information about other tinc daemons and subnets they know of, so that both
1456 sides (and all the other tinc daemons behind them) have their information
1457 synchronised.
1458
1459 @cindex ADD_HOST
1460 @cindex ADD_SUBNET
1461 @example
1462 daemon  message
1463 --------------------------------------------------------------------------
1464 origin  ADD_HOST daemon a329e18c:655 0
1465                     |         |      +--> options
1466                     |         +---------> real address:port
1467                     +-------------------> name of new tinc daemon
1468 origin  ADD_SUBNET daemon 1,0a010100/ffffff00
1469                       |   |     |       +--> netmask
1470                       |   |     +----------> vpn IPv4 network address
1471                       |   +----------------> subnet type (1=IPv4)
1472                       +--------------------> owner of this subnet
1473 --------------------------------------------------------------------------
1474 @end example
1475
1476 @cindex DEL_HOST
1477 @cindex DEL_SUBNET
1478 In case daemons leave the VPN, DEL_HOST and DEL_SUBNET messages with exactly
1479 the same syntax are sent to inform the other daemons of the departure.
1480
1481 The keys used to encrypt VPN packets are not sent out directly. This is
1482 because it would generate a lot of traffic on VPNs with many daemons, and
1483 chances are that not every tinc daemon will ever send a packet to every
1484 other daemon. Instead, if a daemon needs a key it sends a request for it
1485 via the meta connection of the nearest hop in the direction of the
1486 destination. If any hop on the way has already learned the key, it will
1487 act as a proxy and forward it's copy back to the requestor.
1488
1489 @cindex REQ_KEY
1490 @cindex ANS_KEY
1491 @cindex KEY_CHANGED
1492 @example
1493 daemon  message
1494 --------------------------------------------------------------------------
1495 daemon  REQ_KEY origin destination
1496                    |       +--> name of the tinc daemon it wants the key from
1497                    +----------> name of the daemon that wants the key      
1498 daemon  ANS_KEY origin destination e4ae0b0a82d6e0078179b5290c62c7d0
1499                    |       |       \______________________________/
1500                    |       |                      +--> 128 bits key
1501                    |       +--> name of the daemon that wants the key
1502                    +----------> name of the daemon that uses this key
1503 daemon  KEY_CHANGED origin
1504                       +--> daemon that has changed it's packet key
1505 --------------------------------------------------------------------------
1506 @end example
1507
1508 There is also a mechanism to check if hosts are still alive. Since network
1509 failures or a crash can cause a daemon to be killed without properly
1510 shutting down the TCP connection, this is necessary to keep an up to date
1511 connection list. PINGs are sent at regular intervals, except when there
1512 is also some other traffic. A little bit of salt (random data) is added
1513 with each PING and PONG message, to make sure that long sequences of PING/PONG
1514 messages without any other traffic won't result in known plaintext.
1515
1516 @cindex PING
1517 @cindex PONG
1518 @example
1519 daemon  message
1520 --------------------------------------------------------------------------
1521 origin  PING 9e76
1522              \__/
1523                +--> 2 bytes of salt (random data)
1524 dest.   PONG 3b8d
1525              \__/
1526                +--> 2 bytes of salt (random data)
1527 --------------------------------------------------------------------------
1528 @end example
1529
1530 This basically covers what is sent over the meta connection by
1531 tinc.
1532
1533
1534 @c ==================================================================
1535 @node    Security,  , The meta-protocol, Technical information
1536 @section About tinc's encryption and other security-related issues.
1537
1538 @cindex TINC
1539 @cindex Cabal
1540 tinc got its name from ``TINC,'' short for @emph{There Is No Cabal}; the
1541 alleged Cabal was/is an organisation that was said to keep an eye on the
1542 entire Internet.  As this is exactly what you @emph{don't} want, we named
1543 the tinc project after TINC.
1544
1545 @cindex SVPN
1546 But in order to be ``immune'' to eavesdropping, you'll have to encrypt
1547 your data.  Because tinc is a @emph{Secure} VPN (SVPN) daemon, it does
1548 exactly that: encrypt.
1549 tinc uses blowfish encryption in CBC mode and a small amount of salt
1550 at the beginning of each packet to make sure eavesdroppers cannot get
1551 any information at all from the packets they can intercept.
1552
1553 @menu
1554 * Authentication protocol::
1555 * Encryption of network packets::
1556 @end menu
1557
1558
1559 @c ==================================================================
1560 @node    Authentication protocol, Encryption of network packets, Security, Security
1561 @subsection Authentication protocol
1562
1563 @cindex authentication
1564 A new scheme for authentication in tinc has been devised, which offers some
1565 improvements over the protocol used in 1.0pre2 and 1.0pre3. Explanation is
1566 below.
1567
1568 @example
1569 daemon  message
1570 --------------------------------------------------------------------------
1571 client  <attempts connection>
1572
1573 server  <accepts connection>
1574
1575 client  ID client 10 0
1576               |    | +-> options
1577               |    +---> version
1578               +--------> name of tinc daemon
1579
1580 server  ID server 10 0
1581               |    | +-> options
1582               |    +---> version
1583               +--------> name of tinc daemon
1584
1585 client  META_KEY 5f0823a93e35b69e...7086ec7866ce582b
1586                  \_________________________________/
1587                                  +-> RSAKEYLEN bits totally random string S1,
1588                                      encrypted with server's public RSA key
1589
1590 server  META_KEY 6ab9c1640388f8f0...45d1a07f8a672630
1591                  \_________________________________/
1592                                  +-> RSAKEYLEN bits totally random string S2,
1593                                      encrypted with client's public RSA key
1594
1595 From now on:
1596  - the client will encrypt outgoing traffic using S1
1597  - the server will encrypt outgoing traffic using S2
1598
1599 client  CHALLENGE da02add1817c1920989ba6ae2a49cecbda0
1600                   \_________________________________/
1601                                  +-> CHALLEN bits totally random string H1
1602
1603 server  CHALLENGE 57fb4b2ccd70d6bb35a64c142f47e61d57f
1604                   \_________________________________/
1605                                  +-> CHALLEN bits totally random string H2
1606
1607 client  CHAL_REPLY 816a86
1608                       +-> 160 bits SHA1 of H2
1609
1610 server  CHAL_REPLY 928ffe
1611                       +-> 160 bits SHA1 of H1
1612 --------------------------------------------------------------------------
1613 @end example
1614
1615 This new scheme has several improvements, both in efficiency and security.
1616
1617 First of all, the server sends exactly the same kind of messages over the wire
1618 as the client. The previous versions of tinc first authenticated the client,
1619 and then the server. This scheme even allows both sides to send their messages
1620 simultaneously, there is no need to wait for the other to send something first.
1621 This means that any calculations that need to be done upon sending or receiving
1622 a message can also be done in parallel. This is especially important when doing
1623 RSA encryption/decryption. Given that these calculations are the main part of
1624 the CPU time spent for the authentication, speed is improved by a factor 2.
1625
1626 Second, only one RSA encrypted message is sent instead of two. This reduces the
1627 amount of information attackers can see (and thus use for a cryptographic
1628 attack). It also improves speed by a factor two, making the total speedup a
1629 factor 4.
1630
1631 Third, and most important:
1632 The symmetric cipher keys are exchanged first, the challenge is done
1633 afterwards. In the previous authentication scheme, because a man-in-the-middle
1634 could pass the challenge/chal_reply phase (by just copying the messages between
1635 the two real tinc daemons), but no information was exchanged that was really
1636 needed to read the rest of the messages, the challenge/chal_reply phase was of
1637 no real use. The man-in-the-middle was only stopped by the fact that only after
1638 the ACK messages were encrypted with the symmetric cipher. Potentially, it
1639 could even send it's own symmetric key to the server (if it knew the server's
1640 public key) and read some of the metadata the server would send it (it was
1641 impossible for the mitm to read actual network packets though). The new scheme
1642 however prevents this.
1643
1644 This new scheme makes sure that first of all, symmetric keys are exchanged. The
1645 rest of the messages are then encrypted with the symmetric cipher. Then, each
1646 side can only read received messages if they have their private key. The
1647 challenge is there to let the other side know that the private key is really
1648 known, because a challenge reply can only be sent back if the challenge is
1649 decrypted correctly, and that can only be done with knowledge of the private
1650 key.
1651
1652 Fourth: the first thing that is send via the symmetric cipher encrypted
1653 connection is a totally random string, so that there is no known plaintext (for
1654 an attacker) in the beginning of the encrypted stream.
1655
1656
1657 @c ==================================================================
1658 @node    Encryption of network packets,  , Authentication protocol, Security
1659 @subsection Encryption of network packet
1660 @cindex encryption
1661
1662 A data packet can only be sent if the encryption key is known to both
1663 parties, and the connection is  activated. If the encryption key is not
1664 known, a request is sent to the destination using the meta connection
1665 to retreive it. The packet is stored in a queue while waiting for the
1666 key to arrive.
1667
1668 @cindex UDP
1669 The UDP packet containing the network packet from the VPN has the following layout:
1670
1671 @example
1672 ... | IP header | UDP header | salt | VPN packet | UDP trailer
1673                              \___________________/
1674                                        |
1675                                        V
1676                          Encrypted with symmetric cipher
1677 @end example
1678
1679 So, the entire UDP payload is encrypted using a symmetric cipher (blowfish in CBC mode).
1680 2 bytes of salt (random data) are added in front of the actual VPN packet,
1681 so that two VPN packets with (almost) the same content do not seem to be
1682 the same for eavesdroppers.
1683 2 bytes of salt may not seem much, but you can encrypt 65536 identical packets
1684 now without an attacker being able to see that they were identical.
1685 Given a MTU of 1500 this means 96 Megabyte of data.
1686
1687 There is no @emph{extra} provision against replay attacks or alteration of packets.
1688 However, the VPN packets, normally UDP or TCP packets themselves, contain
1689 checksums and sequence numbers.
1690 Since those checksums and sequence numbers are encrypted,
1691 they automatically become @emph{cryptographically secure}.
1692 The kernel will handle any checksum errors and duplicate packets.
1693
1694
1695 @c ==================================================================
1696 @node    About us, Concept Index, Technical information, Top
1697 @chapter About us
1698
1699
1700 @menu
1701 * Contact Information::
1702 * Authors::
1703 @end menu
1704
1705
1706 @c ==================================================================
1707 @node    Contact Information, Authors, About us, About us
1708 @section Contact information
1709
1710 @cindex website
1711 tinc's website is at @url{http://tinc.nl.linux.org/},
1712 this server is located in the Netherlands.
1713
1714 @cindex IRC
1715 We have an IRC channel on the Open Projects IRC network.  Connect to
1716 @uref{http://openprojects.nu/services/irc.html, irc.openprojects.net},
1717 and join channel #tinc.
1718
1719
1720 @c ==================================================================
1721 @node    Authors,  , Contact Information, About us
1722 @section Authors
1723
1724 @table @asis
1725 @item Ivo Timmermans (zarq) (@email{itimmermans@@bigfoot.com})
1726 Main coder/hacker and maintainer of the package.
1727
1728 @item Guus Sliepen (guus) (@email{guus@@sliepen.warande.net})
1729 Originator of it all, co-author.
1730
1731 @item Wessel Dankers (Ubiq) (@email{wsl@@nl.linux.org})
1732 For the name `tinc' and various suggestions.
1733
1734 @end table
1735
1736 We have received a lot of valuable input from users.  With their help,
1737 tinc has become the flexible and robust tool that it is today.  We have
1738 composed a list of contributions, in the file called @file{THANKS} in
1739 the source distribution.
1740
1741
1742 @c ==================================================================
1743 @node    Concept Index,  , About us, Top
1744 @c        node-name,    next, previous,        up
1745 @unnumbered Concept Index
1746
1747 @c ==================================================================
1748 @printindex cp
1749
1750
1751 @c ==================================================================
1752 @contents
1753 @bye