Ubuntu 16.04 builds PPTP VPN Server in three minutes

  1. Install PPTP VPN service
    sudo apt-get install pptpd

     

  2.  Add VPN account
    sudo vi /etc/ppp/chap-secrets
    
    #配置VPN客户端登录使用的用户名和密码如下图所示

  3. Configure pptpd.conf

    sudo vi /etc/pptpd.conf
    #找到并去掉以下代码的#号如下图所示
    #localip  192.168.0.1
    #remoteip 192.168.0.234-238,192.168.0.245

  4. Configure ms-dns for vpn

    sudo vi /etc/ppp/pptpd-options
    #找到ms-dns并去掉#号,修改为8.8.8.8和8.8.4.4如下图所示
    #ms-dns 8.8.8.8
    #ms-dns 8.8.4.4

  5. Enable kernel IP forwarding

    sudo vi /etc/sysctl.conf
    #找到以下代码,并去掉#号,如下图所示
    #net.ipv4.ip_forward=1

  6. Enter the command configuration to take effect

    sudo sysctl -p

     

  7. Clear old rules in iptables

    sudo iptables -F
    sudo iptables -X
    sudo iptables -t nat -F
    sudo iptables -t nat -X

     

  8. Allows the gre protocol and ports 1723 and 47

    sudo iptables -A INPUT -p gre -j ACCEPT 
    sudo iptables -A INPUT -p tcp --dport 1723 -j ACCEPT 
    sudo iptables -A INPUT -p tcp --dport 47 -j ACCEPT 

     

  9. Enable NAT forwarding

    sudo iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -o ens3 -j MASQUERADE
    #注意填写ens3,不同机器是不一样的,可以在终端输入ifconfig来查看网卡联网以及网卡的名称

  10. Restart the service and try connecting to the VPN

    sudo service pptpd restart
    #VPN代理上网慢请输入以下命令尝试解决
    sudo /sbin/iptables -I FORWARD -p tcp --syn -i ppp+ -j TCPMSS --set-mss 1356
    sudo service pptpd restart

     

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325340673&siteId=291194637