tinc.texi 67 KB

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