1. 程式人生 > >centos7 安裝pptp vpn(使用iptbales防火墻)

centos7 安裝pptp vpn(使用iptbales防火墻)

centos7 pptpd iptables

一.系統設置

關閉selinux

[[email protected] system]# cat /etc/selinux/config
SELINUX=disabled

檢查是否支持

[[email protected] system]# modprobe ppp-compress-18 && echo yes
yes

二.安裝pptp

[[email protected] system]# yum -y update
[[email protected] system]#yum install pptpd pptp -y

設置:

[[email protected] system]# cat /etc/pptpd.conf|grep -v "#"|grep -v "^$"
option /etc/ppp/options.pptpd
logwtmp
localip 192.168.36.1
remoteip 192.168.36.100-238
[[email protected] system]# cat /etc/ppp/options.pptpd |grep -v "#"|grep -v "^$"
name pptpd
refuse-pap
refuse-chap
refuse-mschap
require-mschap-v2
require-mppe-128
ms-dns 8.8.8.8
ms-dns 8.8.4.4
proxyarp
lock
nobsdcomp 
novj
novjccomp
nologfd
[[email protected] system]# cat /etc/ppp/chap-secrets
# Secrets for authentication using CHAP
# client	server	secret			IP addresses
test pptpd test1 *

如果撥號成功,服務器本機地址為:192.168.36.1

客戶端分配IP為:192.168.36.100-238.DNS為:8.8.8.8

以上都很簡單,走彎路是下面安裝iptables

三.設置防火墻

關閉firewalld,因為iptables nat寫法比firewalld方便

[[email protected] ~]# systemctl stop firewalld
[[email protected] system]# systemctl disable firewalld

安裝iptables,需要註意的是,要安裝的是iptabels-services這個包,剛開始我是yum -y install iptables,死活找不到服務啟動.

[[email protected] system]# yum install iptables-services
[[email protected] system]# systemctl enable iptables
[[email protected] system]# systemctl start iptables

在其他規則的基礎上加上

[[email protected] system]# iptables -A INPUT -i eth0 -p tcp --dport 1723 -j ACCEPT
[[email protected] system]# iptables -A INPUT -i eth0 -p tcp --dport 47 -j ACCEPT
[[email protected] system]# iptables -I INPUT -p gre -j ACCEPT
[[email protected] system]#iptables -t nat -A POSTROUTING -s 192.168.36.0/255.255.255.0 -j SNAT --to-source 103.*.*.*

其中103.*.*.*是你的服務器ip,最後一條是轉發

cento7沒有/etc/init.d/iptables save來保存規則,使用以下命令保存規則,不然機器重啟後iptables規則沒有,將規則保存到文件.機器重啟或者systemctl restart iptables 也會從文件中讀取配置

[[email protected] system]# iptables-save /etc/sysconfig/iptables


本文出自 “海底兩萬裏” 博客,請務必保留此出處http://huwei555.blog.51cto.com/1347480/1971077

centos7 安裝pptp vpn(使用iptbales防火墻)