CentOS7 PPTP

实验环境

Windows 10, 64-bit
VMware® Workstation 15 Pro 15.1.0 build-13591040
CentOS-7-x86_64-DVD-1908.iso

1、CentOS7安装

此教程不讲解CentOS的安装,之讲解一些注意点:
1.此实验用的是字符界面
2.安装过程先使用 nat 模式(便于后面的软件安装)
3.dhcp自动获取ip地址保证能上外网

在这里插入图片描述

2、检验系统是否支持pptp

输入以下命令返回ok就说明系统支持pptp

modprobe ppp-compress-18 && echo ok

3、安装PPP,PPTP,net-tools,iptables-services

yum install -y ppp
yum install -y epel-release
yum install -y pptpd
yum install -y net-tools
yum install -y iptables-services
#关闭firewalld开启iptables
systemctl stop firewalld 
systemctl mask firewalld
systemctl start iptables 
systemctl enable iptables 

4、修改配置文件(重点)

1.编辑 /etc/pptpd.conf 在末尾添加(注意:10.3.77.221是服务器等会儿要设置的IP)
localip 10.3.77.221 
remoteip 192.168.0.100-192.168.0.150
2.编辑 /etc/ppp/chap-secrets 在末尾添加
user1   *   user1pass       *
3.编辑 /etc/ppp/options.pptpd

找到

#ms-dns 10.0.0.1
#ms-dns 10.0.0.2

在后面添加自己的dns

ms-dns 218.201.17.2
ms-dns 218.201.4.3
3.编辑 /etc/sysctl.conf
net.ipv4.ip_forward=1

允许系统路由转发,修文件后执行命令 sysctl -p 使立即生效

4.添加防火墙规则后面这点儿有点儿乱

注意:ens33为网卡名称 10.3.77.0/24为公网网段(等会儿要给网卡设置的网段)

错误的 不要执行
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 ens33 -j ACCEPT
firewall-cmd --permanent --direct --add-rule ipv4 filter FORWARD 0 -i ens33 -o ppp+ -j ACCEPT
firewall-cmd --permanent --direct --passthrough ipv4 -t nat -I POSTROUTING -o ens33 -j MASQUERADE -s 192.168.0.0/24
firewall-cmd --reload

错误的 不要执行
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 ens33 -j ACCEPT
firewall-cmd --permanent --direct --add-rule ipv4 filter FORWARD 0 -i ens33 -o ppp+ -j ACCEPT
firewall-cmd --permanent --direct --passthrough ipv4 -t nat -I POSTROUTING -o ens33 -j MASQUERADE -s 192.168.0.0/24

正确使用

删除所有iptables的规则 和nat规则
#iptables -I INPUT -p tcp --dport 1723 -j ACCEPT
#iptables -I INPUT -p tcp --dport 47 -j ACCEPT
#iptables -I INPUT -p gre -j ACCEPT
iptables -t nat -I POSTROUTING -s 192.168.0.0/24 -j SNAT --to-source 10.3.77.221
#iptables -t nat -I POSTROUTING -s 192.168.0.0/24 -o ens33 -j MASQUERADE
i#ptables -I FORWARD -p tcp --syn -i ppp+ -j TCPMSS --set-mss 1396
service iptables save

编辑/etc/ppp/ip-up 在exit 0上面添加
ifconfig $1 mtu 1472

学习到的一些命令
iptables -nvL --line-number 查看记录
iptables -D INPUT 10 删除第10条

Alt

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值