install vpn server and setting up port forwarding on ubuntu

Hi, today in iThePro we will see how we can install vpn server and setting up port forwarding on ubuntu . so you can open port and forwarding them to any specific IP address.

Ok let's get started. First you need a full access to a linux server with root permission. In our example we will use Ubuntu 14.04 LTS x64 via ssh.

Installing PPTP Server

1) Connect to the server, and be ready for root commands.

2) install pptp server using apt-get command.

# sudo apt-get install pptpd

3) configure the pptp config file .

# sudo nano /etc/pptpd.conf

Uncomment and add the server IP and client IP in the end of the file, for example we use as pptp server ip address and we make a clients ip range from to

Save and Exit with Ctrl+X and Y for "yes save" .

4) Now setting up the Primary and secondary DNS Server .

# sudo nano /etc/ppp/pptpd-options
 Uncomment and give ms-dns two IP address of any trusted DNS Server .

 5) Time for setting pptp's users clients .

# sudo nano /etc/ppp/chap-secrets

Put the Username, Password and (Specific IP {if you want}).

Note : (we put * as IP addresses, so this will make the pptp server give access to the test user multiple devices, and the test user we will get every time a new IP address ).

6) Restart the pptpd server .

# /etc/init.d/pptpd restart

Setting up IP forwarding

7) Enable IP forward.

# sudo nano /etc/sysctl.conf

Uncomment the line :  "net.ipv4.ip_forward=1" .

 8) Reload the configuration .

sudo sysctl -p

9) run forward rule in iptables and add the to /etc/rc.local.

# sudo nano /etc/rc.local

Run all the forward rule with iptables command

# iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
# iptables --table nat --append POSTROUTING --out-interface ppp0 -j MASQUERADE
# iptables -I INPUT -s -i ppp0 -j ACCEPT
# iptables --append FORWARD --in-interface eth0 -j ACCEPT

Note : please make sure the default network interface . you can see it with "Route" Command . for example we use "eth0".

We are done Now, you can reboot the server . and you're vpn now should work

Open port and Forward to client

just type this command :

# iptables -t nat -A PREROUTING -p tcp --dport 4444 -j DNAT --to-destination

4444 : Tcp Port . : Client IP address .




Oussama Amri 21 years, security professional from Tunisia. Lover of computer science especially programming and secuirty. Follow me On :

Popular Posts Powered by Blogger.