Loan

Aug 31 2017

Easiest way to setup Ubuntu as a VPN server – Ask Ubuntu #dedicated #vpn #server

#

I know there are many tutorials on the net for setting up VPN client and server.

I you find one that is simple/short. I am interested only in the server part.

For client, I will use OS X so I prefer a solution that uses L2TP over IPsec or PPTP because I suppose Cisco IPsec would cost something.

I don’t want to spent too many hours setting it up. You know, maybe someone already made a setup script 🙂

Note: I am using an EC2 micro instance running Ubuntu 12.04 on it.

May 12 13:28:06 zork pppd[9447]: Plugin /usr/lib/pptpd/pptpd-logwtmp.so loaded. May 12 13:28:06 zork pppd[9447]: pppd 2.4.5 started by root, uid 0 May 12 13:28:06 zork pppd[9447]: Using interface ppp0 May 12 13:28:06 zork pppd[9447]: Connect: ppp0 — /dev/pts/3 May 12 13:28:36 zork pppd[9447]: Hangup (SIGHUP) May 12 13:28:36 zork pppd[9447]: Modem hangup May 12 13:28:36 zork pppd[9447]: Connection terminated. May 12 13:28:36 zork pppd[9447]: Exit.It doesn t work yet! Your guide is incomplete (yet) 😉 sorin May 12 ’12 at 13:30

WARNING: PPTP IS AN INSECURE PROTOCOL! Not only has the encryption been breached, but it sends your authentication in clear text and is easily intercepted. It has been estimated that the amount of time required to brute-force the password is roughly equivalent to the time required to brute-force a single DES key. Consider using OpenVPN or another VPN architecture instead of PPTP!

I used this guide to set up a PPTP VPN server on my Ubuntu 12.04 server.

To summarize the main points in the link, though:

1: Install pptpd and ufw. iptables can be used in place of ufw, but for the sake of easiness, ufw is better if you don’t know iptables .

sudo apt-get install pptpd ufw

2: Open the ports needed. The guide suggests 22 (SSH) and 1723 for the pptp vpn.

3: Edit /etc/ppp/pptpd-options. Open the file with your favorite editor (mine’s nano, so the command for me is sudo nano /etc/ppp/pptpd-options ), and comment out these lines by putting a # before them, if you want this to work universally on all OSes:

You can comment this line if you want to disable encryption: require-mppe-128

4: While editing /etc/ppp/pptpd-options. add DNS servers for the VPN. This example uses OpenDNS servers:

5: Edit /etc/pptpd.conf. Open the file with your favorite editor (mine’s nano, so the command for me is sudo nano /etc/pptpd.conf ). You need to add the local VPN IPs for the system, so add:

6: Edit /etc/ppp/chap-secrets. Open the file with your favorite editor (mine’s nano, so the command for me is sudo nano /etc/ppp/chap-secrets ), and add the auth data.
The format for /etc/ppp/chap-secrets is:

An example would be: sampleuser pptpd samplepassword *

7: Restart pptpd. Run this command in terminal: sudo /etc/init.d/pptpd restart

8: Edit /etc/sysctl.conf. Open the file with your favorite editor (mine’s nano, so the command for me is sudo nano /etc/sysctl.conf ). Un-comment the following line (by removing the # at the beginning of it) in /etc/sysctl.conf. net.ipv4.ip_forward=1
Reload the configuration: sudo sysctl -p

9: This step assumes you have ufw.
Edit /etc/default/ufw and change the option DEFAULT_FORWARD_POLICY from DROP to ACCEPT

10: This step assumes you have ufw.
Edit /etc/ufw/before.rules. and add the following either at the beginning of /etc/ufw/before.rules or just before the *filter rules (recommended):

If you have kernel version 3.18 and newer (you can check this by running uname -r ), also add the following lines before the # drop INVALID packets. line:

11: Restart the firewall, to refresh the rule sets and to apply the rules we added to the /etc/ufw/*.rules files: sudo ufw disable sudo ufw enable

Warning: If you have other ports you need open, such as for HTTPS if your server hosts a website, you need to individually add those ports to the allowed list with sudo ufw allow PORT

Here is a quick tutorial to set up a basic PPTP VPN server on Ubuntu 12.04.

Install Necessary Packages

Configure PPTP IP Ranges on the Server

Add the following lines in end

This sets up the PPTP server to use IP 10.89.64.1 while distributing the IP range 10.89.64.100 to 10.89.64.150 to PPTP clients. Change these as you wish as long as they are private IP addresses and do not conflict with IP addresses already used by your server.

Configure DNS Servers to Use When Clients Connect to this PPTP Server

Modify OR Add the following lines in end

Create a PPTP User

Append a line at the bottom so your file looks something like:

Configure NAT for PPTP Connections

Without this step you will be able to connect but your connection will not be able to load any web connection from this server.

Add the following to the bottom right before “exit 0” line:

Assuming eth0, you can use ifconfig to check network name.

Enable IPv4 forwading:

Uncomment the following line:

Then reload the configuration:

Reboot your VPS and everything should work swimmingly from any PPTP client.

Client side configuration

For Mac, make sure you added PPTP VPN connection. Besides that you only need to setup server address, account name, and password in authentication settings. No pain here.

For Linux, NetworkManager to add VPN connections. Make sure you added PPTP VPN connection. And the configuration I use is here:

And for Windows

The other answers on this thread were only partial answers in my case. Here’s what worked for me on Ubuntu 12.04.3

Append the following to /etc/pptpd.conf (IP Address does not matter, this is only IP Addresses for your ppp0 interface.)

Add DNS Servers to /etc/ppp/pptpd-options

Enable IP Forwarding

Uncomment this line

Edit /etc/ppp/chap-secrets, add a VPN user in this format:

Run ifconfig and find your default interface, in my case it was br0 (I changed it to allow virtual machines on my physical machine to share the interface. Yours will probably be en0 )

Back up iptables

Now make your iptables changes use your default interface as revealed by ifconfig.

To keep it persistent when your system reboots;

Add VPN on client computer (Mac)

System Preferences > Network > [+] > VPN

Then choose Authentication settings > Password, then fill in your password here





Written by admin


Leave a Reply

Your email address will not be published. Required fields are marked *