{"id":1522,"date":"2014-10-01T16:44:32","date_gmt":"2014-10-01T14:44:32","guid":{"rendered":"http:\/\/www.moucha.cc\/charon\/?p=1522"},"modified":"2014-10-01T16:44:32","modified_gmt":"2014-10-01T14:44:32","slug":"l2tpipsec-vpn-client-on-fedora","status":"publish","type":"post","link":"https:\/\/www.moucha.cc\/charon\/l2tpipsec-vpn-client-on-fedora\/","title":{"rendered":"L2TP\/IPSec VPN client on Fedora"},"content":{"rendered":"<p>Follow the next steps to establish &#8220;road warrior&#8221; pre-shared secret L2TP VPN connection to remote VPN server (running RouterOS 5.24 in my case) from your Fedora system.<\/p>\n<p>Install ipsec and l2tp packages.<\/p>\n<pre>\r\n$ yum install libreswan xl2tpd\r\n<\/pre>\n<p>Main IPSec configuration is located in <code>\/etc\/ipsec.conf<\/code> and <code>\/etc\/ipsec.secrets<\/code>. You can review it, but no changes are required to Fedora&#8217;s default that basically enables NAT traversal and includes <code>\/etc\/ipsec.d\/*.conf<\/code> and <code>\/etc\/ipsec.d\/*.secrets<\/code> files into the configuration.<\/p>\n<p>Create new configuration file in <code>\/etc\/ipsec.d\/desired_vpn_name.conf<\/code> with following content and replace connection name and local and remote IPs.<\/p>\n<pre>\r\nconn VPN_CONNECTION_NAME\r\n authby=secret\r\n pfs=no\r\n auto=add\r\n keyingtries=3\r\n dpddelay=30\r\n dpdtimeout=120\r\n dpdaction=clear\r\n rekey=yes\r\n ikelifetime=8h\r\n keylife=1h\r\n type=transport\r\n left=YOUR_LOCAL_IP_ADDRESS\r\n leftnexthop=%defaultroute\r\n leftprotoport=17\/1701\r\n right=REMOTE_VPN_SERVER_IP_ADDRESS\r\n rightprotoport=17\/1701\r\n<\/pre>\n<p>Create new secrets file in <code>\/etc\/ipsec.d\/desired_vpn_name.secrets<\/code> with following content and replace remote server IP and pre-shared secret.<\/p>\n<pre>\r\n%any REMOTE_VPN_SERVER_IP_ADDRESS : PSK \"YOUR-PRE-SHARED-SECRET\"\r\n<\/pre>\n<p>Start IPSec daemon in foreground to ensure IPSec stack is in your kernel and testing your configuration later.<\/p>\n<pre>\r\n$ ipsec pluto --stderrlog --config \/etc\/ipsec.conf --nofork\r\n<\/pre>\n<p>If you find out following section in the output:<\/p>\n<pre>\r\nNo Kernel XFRM\/NETKEY interface detected\r\nNo Kernel KLIPS interface detected\r\nNo Kernel MASTKLIPS interface detected\r\nUsing 'no_kernel' interface code on 3.16.3-200.fc20.i686\r\n<\/pre>\n<p>it means there is no IPSec stack in your kernel and you have to load apropriate module into the kernel manually by:<\/p>\n<pre>\r\n$ modprobe af_key\r\n<\/pre>\n<p>If you have no IPSec stack in the kernel and continue you will get completely misleading error when trying to connect the tunnel.<\/p>\n<pre>\r\n022 \"VPN_CONNECTION_NAME\": We cannot identify ourselves with either end of this connection.\r\n<\/pre>\n<p>When everything is alright you should see just:<\/p>\n<pre>\r\nUsing Linux XFRM\/NETKEY IPsec interface code on 3.16.3-200.fc20.i686\r\n<\/pre>\n<p>Add your new connection by:<\/p>\n<pre>\r\n$ ipsec auto --add VPN_CONNECTION_NAME\r\n<\/pre>\n<p>Now configure L2TP part. Add a new section to <code>\/etc\/xl2tpd\/xl2tpd.conf<\/code> and replace connection name and remote server IP.<\/p>\n<pre>\r\n[lac VPN_CONNECTION_NAME]\r\nlns = REMOTE_VPN_SERVER_IP_ADDRESS\r\nppp debug = yes\r\npppoptfile = \/etc\/ppp\/options.xl2tpd.VPN_CONNECTION_NAME\r\nlength bit = yes\r\n<\/pre>\n<p>And create new file <code>\/etc\/ppp\/options.xl2tpd.VPN_CONNECTION_NAME<\/code> with your new PPP options and put there following configuration (replace username and password for authentication).<\/p>\n<pre>\r\nipcp-accept-local\r\nipcp-accept-remote\r\nrefuse-eap\r\nrequire-mschap-v2\r\nnoccp\r\nnoauth\r\nidle 1800\r\nmtu 1410\r\nmru 1410\r\ndefaultroute\r\nusepeerdns\r\ndebug\r\nlock\r\nconnect-delay 5000\r\nname AUTH_USERNAME\r\npassword AUTH_PASSWORD\r\n<\/pre>\n<p>Start all daemons and connect the tunnel<\/p>\n<pre>$ systemctl start ipsec\r\n$ systemctl start xl2tpd\r\n$ echo \"c VPN_CONNECTION_NAME\" &gt; \/var\/run\/xl2tpd\/l2tp-control\r\n<\/pre>\n<p>To disconnect do<\/p>\n<pre>\r\n$ echo \"d VPN_CONNECTION_NAME\" &gt; \/var\/run\/xl2tpd\/l2tp-control\r\n<\/pre>\n<p><em>Remind: if you successfully reached this point you have the tunnel only and you need to add your routes manually to access the networks behind the tunnel!<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Follow the next steps to establish &#8220;road warrior&#8221; pre-shared secret L2TP VPN connection to remote VPN server (running RouterOS 5.24 in my case) from your Fedora system. Install ipsec and l2tp packages. $ yum install libreswan xl2tpd Main IPSec configuration is located in \/etc\/ipsec.conf and \/etc\/ipsec.secrets. You can review it, but no changes are required&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[7,33],"tags":[73,55,70,71,72],"class_list":["post-1522","post","type-post","status-publish","format-standard","hentry","category-technology","category-work","tag-client","tag-fedora","tag-ipsec","tag-l2tp","tag-vpn"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p20Iro-oy","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.moucha.cc\/charon\/wp-json\/wp\/v2\/posts\/1522","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.moucha.cc\/charon\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.moucha.cc\/charon\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.moucha.cc\/charon\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.moucha.cc\/charon\/wp-json\/wp\/v2\/comments?post=1522"}],"version-history":[{"count":12,"href":"https:\/\/www.moucha.cc\/charon\/wp-json\/wp\/v2\/posts\/1522\/revisions"}],"predecessor-version":[{"id":1534,"href":"https:\/\/www.moucha.cc\/charon\/wp-json\/wp\/v2\/posts\/1522\/revisions\/1534"}],"wp:attachment":[{"href":"https:\/\/www.moucha.cc\/charon\/wp-json\/wp\/v2\/media?parent=1522"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.moucha.cc\/charon\/wp-json\/wp\/v2\/categories?post=1522"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.moucha.cc\/charon\/wp-json\/wp\/v2\/tags?post=1522"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}