{"id":375,"date":"2017-08-29T15:22:11","date_gmt":"2017-08-29T07:22:11","guid":{"rendered":"https:\/\/blog.jsjs.org\/?p=375"},"modified":"2017-08-29T15:22:11","modified_gmt":"2017-08-29T07:22:11","slug":"how-to-install-and-configure-tinc-vpn-on-linux","status":"publish","type":"post","link":"https:\/\/blog.jsjs.org\/?p=375","title":{"rendered":"How to install and configure tinc VPN on Linux"},"content":{"rendered":"<header class=\"entry-header\">\n<h1 class=\"entry-title\"><a title=\"Permalink to How to install and configure tinc VPN on Linux\" href=\"http:\/\/xmodulo.com\/how-to-install-and-configure-tinc-vpn.html\" rel=\"bookmark\">How to install and configure tinc VPN on Linux<\/a><\/h1>\n<\/header>\n<div class=\"heatmapthemead-header-entry-meta entry-meta\"><span class=\"heatmapthemead-post-details\">Last updated on\u00a0<a title=\"1:58 am\" href=\"http:\/\/xmodulo.com\/how-to-install-and-configure-tinc-vpn.html\" rel=\"bookmark\"><time class=\"entry-date\" datetime=\"2012-05-26T01:58:00+00:00\">May 26, 2012<\/time><\/a><span class=\"byline\">\u00a0Authored by\u00a0<span class=\"author vcard\"><a class=\"url fn n\" title=\"View all posts by Dan Nanni\" href=\"http:\/\/xmodulo.com\/author\/nanni\" rel=\"author\">Dan Nanni<\/a><\/span><\/span><\/span> <span class=\"comments-link\"><a href=\"http:\/\/xmodulo.com\/how-to-install-and-configure-tinc-vpn.html#comments\">3 Comments<\/a><\/span><\/div>\n<div class=\"entry-content\">\n<p><a href=\"http:\/\/list.xmodulo.com\/tinc.html\" target=\"_blank\" rel=\"noopener\">Tinc<\/a>\u00a0is an open-source VPN software with a number of powerful features not found in other VPN solutions. \u00a0For example, tinc allows peers behind NAT to communicate with one another via VPN directly, not through a third party. \u00a0Other features include full IPv6 support and path MTU discovery.<\/p>\n<p>In this\u00a0<b>tinc example<\/b>, I will show you how to set up a VPN connection between two hosts via tinc. Let&#8217;s call these hosts &#8220;alice&#8221; and &#8220;bob&#8221; respectively. Note that these are just symbolic names used by tinc, not necessarily hostnames. In this example, I assume that host &#8220;bob&#8221; will initiate a VPN connection to host &#8220;alice&#8221;.<\/p>\n<p>First, install tinc on both hosts:<\/p>\n<p>For\u00a0<b>CentOS system<\/b>, first\u00a0<a href=\"http:\/\/xmodulo.com\/how-to-set-up-rpmforge-repoforge-repository-on-centos.html\" target=\"_blank\" rel=\"noopener\">set up RPMforge repository<\/a>. Then, do the following.<\/p>\n<div class=\"console\">$ sudo yum install tinc -y<\/div>\n<p>For\u00a0<b>Debian\/Ubuntu system<\/b>:<\/p>\n<div class=\"console\">$ sudo apt-get install tinc<\/div>\n<p>Now, let&#8217;s go ahead and configure tinc VPN on both hosts as follows.<\/p>\n<p>On host &#8220;alice&#8221;, do the following.<\/p>\n<div class=\"console\">$ sudo mkdir -p \/etc\/tinc\/myvpn\/hosts<\/div>\n<p>Then create a tinc configuration file called tinc.conf, and host configuration file(s) as follows.<\/p>\n<div class=\"console\">$ sudo vi \/etc\/tinc\/myvpn\/tinc.conf<\/div>\n<pre>Name = alice\nAddressFamily = ipv4\nInterface = tun0\n<\/pre>\n<p>In the above example, the directory &#8220;myvpn&#8221; under \/etc\/tinc is the name of the VPN network to be established between alice and bob. VPN name can be any alphanumeric name without containing &#8220;-&#8220;. In\u00a0<b>tinc.conf example<\/b>, &#8220;Name&#8221; field indicates the name of tinc-running local host, which doesn&#8217;t have to be actual hostname. You can choose any generic name.<\/p>\n<p>Next, create host configuration files which contain host-specific information.<\/p>\n<div class=\"console\">$ sudo vi \/etc\/tinc\/myvpn\/hosts\/alice<\/div>\n<pre>Address = 1.2.3.4\nSubnet = 10.0.0.1\/32\n<\/pre>\n<p>The name of host configuration file (e.g., alice) should be the same as the one you defined in tinc.conf. The &#8220;Address&#8221; field indicates a globally routable public IP address associated with alice. This field is required for at least one host in a given VPN network so that other hosts can initiate VPN connections to it. In this example, alice will serve as the bootstrapping server, and so has a public IP address (e.g., 1.2.3.4). The &#8220;Subnet&#8221; field indicates the VPN IP address to be assigned to alice.<\/p>\n<div><ins class=\"adsbygoogle\" data-ad-client=\"ca-pub-7245163904660683\" data-ad-slot=\"5795021983\" data-adsbygoogle-status=\"done\"><ins id=\"aswift_1_expand\"><ins id=\"aswift_1_anchor\"><iframe id=\"aswift_1\" name=\"aswift_1\" width=\"336\" height=\"280\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\" allowfullscreen=\"allowfullscreen\" data-mce-fragment=\"1\"><\/iframe><\/ins><\/ins><\/ins><\/div>\n<p>The next step is to generate public\/private keys.<\/p>\n<div class=\"console\">$ sudo tincd -n myvpn -K4096<\/div>\n<p>The above command will generate 4096-bit public\/private keys for host &#8220;alice&#8221;. The private key will be stored as \/etc\/tinc\/myvpn\/rsa_key.priv, and the public key will be appended to \/etc\/tinc\/myvpn\/hosts\/alice.<\/p>\n<p>Next, configure the scripts that will be run right after tinc daemon gets started, as well as right before tinc daemon is terminated.<\/p>\n<div class=\"console\">$ sudo vi \/etc\/tinc\/myvpn\/tinc-up<\/div>\n<pre>#!\/bin\/sh\nifconfig $INTERFACE 10.0.0.1 netmask 255.255.255.0\n<\/pre>\n<div class=\"console\">$ sudo vi \/etc\/tinc\/myvpn\/tinc-down<\/div>\n<pre>#!\/bin\/sh\nifconfig $INTERFACE down\n<\/pre>\n<div class=\"console\">$ sudo chmod 755 \/etc\/tinc\/myvpn\/tinc-*<\/div>\n<p>Now tinc configuration for host &#8220;alice&#8217; is done. Similar to alice, configure tinc on host &#8220;bob&#8221; as follows.<\/p>\n<div class=\"console\">$ sudo mkdir -p \/etc\/tinc\/myvpn<br \/>\n$ sudo vi \/etc\/tinc\/myvpn\/tinc.conf<\/div>\n<pre>Name = bob\nAddressFamily = ipv4\nInterface = tun0\nConnectTo = alice\n<\/pre>\n<p>In the above, note that unlike host &#8220;alice&#8221;, I put &#8220;ConnectTo&#8221; field in bob&#8217;s tinc configuration, since host &#8220;bob&#8221; will initiate a VPN connection to host &#8220;alice&#8221; when tinc daemon on bob is up.<\/p>\n<div class=\"console\">$ sudo vi \/etc\/tinc\/myvpn\/hosts\/bob<\/div>\n<pre>Subnet = 10.0.0.2\/32\n<\/pre>\n<div class=\"console\">$ sudo tincd -n myvpn -K4096<\/div>\n<p>Similarly, the bob&#8217;s private key will be stored as \/etc\/tinc\/myvpn\/rsa_key.priv, and its public key will be added to \/etc\/tinc\/myvpn\/hosts\/bob.<\/p>\n<div class=\"console\">$ sudo vi \/etc\/tinc\/myvpn\/tinc-up<\/div>\n<pre>ifconfig $INTERFACE 10.0.0.2 netmask 255.255.255.0\n<\/pre>\n<div class=\"console\">$ sudo vi \/etc\/tinc\/myvpn\/tinc-down<\/div>\n<pre>ifconfig $INTERFACE down\n<\/pre>\n<div class=\"console\">$ sudo chmod 755 \/etc\/tinc\/myvpn\/tinc-*<\/div>\n<p>Once you are done with configuring tinc on all hosts as above, copy each host&#8217;s public key file onto the other host:<\/p>\n<p>On host &#8220;alice&#8221;:<\/p>\n<div class=\"console\">$ scp \/etc\/tinc\/myvpn\/hosts\/alice root@bob:\/etc\/tinc\/myvpn\/hosts\/<\/div>\n<p>On host &#8220;bob&#8221;:<\/p>\n<div class=\"console\">$ scp \/etc\/tinc\/myvpn\/hosts\/bob root@alice:\/etc\/tinc\/myvpn\/hosts\/<\/div>\n<p>Finally, start tinc daemon on them as follows. \u00a0Since host &#8220;bob&#8221; initiates a VPN connection, you will need to start tinc daemon on host &#8220;alice&#8221; first, and then host &#8220;bob&#8221;.<\/p>\n<div class=\"console\">$ sudo tincd -n myvpn<\/div>\n<p>Two hosts should now be able to talk to each other via VPN IP addresses assigned to them.<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>How to install and configure tinc VPN on Linux Last updated on\u00a0May 26, 2012\u00a0Authored by\u00a0Dan Nanni 3 Comments Tinc\u00a0is an [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[1],"tags":[],"class_list":["post-375","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=\/wp\/v2\/posts\/375","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=375"}],"version-history":[{"count":0,"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=\/wp\/v2\/posts\/375\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=375"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=375"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=375"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}