【中信Wind】VPN PPTP 文案

https://www.cccwind.com
https://blog.csdn.net/weixin_43934607/article/details/108671382?utm_medium=distribute.pc_relevant.none-task-blog-2~default~baidujs_utm_term~default-0-108671382-blog-120134829.235^v38^pc_relevant_anti_vip&spm=1001.2101.3001.4242.1&utm_relevant_index=3
版權聲明:本文為博主原創(chuàng)文章,遵循 CC 4.0 BY-SA 版權協(xié)議,轉載請附上原文出處鏈接和本聲明。
本文鏈接:https://blog.csdn.net/weixin_43934607/article/details/108671382
————————————————
版權聲明:本文為CSDN博主「槑!」的原創(chuàng)文章,遵循CC 4.0 BY-SA版權協(xié)議,轉載請附上原文出處鏈接及本聲明。
原文鏈接:https://blog.csdn.net/weixin_43934607/article/details/108671382
版本要求centos7.9
第一步先下載
yum install -y ppp
yum install -y pptpd
yum install -y iptables-services
第二步基礎配置
vi /etc/pptpd.conf
vi /etc/ppp/options.pptpd
vi /etc/ppp/chap-secrets
第三步重啟
service pptpd start
service pptpd stop
service pptpd restart
第四步配置外網(wǎng)鏈接
vi /etc/sysctl.conf
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1
vm.swappiness = 0
net.ipv4.neigh.default.gc_stale_time = 120
net.ipv4.conf.all.rp_filter = 0
net.ipv4.conf.default.rp_filter = 0
net.ipv4.conf.default.arp_announce = 2
net.ipv4.conf.lo.arp_announce = 2
net.ipv4.conf.all.arp_announce = 2
net.ipv4.tcp_max_tw_buckets = 5000
net.ipv4.tcp_max_syn_backlog = 1024
net.ipv4.tcp_synack_retries = 2
kernel.sysrq = 1
net.ipv4.ip_forward = 1
sysctl -p
第六步配置規(guī)則
vi /usr/lib/firewalld/services/pptpd.xml
<?xml version="1.0" encoding="utf-8"?>
<service>
? ? <short>pptpd</short>
? ? <description>PPTP</description>
? ? <port protocol="tcp" port="1723"/>
</service>
第七步配置協(xié)議
service firewalld start
firewall-cmd --permanent --zone=public --add-service=pptpd
firewall-cmd --add-masquerade
firewall-cmd --permanent --zone=public --add-port=47/tcp
firewall-cmd --permanent --zone=public --add-port=1723/tcp
firewall-cmd --permanent --direct --add-rule ipv4 filter INPUT 0 -p gre -j ACCEPT
firewall-cmd --permanent --direct --add-rule ipv4 filter OUTPUT 0 -p gre -j ACCEPT
firewall-cmd --permanent --direct --add-rule ipv4 filter FORWARD 0 -i ppp+ -o eth0 -j ACCEPT
firewall-cmd --permanent --direct --add-rule ipv4 filter FORWARD 0 -i eth0 -o ppp+ -j ACCEPT
firewall-cmd --permanent --direct --passthrough ipv4 -t nat -I POSTROUTING -o eth0 -j MASQUERADE -s 192.168.0.0/24
service firewalld restart
iptables -P FORWARD ACCEPT
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
iptables -I FORWARD -p tcp --syn -i ppp+ -j TCPMSS --set-mss 1356
service iptables save
service iptables restart
service firewalld restart
高級配置
賬戶登錄
vi /etc/ppp/auth-up
#!/bin/sh
# get the username/ppp line number from the parameters
REALDEVICE=$1
USER=$2
# create the directory to keep pid files per user
mkdir -p /var/run/pptpd-users
# if there is a session already for this user, terminate the old one
if [ -f /var/run/pptpd-users/$USER ]; then
kill -HUP `cat /var/run/pptpd-users/$USER`
rm /var/run/pptpd-users/$USER
fi
# copy the pid file of current user to /var/run/pptpd-users
cp "/var/run/$REALDEVICE.pid" /var/run/pptpd-users/$USER
chmod a+x /etc/ppp/auth-up
service pptpd restart
日志記錄
vi /etc/ppp/ip-up.local
echo "---------------Login---------------------------------------" >> /var/log/pptpd.log
echo "time: `date -d today +%F_%T`" >> /var/log/pptpd.log
echo "clientIP: $6" >> /var/log/pptpd.log
echo "username: $PEERNAME" >> /var/log/pptpd.log
echo "device: $1" >> /var/log/pptpd.log
echo "vpnIP: $4" >> /var/log/pptpd.log
echo "assignIP: $5" >> /var/log/pptpd.log
echo "-----------------------------------------------------------" >> /var/log/pptpd.log
chmod +x ip-up.local
vi /etc/ppp/ip-down.local
echo "---------------Logout--------------------------------------" >> /var/log/pptpd.log
echo "time: `date -d today +%F_%T`" >> /var/log/pptpd.log
echo "clientIP: $6" >> /var/log/pptpd.log
echo "username: $PEERNAME" >> /var/log/pptpd.log
echo "device: $1" >> /var/log/pptpd.log
echo "vpnIP: $4" >> /var/log/pptpd.log
echo "assignIP: $5" >> /var/log/pptpd.log
echo "-----------------------------------------------------------" >> /var/log/pptpd.log
chmod +x ip-down.local
如果出現(xiàn)無法連接或者是,之前成功后出現(xiàn)的癥狀請用管理員權限在重新輸入一遍
service firewalld start
firewall-cmd --permanent --zone=public --add-service=pptpd
firewall-cmd --add-masquerade
firewall-cmd --permanent --zone=public --add-port=47/tcp
firewall-cmd --permanent --zone=public --add-port=1723/tcp
firewall-cmd --permanent --direct --add-rule ipv4 filter INPUT 0 -p gre -j ACCEPT
firewall-cmd --permanent --direct --add-rule ipv4 filter OUTPUT 0 -p gre -j ACCEPT
firewall-cmd --permanent --direct --add-rule ipv4 filter FORWARD 0 -i ppp+ -o eth0 -j ACCEPT
firewall-cmd --permanent --direct --add-rule ipv4 filter FORWARD 0 -i eth0 -o ppp+ -j ACCEPT
firewall-cmd --permanent --direct --passthrough ipv4 -t nat -I POSTROUTING -o eth0 -j MASQUERADE -s 192.168.0.0/24
service firewalld restart
iptables -P FORWARD ACCEPT
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
iptables -I FORWARD -p tcp --syn -i ppp+ -j TCPMSS --set-mss 1356
service iptables save
service iptables restart
service firewalld restart
出現(xiàn)什么問題重啟可以解決部分的問題
service pptpd start
service pptpd stop
service pptpd restart