How to Install PPTP VPN on CentOs 8

A VPN, or a Virtual Private Network, is a special connection kind. It is used to make connections to public and private networks safe. VPNs are also used by companies to send sensitive data. VPNs are also applied widely by individual users in the location where some internet content is restricted.

When you use a VPN, your IP address is hidden. Instead, on the web, the IP address that your VPN provider gives. Thus, it is impossible to identify from where you are connecting to the service.

PPTP (Point-to-Point Tunneling Protocol) is a special protocol used for VPN. It ensures communication between the VPN server and the VPN client.

You can use it for CentOS Linux, too. Thus, we will check how to install PPTP VPN on CentOS 8.

Step 1

It all starts with the PPTP installation. For that, execute the following command:

dnf install -y epel-release
dnf install -y ppp pptpd iptables nano

Step 2

Now, set it up:

Open /etc/pptpd.conf and set the local and remote IP addresses for VPN clients:

nano /etc/pptpd.conf

localip 192.168.0.1
remoteip 192.168.0.101-200

Now, move to /etc/ppp/options.pptpd and edit the settings:

nano /etc/ppp/options.pptpd

ms-dns 8.8.8.8
ms-dns 8.8.4.4

Step 3

Set up the user. With it, you will access your VPN.

For that, open /etc/ppp/chap-secrets, add your user and assign a password to it (format: user, server name, password, allowed IP):

nano /etc/ppp/chap-secrets

vpnuser pptpd vpnpassword *

Step 4

Move to /etc/sysctl.conf. Enable network forwarding.

nano /etc/sysctl.conf

net.ipv4.ip_forward = 1

# Apply the changes:
sysctl -p

Step 5

Now, it is time to move to the iptables installation.

Open the correct ports and forwarding of data packets by adding the following iptables rules:

iptables -A INPUT -i eth0 -p tcp --dport 1723 -j ACCEPT
iptables -A INPUT -i eth0 -p gre -j ACCEPT
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

Step 6

Start the VPN server.

systemctl restart pptpd
systemctl enable pptpd

Now, your VPN is installed on CentOS.

Blog