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