centos7 安装pptpd(使用iptbales防火墙)

本文详细介绍如何在CentOS 7上搭建PPTP VPN服务器,包括系统设置、安装及配置PPTP服务、设置防火墙规则等步骤,并提供具体的命令行操作示例。

一.系统设置

关闭selinux

1
2
[root@TW2 system]# cat /etc/selinux/config
SELINUX=disabled

检查是否支持

1
2
[root@TW2 system]# modprobe ppp-compress-18 && echo yes
yes

二.安装pptp

1
2
[root@TW2 system]# yum -y update
[root@TW2 system]#yum install pptpd pptp -y

设置:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
[root@TW2 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
[root@TW2 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
[root@TW2 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方便

1
2
[root@TW2 ~]# systemctl stop firewalld
[root@TW2 system]# systemctl disable firewalld

安装iptables,需要注意的是,要安装的是iptabels-services这个包,刚开始我是yum -y install iptables,死活找不到服务启动.

1
2
3
[root@TW2 system]# yum install iptables-services
[root@TW2 system]# systemctl enable iptables
[root@TW2 system]# systemctl start iptables

在其他规则的基础上加上

1
2
3
4
[root@TW2 system]# iptables -A INPUT -i eth0 -p tcp --dport 1723 -j ACCEPT
[root@TW2 system]# iptables -A INPUT -i eth0 -p tcp --dport 47 -j ACCEPT
[root@TW2 system]# iptables -I INPUT -p gre -j ACCEPT
[root@TW2 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 也会从文件中读取配置

1
[root@TW2 system]# iptables-save /etc/sysconfig/iptables


本文转自 yawei555 51CTO博客,原文链接:http://blog.51cto.com/huwei555/1971077,如需转载请自行联系原作者
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值