1.安装ppp和pptpd
yum -y install ppp pptpd
2.编辑配置文件 /etc/pptpd.conf
#设置localip 和remoteip
#remoteip 用于分配给vpn客户端
localip 192.168.0.1
remoteip 192.168.1.0-255
3.编辑配置文件 /etc/ppp/options.pptpd
#如果没有就加上
nologfd
#日志文件
logfile /var/log/pptpd.log
4.编辑配置文件 /etc/ppp/chap-secrets
配置链接客户端
格式:
【账户】 【服务名称】 【密码】 【ip】
#示例
myvpn pptpd 123456 *
#表示 客户端账号myvpn 密码123456 允许所有ip(*表示所有)
5.设置转发
1.安装iptables-services
yum -y install iptables-services
2.开启iptables
service iptables start
3.设置转发规则
iptables -A POSTROUTING -s 192.168.1.0/24 -o eth0 -j MASQUERADE
4.将转发规则记录到 配置文件(以后就不用每次都设置了)
service iptables save
5.将iptables设置为开机启动
systemctl enable iptables
6.开启服务
启动pptpd
systemctl start pptpd
加入开机启动
systemctl enable pptpd
-----------------完成-------------------