Zero's Blog

centos7安装pptpd vpn

系统环境

1
2
more /etc/redhat-release
CentOS Linux release 7.1.1503 (Core)

安装

1
yum install pptpd

配置

  • /etc/pptpd.conf

    1
    2
    3
    //增加下面内容
    localip 1.1.1.1
    remoteip 10.0.2.128-254
  • /etc/ppp/pptpd.options

    1
    2
    3
    //增加下面内容
    ms-dns 8.8.8.8
    ms-dns 8.8.4.4
  • /etc/ppp/chap-secrets

    1
    2
    3
    4
    // 用户密码文件
    # Secrets for authentication using CHAP
    # client server secret IP addresses
    test ptpd testpasswd 10.0.2.131
  • 防火墙

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    ::::::::::::::
    forward.sh
    ::::::::::::::
    #!/bin/bash
    /sbin/iptables -F FORWARD
    ##[test]
    /sbin/iptables -A FORWARD -s 10.0.2.131 -p tcp -d 172.16.3.131 -j ACCEPT
    ##[default]
    /sbin/iptables -A FORWARD -s 10.0.2.0/24 -d 172.16.6.88 -j ACCEPT
    /sbin/iptables -A FORWARD -s 10.0.2.0/24 -d 172.16.0.0/255.255.0.0 -j DROP
    ::::::::::::::
    gw.sh
    ::::::::::::::
    #!/bin/bash
    /sbin/iptables -t nat -F
    /sbin/iptables -t nat -A POSTROUTING -s 10.0.2.0/24 -d 172.16.0.0/16 -o eth1 -j SNAT --to-source 172.16.1.23
    /sbin/iptables -t nat -A POSTROUTING -s 10.0.2.0/24 ! -d 10.0.2.0/24 -o eth0 -j SNAT --to-source 59.51.149.23
    /sbin/iptables -t nat -A POSTROUTING -s 10.0.2.0/24 ! -d 172.16.0.0/16 -o eth0 -j SNAT --to-source 59.51.149.23
  • systecm 文件

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    more /usr/lib/systemd/system/pptpd.service
    [Unit]
    Description=PoPToP Point to Point Tunneling Server
    After=network.target
    [Service]
    EnvironmentFile=/etc/sysconfig/pptpd
    ExecStart=/usr/sbin/pptpd -f $OPTIONS
    [Install]
    WantedBy=multi-user.target