{"id":356,"date":"2018-05-02T03:08:55","date_gmt":"2018-05-02T03:08:55","guid":{"rendered":"http:\/\/softinite.com\/?p=356"},"modified":"2018-05-02T03:08:55","modified_gmt":"2018-05-02T03:08:55","slug":"setting-up-raspberry-pi-as-openvpn-wireless-access-point","status":"publish","type":"post","link":"http:\/\/softinite.com\/?p=356","title":{"rendered":"Setting up Raspberry Pi as OpenVPN Wireless Access Point"},"content":{"rendered":"<h1 id=\"installing_wireless_access_point\" class=\"sectionedit1\">Installing Wireless Access Point<\/h1>\n<p>Step 1: install <a href=\"https:\/\/projects.raspberrypi.org\/en\/projects\/noobs-install\">Raspbian<\/a><\/p>\n<p>Step 2: install necessary software and edit dhcp configuration<\/p>\n<pre class=\"code\">sudo apt-get update\r\nsudo apt-get upgrade\r\nsudo apt-get install dnsmasq hostapd speedtest-cli\r\nsudo systemctl stop dnsmasq\r\nsudo systemctl stop hostapd\r\nsudo nano \/etc\/dhcpcd.conf\r\n\r\nStep 3: Insert the following lines and save\r\n\r\n<\/pre>\n<pre class=\"code\">interface wlan0\r\n    static ip_address=192.168.4.1\/24\r\n\r\nStep 4: Restart DHCP server and start editing dnsmasq\r\n\r\n<\/pre>\n<pre class=\"code\">sudo service dhcpcd restart\r\nsudo mv \/etc\/dnsmasq.conf \/etc\/dnsmasq.conf.orig\r\nsudo nano \/etc\/dnsmasq.conf\r\n\r\nStep 5: Write the following lines and save<\/pre>\n<pre class=\"code\">interface=wlan0      # Use the require wireless interface - usually wlan0\r\n  dhcp-range=192.168.4.2,192.168.4.20,255.255.255.0,24h\r\n\r\nStep 6: Edit hostapd configuration\r\n\r\n<\/pre>\n<pre class=\"code\">sudo nano \/etc\/hostapd\/hostapd.conf\r\n\r\nStep 7: Write the following configuration and adapt to your situation\r\n\r\n<\/pre>\n<pre class=\"code\">interface=wlan0\r\ndriver=nl80211\r\nssid=NameOfNetwork\r\nhw_mode=g\r\nchannel=7\r\nwmm_enabled=0\r\nmacaddr_acl=0\r\nauth_algs=1\r\nignore_broadcast_ssid=0\r\nwpa=2\r\nwpa_passphrase=AardvarkBadgerHedgehog\r\nwpa_key_mgmt=WPA-PSK\r\nwpa_pairwise=TKIP\r\nrsn_pairwise=CCMP\r\n\r\nStep 8: Point to the above configuration\r\n\r\n<\/pre>\n<pre class=\"code\">sudo nano \/etc\/default\/hostapd\r\n\r\nMake sure the following line exists and save\r\n\r\n<\/pre>\n<pre class=\"code\">DAEMON_CONF=\"\/etc\/hostapd\/hostapd.conf\"\r\n\r\nStep 9: Edit sysctl\r\n\r\n<\/pre>\n<pre class=\"code\">sudo nano \/etc\/sysctl.conf\r\n\r\nStep 10: Uncomment and save\r\n\r\n<\/pre>\n<pre class=\"code\">net.ipv4.ip_forward=1\r\n\r\nStep 11: Setup IP tables\r\n\r\n<\/pre>\n<pre class=\"code\">sudo iptables -t nat -A  POSTROUTING -o eth0 -j MASQUERADE\r\nsudo sh -c \"iptables-save &gt; \/etc\/iptables.ipv4.nat\"\r\n\r\nStep 12: Make sure configuration persists on restart by editing\r\n\r\n<\/pre>\n<pre class=\"code\">sudo nano \/etc\/rc.local\r\n\r\nand injecting the following line right before 'exit 0'<\/pre>\n<pre class=\"code\">iptables-restore &lt; \/etc\/iptables.ipv4.nat\r\n\r\n\r\n<\/pre>\n<h1 id=\"at_this_point_wap_should_be_up_and_running_now_let_s_setup_pia_openvpn_client\" class=\"sectionedit2\">At this point WAP should be up and running. Now, let&#8217;s setup PIA OpenVPN client:<\/h1>\n<pre class=\"code\">Step 13: Adapt the following to your situation and run\r\n\r\n<\/pre>\n<pre class=\"code\">sudo apt-get install openvpn\r\ncd \/etc\/openvpn\r\nsudo wget http:\/\/www.privateinternetaccess.com\/openvpn\/openvpn.zip\r\nsudo unzip openvpn.zip\r\nsudo mv -fv US\\ New\\ York\\ City.ovpn us_new_york.ovpn\r\nsudo nano us_new_york.ovpn\r\n\r\nStep 14: Make sure the following line is present\r\n\r\n<\/pre>\n<pre class=\"code\">auth-user-pass creds.pwd\r\n\r\nStep 15: Create creds.pwd and add your VPN username\/password in the first two lines\r\n\r\n<\/pre>\n<pre class=\"code\">sudo nano creds.pwd\r\n\r\nStep 16: Test the configuration by running (press Enter twice after the first command)\r\n\r\n<\/pre>\n<pre class=\"code\">sudo openvpn --config us_new_york.ovpn &amp; disown\r\nspeedtest-cli\r\n\r\nStep 17: Redirect WiFi traffic to the openvpn interface\r\n\r\n<\/pre>\n<pre class=\"code\">sudo iptables -F\r\nsudo iptables -t nat -F\r\nsudo iptables -X\r\nsudo iptables -t nat -A POSTROUTING -o tun0 -j MASQUERADE\r\nsudo iptables -A FORWARD -i tun0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT\r\nsudo iptables -A FORWARD -i wlan0 -o tun0 -j ACCEPT\r\nsudo sh -c \"iptables-save &gt; \/etc\/iptables.ipv4.nat\"\r\nsudo nano \/etc\/rc.local\r\n\r\nStep 18: Enter the following lines right before 'exit 0'\r\n\r\n<\/pre>\n<pre class=\"code\">sleep 5\r\ncd \/etc\/openvpn\r\nsudo openvpn --config us_new_york.ovpn\r\n\r\nStep 19: Reboot\r\n\r\n<\/pre>\n<pre class=\"code\">sudo reboot\r\n\r\n\r\n\r\n<\/pre>\n<p>References:<\/p>\n<ul>\n<li class=\"level1\">\n<div class=\"li\"><a class=\"urlextern\" title=\"https:\/\/pimylifeup.com\/raspberry-pi-wireless-access-point\/\" href=\"https:\/\/pimylifeup.com\/raspberry-pi-wireless-access-point\/\" rel=\"nofollow\">https:\/\/pimylifeup.com\/raspberry-pi-wireless-access-point\/<\/a><\/div>\n<\/li>\n<li class=\"level1\">\n<div class=\"li\"><a class=\"urlextern\" title=\"https:\/\/pimylifeup.com\/raspberry-pi-vpn-access-point\/\" href=\"https:\/\/pimylifeup.com\/raspberry-pi-vpn-access-point\/\" rel=\"nofollow\">https:\/\/pimylifeup.com\/raspberry-pi-vpn-access-point\/<\/a><\/div>\n<\/li>\n<li class=\"level1\">\n<div class=\"li\"><a class=\"urlextern\" title=\"https:\/\/www.raspberrypi.org\/documentation\/configuration\/wireless\/access-point.md#internet-sharing\" href=\"https:\/\/www.raspberrypi.org\/documentation\/configuration\/wireless\/access-point.md#internet-sharing\" rel=\"nofollow\">https:\/\/www.raspberrypi.org\/documentation\/configuration\/wireless\/access-point.md#internet-sharing<\/a><\/div>\n<\/li>\n<li class=\"level1\">\n<div class=\"li\"><a class=\"urlextern\" title=\"https:\/\/askubuntu.com\/questions\/104755\/how-to-check-internet-speed-via-terminal?utm_medium=organic&amp;utm_source=google_rich_qa&amp;utm_campaign=google_rich_qa\" href=\"https:\/\/askubuntu.com\/questions\/104755\/how-to-check-internet-speed-via-terminal?utm_medium=organic&amp;utm_source=google_rich_qa&amp;utm_campaign=google_rich_qa\" rel=\"nofollow\">https:\/\/askubuntu.com\/questions\/104755\/how-to-check-internet-speed-via-terminal?utm_medium=organic&amp;utm_source=google_rich_qa&amp;utm_campaign=google_rich_qa<\/a><\/div>\n<\/li>\n<li class=\"level1\">\n<div class=\"li\"><a class=\"urlextern\" title=\"https:\/\/nordvpn.com\/tutorials\/raspberry-pi\/openvpn\/\" href=\"https:\/\/nordvpn.com\/tutorials\/raspberry-pi\/openvpn\/\" rel=\"nofollow\">https:\/\/nordvpn.com\/tutorials\/raspberry-pi\/openvpn\/<\/a><\/div>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p>Troubleshooting:<\/p>\n<ul>\n<li class=\"level1\">\n<div class=\"li\">If Raspberry does not start and green light did not flash, it means it could not read the SD card<\/div>\n<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Installing Wireless Access Point<\/p>\n<p>Step 1: install <a href=\"https:\/\/projects.raspberrypi.org\/en\/projects\/noobs-install\">Raspbian<\/a><\/p>\n<p>Step 2: install necessary software and edit dhcp configuration<\/p>\n<p>sudo apt-get update<br \/>\nsudo apt-get upgrade<br \/>\nsudo apt-get install dnsmasq hostapd speedtest-cli<br \/>\nsudo systemctl stop dnsmasq<br \/>\nsudo systemctl stop hostapd<br \/>\nsudo nano \/etc\/dhcpcd.conf<\/p>\n<p>Step 3: Insert &#8230;<\/p>\n","protected":false},"author":2,"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_newsletter_tier_id":0,"footnotes":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[13],"tags":[15,14,16,17],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p7uKYI-5K","_links":{"self":[{"href":"http:\/\/softinite.com\/index.php?rest_route=\/wp\/v2\/posts\/356"}],"collection":[{"href":"http:\/\/softinite.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/softinite.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/softinite.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/softinite.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=356"}],"version-history":[{"count":3,"href":"http:\/\/softinite.com\/index.php?rest_route=\/wp\/v2\/posts\/356\/revisions"}],"predecessor-version":[{"id":359,"href":"http:\/\/softinite.com\/index.php?rest_route=\/wp\/v2\/posts\/356\/revisions\/359"}],"wp:attachment":[{"href":"http:\/\/softinite.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=356"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/softinite.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=356"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/softinite.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=356"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}