Previously, we mentioned how to configure a VPN server on CentOS. Today, let's briefly discuss how to configure a VPN proxy service on Ubuntu. The process of configuring VPN on Ubuntu is similar to CentOS. Here, I will use a DigitalOcean VPS as a test server. The reason for choosing it is simple - because VPS allows complete control over the PPP device and does not require submitting a ticket to customer service for activation. The operating system is Ubuntu Server 12.04.3. All operations are performed after executing "sudo su".
- Confirm whether the PPP device or TUN device is installed (skip this step for DigitalOcean VPS).
ls /dev/ppp
ls /dev/net/tun
or#
cat /dev/ppp
cat /dev/net/tun
If it prompts "No such file or directory" or "No such device or address", it means it is not installed. You can request activation by submitting a ticket.
- Install pptpd.
apt-get install pptpd
- After successful installation, modify the /etc/pptpd.conf file to configure the IP address of the VPN. Write:
localip XXX.XXX.XXX.XXX
remoteip XXX.XXX.XXX.XXX-XXX
Reference configuration#
localip 10.0.0.1#
remoteip 10.0.0.100-200#
localip is the local IP, which is the IP of the local machine. remoteip is the IP that will be assigned to the remote host. It is usually set as a continuous IP range.
- Modify the /etc/ppp/options.pptpd file to complete the DNS modification of the VPS server.
ms-dns 8.8.8.8
ms-dns 8.8.4.4
- Edit /etc/ppp/chap-secrets to configure the users for VPN connection. The format is:
username pptpd password *
username represents the username. pptpd represents the service name, usually the default. password represents the password. The asterisk (*) means that all IPs can connect.
- Enable IP forwarding by opening /etc/sysctl.conf. After opening the file, find the following content and modify it. If it doesn't exist, please add it.
Enable IP forwarding#
net.ipv4.ip_forward=1
Enable SYN cookies to avoid SYN flood attacks. It is recommended to enable this when multiple users are connected.#
net.ipv4.tcp_syncookies=0
Apply the changes to /etc/sysctl.conf (optional).
sysctl -p
- Open the firewall.
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE && iptables-save
- Start the pptp VPN service.
service pptpd start
Tutorial provided by DigitalOcean: https://www.digitalocean.com/community/articles/how-to-setup-your-own-vpn-with-pptp