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