{"id":357,"date":"2016-02-04T17:17:24","date_gmt":"2016-02-04T17:17:24","guid":{"rendered":"http:\/\/james-batchelor.com\/?p=357"},"modified":"2016-04-18T17:37:12","modified_gmt":"2016-04-18T17:37:12","slug":"osmc-on-pi-with-pptp-vpn","status":"publish","type":"post","link":"https:\/\/james-batchelor.com\/index.php\/2016\/02\/04\/osmc-on-pi-with-pptp-vpn\/","title":{"rendered":"OSMC on Pi with PPTP VPN"},"content":{"rendered":"<p>The arrival of the <a href=\"https:\/\/james-batchelor.com\/index.php\/2015\/10\/18\/raspberry-pi-2\/\">Raspberry Pi 2<\/a> meant the B+ previously used as a server was now ready for a new purpose. These little machines make great media players and is easy to setup so this would be its new role.<\/p>\n<p>However, this Pi would be in my parents\u2019 home, and miles away from where my videos are stored. I didn\u2019t want to add a hard drive locally as syncing the library would be an issue. But thanks to the fibre internet connection on the server side I could upload at 10Mbps, enough to stream media across the net.<\/p>\n<p>Therefore, the plan is to use an install of OSMC and add a VPN connection to my home server that starts when the Pi starts to make the operation seamless.<\/p>\n<p><!--more--><\/p>\n<h2>How To:<\/h2>\n<p>Start with a running Pi with OSMC on. Log in to the Pi via SSH using osmc for the username and password.<\/p>\n<p>When logged in, perform \u201csudo apt get update\u201d and \u201csudo apt get upgrade\u201d to ensure the latest software is installed, then install the PPTP client by running \u201csudo apt get install pptp-client\u201d<\/p>\n<p>With the PPTP client installed a connection file is needed, however the folder it needs to be in requires elevated privileges to access. So type \u201csudo bash\u201d to gain administrator control.<\/p>\n<p>Then navigate to the folder with <em>cd \/etc\/ppp\/peers<\/em><\/p>\n<p>Open a new text file using \u201cnano connectname\u201d where connectname is the name of the new file.<\/p>\n<p>Enter the following connection settings:<\/p>\n<blockquote><p>pty &#8220;pptp REMOTESERVER &#8211;nolaunchpppd &#8211;debug&#8221;<br \/>\nname USERNAME<br \/>\npassword PASSWORD<br \/>\nremotename PPTP<br \/>\nrequire-mppe-128<br \/>\nrequire-mschap-v2<br \/>\nrefuse-eap<br \/>\nrefuse-pap<br \/>\nrefuse-chap<br \/>\nrefuse-mschap<br \/>\nnoauth<br \/>\ndebug<br \/>\npersist<br \/>\nmaxfail 0<br \/>\ndefaultroute<br \/>\nreplacedefaultroute<br \/>\nusepeerdns<\/p><\/blockquote>\n<p>Where <em>REMOTESERVER<\/em>, <em>USERNAME<\/em> and <em>PASSWORD<\/em> are the address and credentials use to connect to the VPN.<\/p>\n<p>Type <em>Ctrl + O<\/em> to save and <em>Ctrl + X<\/em> to exit the text editor.<\/p>\n<p>The VPN connection can be tested by entering <em>pon connectname<\/em>, have a look on the server to see if a connection is established or typing <em>ifconfig<\/em>\u00a0in the terminal and look for a ppp0 adaptor. If it fails, use <em>poff connectname<\/em> to disconnect then edit the config file.<\/p>\n<p>With a successful connection made, next up is to make the connection start with the Pi, navigate to the home directory using <em>cd \/home\/osmc<\/em><\/p>\n<p>Create a script, by creating a text file with <em>nano connect.sh<\/em><\/p>\n<p>In the new file, enter the following:<\/p>\n<blockquote><p>#!\/bin\/bash<br \/>\nsudo pon hartland<\/p><\/blockquote>\n<p><em>Ctrl + O<\/em> to save and <em>Ctrl + X<\/em> to exit<\/p>\n<p>Make the file an executable using <em>chmod +x connect.sh<\/em><\/p>\n<p>With the script created and executable, edit the start-up file that will run the script when the Pi boots, open it by using <em>nano \/etc\/rc.local<\/em>, as this is editing an established file the following screen should appear:<\/p>\n<p><a href=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2016\/04\/14.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-358 size-full\" src=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2016\/04\/14.png\" alt=\"rc.local before\" width=\"661\" height=\"418\" srcset=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2016\/04\/14.png 661w, https:\/\/james-batchelor.com\/wp-content\/uploads\/2016\/04\/14-300x190.png 300w, https:\/\/james-batchelor.com\/wp-content\/uploads\/2016\/04\/14-624x395.png 624w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px\" \/><\/a><\/p>\n<p>After the lines starting with # and before <em>exit 0<\/em>, add the following line:<\/p>\n<p><em>(sleep 20;sudo \/home\/osmc\/connectvpn.sh)&amp;<\/em><\/p>\n<p>So the file looks like the following:<\/p>\n<p><a href=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2016\/04\/15.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-359 size-full\" src=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2016\/04\/15.png\" alt=\"rc.local after\" width=\"661\" height=\"418\" srcset=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2016\/04\/15.png 661w, https:\/\/james-batchelor.com\/wp-content\/uploads\/2016\/04\/15-300x190.png 300w, https:\/\/james-batchelor.com\/wp-content\/uploads\/2016\/04\/15-624x395.png 624w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px\" \/><\/a><\/p>\n<p><em>Ctrl + O<\/em> to save, <em>Ctrl + X<\/em> to exit and it is set up. The Pi is now setup to connect to the VPN at boot, test by rebooting the Pi and monitoring the server to see if a connection is made.<\/p>\n<h2>Tweaking<\/h2>\n<p>During this setup an issue arose where a VPN was made, but upon any attempt to access files the connection would drop, and looking at <em>ifconfig<\/em> on the Pi showed unfeasibly large amounts of transmitted data on ppp0 adaptor.<\/p>\n<p>To rectify this, a manual IP route is required to show the Pi a useable path to the remote network, this may be needed also if the remote network is on a different subnet to the local.<\/p>\n<p>Do this by entering <em>route add -net 192.168.1.0 netmask 255.255.255.0 dev ppp0<\/em>\u00a0at the command line, replacing <em>192.168.1.0<\/em> with the subnet required and the final value 0. Test by pinging servers or machines on the remote network to see if they reply.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The arrival of the Raspberry Pi 2 meant the B+ previously used as a server was now ready for a new purpose. These little machines make great media players and is easy to setup so this would be its new role. However, this Pi would be in my parents\u2019 home, and miles away from where &hellip; <a href=\"https:\/\/james-batchelor.com\/index.php\/2016\/02\/04\/osmc-on-pi-with-pptp-vpn\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;OSMC on Pi with PPTP VPN&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,5],"tags":[118,117,116,115,63,114],"class_list":["post-357","post","type-post","status-publish","format-standard","hentry","category-raspberry-pi","category-servers","tag-b","tag-media-over-internet","tag-osmc","tag-pptp","tag-raspberry-pi","tag-vpn"],"_links":{"self":[{"href":"https:\/\/james-batchelor.com\/index.php\/wp-json\/wp\/v2\/posts\/357","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/james-batchelor.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/james-batchelor.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/james-batchelor.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/james-batchelor.com\/index.php\/wp-json\/wp\/v2\/comments?post=357"}],"version-history":[{"count":2,"href":"https:\/\/james-batchelor.com\/index.php\/wp-json\/wp\/v2\/posts\/357\/revisions"}],"predecessor-version":[{"id":361,"href":"https:\/\/james-batchelor.com\/index.php\/wp-json\/wp\/v2\/posts\/357\/revisions\/361"}],"wp:attachment":[{"href":"https:\/\/james-batchelor.com\/index.php\/wp-json\/wp\/v2\/media?parent=357"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/james-batchelor.com\/index.php\/wp-json\/wp\/v2\/categories?post=357"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/james-batchelor.com\/index.php\/wp-json\/wp\/v2\/tags?post=357"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}