Connect with us

How To

Raspberry PI Router VPN | How to use your Raspberry Pi as a VPN router?



Raspberry PI Router

The router is the networking device which forwards the data packets between computer networks. The router has the specific processor, which handles the data packets and RF segment that handles wireless. The Raspberry Pi can be converted into a router. Running your own VPN server is the great way to increase your mobile security and get access to the LAN from the internet, but they are very hard to set up. But the Raspberry Pi makes this task much simple, cheap and effective. You can set the VPN router using the Raspberry Pi. the newest version of Raspberry is, even more, better with the built-in Wifi. It is highly useful for the networking projects. You can use you
Raspberry Pi as the VPN access point, which helps you to browse the web more privately.

Raspberry PI Router VPN
Raspberry PI Router VPN

Related: What is Raspberry Pi?

How to use your Raspberry Pi as a VPN router

The following steps describe how to set the Raspberry Pi as the VPN router.

Step 1: The first thing you have to do is just turn your Raspberry Pi into a wireless access point.

Step 2: Now Install the VPN, Here we are using the program called OpenVPN to set up the VPN. Just open the command line and type the below line to get it.

sudo apt-get install openvpn -y

Now reboot the Pi

sudo reboot

Step 3: We need one more program for this, Here we use VyprVPN. You can get it through the below-given command line.

cd /etc/openvpn

This puts us in the right directory.

sudo wget

This downloads the file.

sudo unzip

This unzips the file.

Raspberry PI Router VPN
Raspberry PI Router VPN

Step 4: Enter into the new directory here, then type Is to list files. They are using the 256-bit version So that you have that in the path.

cd GF_OpenVPN_10142016/OpenVPN256

Now you can see that the whole set of file that ends in .ovpn. These are the different VPNs you could use, listed by location. Just Remember these when you wish to connect to the specific VPNs.

Step 5: Now you should create the authorization file
You need to be authorized to use the VyprVPN. Let’s create the authorization file.

sudo nano /etc/openvpn/auth.txt

This creates a new file. Type two lines in the file. The first line will be your username, the second your password. You’re not just making these up – they have to be your VyprVPN login (if you don’t have the VyprVPN account, create one). Now get out of the file (Ctrl+X), save it (Y), and confirm (Enter).

Step 6: Run the test

sudo openvpn –config
“/etc/openvpn/GF_OpenVPN_10142016/OpenVPN256/FILENAME.ovpn” –auth-user-pass

Remember the VPN you wish to use. Plug that in where we have the FILENAME.ovpn. After completing this step correctly you can get the message ” Initialization Sequence Completed.”

Step 7: The whole process is not completed yet, here we have to change the bunch of iptables when we used our Pi as the wireless access point, but we have to change that now.

sudo iptables -F
sudo iptables -t nat -F
sudo iptables -X

This clears out the old stuff.

sudo iptables -t nat -A POSTROUTING -o tun0 -j MASQUERADE
sudo iptables -A FORWARD -i tun0 -o wlan0 -m state –state RELATED, ESTABLISHED -j ACCEPT
sudo iptables -A FORWARD i wlan0 -o tun0 -j ACCEPT

This will route wlan0 connection via our tunnel instead of over the Ethernet connection.

sudo sh -c “iptables-save > /etc/iptables.ipv4.nat”

This saves your work.

Raspberry PI Router VPN
Raspberry PI Router VPN

Step 8:  In this step, you can make things automatic. Set it up so that our VPN starts up when the Pi starts up. We’ll need to edit the rc.local file.

sudo nano /etc/rc.local

In the file, look for the line that says “exit 0” and add these lines just above it:

sleep 5
sudo openvpn –config
“/etc/openvpn/GF_OpenVPN_10142016/OpenVPN256/FILENAME.ovpn” –auth-user-pass

As with the last time, FILENAME.ovpn should be your choice from step 4. Head out of here with same keystrokes as your last file editing step: Ctrl+X, Y, Enter.

That’s it! Now everything should work properly. You can check to ensure that everything starts with each boot by rebooting the Pi with sudo reboot.

Thank you for reading this post.




Would you like to receive notifications on latest updates? No Yes