CentOS7-pptp-一件配置脚本

#!/bin/bash


yum -y update
yum -y install epel-release
yum -y install firewalld net-tools curl ppp pptpd


echo 'net.ipv4.ip_forward = 1' >> /etc/sysctl.conf
sysctl -p


echo 'admin * admin *' >> /etc/ppp/chap-secrets


cat >/etc/pptpd.conf < option /etc/ppp/options.pptpd
#logwtmp
localip 192.168.2.1
remoteip 192.168.2.10-100
END


cat >/etc/ppp/options.pptpd < name pptpd
refuse-pap
refuse-chap
refuse-mschap
require-mschap-v2
require-mppe-128
# ÈÕ±ŸDNS
ms-dns 202.12.27.33
ms-dns 8.8.8.8
# ms-dns 8.8.4.4
proxyarp
lock
nobsdcomp
novj
novjccomp
nologfd
END


add=$(ls /etc/sysconfig/network-scripts/ | grep 'ifcfg-e.*[0-9]' | cut -d- -f2)


# $add Íø¿šÃû×Ö±ØÐëÐÞžÄΪ»úÆ÷µÄÍø¿šÃû×Ö


systemctl restart firewalld.service
systemctl enable firewalld.service
firewall-cmd --set-default-zone=public
firewall-cmd --add-interface=m=$add
firewall-cmd --add-port=22/tcp --permanent
firewall-cmd --add-port=1723/tcp --permanent
firewall-cmd --add-masquerade --permanent
firewall-cmd --permanent --direct --add-rule ipv4 filter INPUT 0 -i $add -p gre -j ACCEPT
firewall-cmd --reload


cat > /etc/ppp/ip-up.local << END
/sbin/ifconfig $1 mtu 1400
END
chmod +x /etc/ppp/ip-up.local
systemctl restart pptpd.service
systemctl enable pptpd.service

你可能感兴趣的:(Linux)