Setting VPN with Port-Forwarding on VPS
Few months ago i had a huge problem with use of my internet connection because of blocked ports, so i decided to search for some alternatives to port forwarding, because i didn't have acces to my router(it was preconfigured by ISP). After few days i have also tried using 4G LTE modem which was useless as well. Finally i search the network, gained some info(BIG Thanks to the community of HackHound) and after those few month i finally did it.
But the point is, that there is no clear tutorial on the internet how to do all these things step-by-step easy enough that some1 without any wisdom (like me before) could do. So i decided to do a little tutorial for ppl who may have the same problem. Good luck.
Step 1. Buy VPS or do something to have one.
Description: In this tutorial I will make everything on Ubuntu 12.04.5 x64. Specs don't have to be high if you will use the connection only for yourself.
Step 2. Connect to it through SSH. (It is the easiest thing on the way.)
Description: Use PuTTY if you are using Windows.
Step 3. Download needed stuff.
Description: As you are connected to your private VPS with Ubuntu 12.04.5 installed write following commands.
- apt-get update
- apt-get upgrade
- wget http://swupdate.openvpn.org/as/openvpn-as-2.0.10-Ubuntu12.amd_64.deb
- dpkg -i openvpn-as-2.0.10-Ubuntu12.amd_64.deb
- passwd openvpn <-- Set password(REMEMBER IT!)
Click 'Go' and download your private APP to connect to your VPN.
Install downloaded software.
It should appear as a tray, click it and enter your credentials Login: openvpn Password: (as u set before). Click yes in the following messagebox.
If you see "Connected to xxx.xxx.xxx.xxx" then you are on the good way.
Step 4. Get info about yourself.
Decription: run command-line in your Windows
Search for IP beginning with 172.xxx.xxx.xxx
Remember it! It is your IP in NAT it will be now called as USER-IP.
IP of your VPS in NAT is all the same as USER-IP but ends with 1 (like: 172.xxx.xxx.1) Remember it! It will be now called VPS-NAT-IP.
Your public IP of your VPS(which you have used to connect to your server) will be now called VPS-PUBLIC-IP.
Step 5. Download and edit pre-made IPTABLES RULES.
Description: These rules allows incoming packets on certain port to your VPS be redirected to specified port to your PC inside VPN's NAT tables.
Download included in post iptables.txt, edit it and replace string "4789" with your PORT you want to unblock and USER-IP, VPS-NAT-IP, VPS-PUBLIC-IP, with your credentials.(use Notepad++ for example). Then upload it to your VPS.
After uploading type in putty:
Step 6. Test you connection.
Description: Use for it for example CanYouSeeMe.org. Remember that it will only recognize that port is unblocked if there is something that is listening on it. Else it will just refuse the connection. Good app to listen on windows is portlistener(Download link below).
Step 7. Do some feedback, I will try to help with any problem!