Thursday, August 16, 2012

How to Install VPN Server in Ubuntu

I am going to install a VPN server on my own ubuntu server to be connected to it from anywhere of this world. I am going to use pptpd package.

First, I have installed the package using the following code
sudo apt-get install pptpd


Then, I have to configure this. I have to edit /etc/pptpd.conf file.

I have commanded in terminal as follow:

sudo vim /etc/pptpd.conf


Added following two lines:

localip 192.168.0.10
remoteip 192.168.0.230-239

Now I have to add user credentials to the file /etc/ppp/chap-secrets as follows:


# client    server  secret          IP Address
moin        pptpd   somepassword    "*" 


At last, I have to restart pptpd daemon using following command

sudo service pptpd restart 

 To allow access to the VPN server from Internet, I had to edit /etc/sysctl.conf using the following command

sudo vim /etc/sysctl.conf

I have uncommented the following line

net.ipv4.ip_forward=1
 
(to search the line press esc and write /net.ipv4.ip_forward=1 
and press enter. then delete "#")
 
Then use iptables to get the net forwarded:

/sbin/iptables -P FORWARD ACCEPT
/sbin/iptables --table nat -A POSTROUTING -o eth0 -j MASQUERADE
 
Optionally you can install bind9 and have a DNS resolver you can use for the vpn connection:

apt-get install bind9 -y
 
Then start it:

/etc/init.d/bind9 start
 
It's done. It worked for me, hope, also work for you. 

3 comments:

Nicole Thomas said...

Hello there, I discovered your blog by means of Google whilst looking for a similar matter, your web site came up, it
looks good. I've bookmarked it in my google bookmarks. Hello there, simply changed into aware of your blog via Google, and
found that it's truly informative. I'm gonna be careful for brussels. I will be grateful in the event you continue this in future. Lots of folks shall be benefited from your writing.
uk vpn

Nicole Thomas said...

I was recommended this blog by means of my cousin. I'm not positive whether this put up is written by means of him as no
one else know such unique about my difficulty. You're incredible! Thank you!
dedicated vpn

hmntl said...

I new in this area and have installed Elastix on Ubuntu on a mac VM...trying to install a2Billing for many days..could you please help, it would be a tremendous help...


Thanks in advance..