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