PPTP on CentOS, RedHat and Ubuntu
How to setup VPN server (PPTP on CentOS, RedHat and Ubuntu)?
There are mainly 3 types of VPN servers: Point-to-Point Tunneling Protocol (PPTP), Layer 2 Tunneling Protocol (L2TP) andOpenVPN. In this tutorial, we use PPTP because it is supported natively on almost all devices, Windows, Linux, Android, IOS and Mac OS.
Step 1. Install PPTPD
If your OS is CentOS/RedHat 5:
yum install pppcd /usr/local/srcwget http://poptop.sourceforge.net/yum/stable/packages/pptpd-1.3.4-2.rhel5.x86_64.rpmrpm -Uhv pptpd-1.3.4-2.rhel5.x86_64.rpmIf your OS is CentOS/RedHat 6:
yum install pppcd /usr/local/srcwget http://poptop.sourceforge.net/yum/stable/packages/pptpd-1.3.4-2.el6.x86_64.rpmrpm -Uhv pptpd-1.3.4-2.el6.x86_64.rpmIf you are using Ubuntu:
apt-get install pptpdStep 2. Edit IP setttings in /etc/pptpd.conf
vi /etc/pptpd.conflocalip 192.168.0.1
remoteip 192.168.0.101-200Step 3. Add user account in/etc/ppp/chap-secrets (assign username and password)
vi /etc/ppp/chap-secretsusernameForuser1 * setpassword1here *
usernameForuser2 * setpassword2here *
Step 4. Optional settings in /etc/ppp/options.pptpd
vi /etc/ppp/options.pptpdms-dns 8.8.8.8
ms-dns 4.4.4.4Step 5. Enable network forwarding in /etc/sysctl.conf
vi /etc/sysctl.confnet.ipv4.ip_forward = 1
use the following command to apply the change:
sysctl -pStep 6. Configure firewall
iptables -A INPUT -i eth0 -p tcp --dport 1723 -j ACCEPTiptables -A INPUT -i eth0 -p gre -j ACCEPTiptables -t nat -A POSTROUTING -o eth0 -j MASQUERADEiptables -A FORWARD -i ppp+ -o eth0 -j ACCEPTiptables -A FORWARD -i eth0 -o ppp+ -j ACCEPTservice iptables saveservice iptables restart
If you are using CSF firewall, you may refer to this post on firewall settings.Step 7. Start PPTP VPN server
If your OS is CentOS or Redhat, using the following command:
service pptpd restartTo start PPTP Daemon automatically when rebooting next time, use command:
chkconfig pptpd on
If your OS is Ubuntu, you just reboot your machine.Now you can test the VPN server from any client: Windows PCs, Linux PCs, Android phones/tablets, or iPhone and iPad.
The log of the VPN server, by default, is combined with system log located at /var/log/messages.
- ۹۲/۰۹/۱۹