linux 服务器 创建vpn

来源:互联网 发布:手机噪音检测软件 编辑:程序博客网 时间:2024/06/05 21:57

需要安装软件 : ppp pptpd

安装ppp

yum install -y ppp

编辑ppp配置文件
vim /etc/ppp/options.pptpd

主要三个
name pptpd
ms-dns 8.8.8.8
ms-dns 8.8.4.4

添加用户
vi /etc/ppp/chap-secrets
username pptpd password *
安装pptpd

加入yum源
rpm -Uvh http://poptop.sourceforge.net/yum/stable/rhel6/pptp-release-current.noarch.rpm

安装pptpd
yum install -y pptpd

配置pptpd
vi /etc/pptpd.conf

localip 192.168.0.1
remoteip 192.168.0.10-20
localip 不需要更改,remoteip 为分配给连接到vpn的电脑ip地址

加入自启动
/etc/init.d/pptpd start chkconfig –level 35 pptpd on

打开内核转发功能
vi /etc/sysctl.conf

net.ipv4.ip_forward = 0
改为
net.ipv4.ip_forward = 1

生效
sysctl -p

编辑iptables

iptables -A INPUT -p gre -j ACCEPT
iptables -A INPUT -p tcp -m tcp –dport 1723 -j ACCEPT
iptables -A INPUT -m state –state RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -s 192.168.0.10/20 -o eth0 -j ACCEPT
iptables -A FORWARD -d 192.168.0.10/20 -i eth0 -j ACCEPT
iptables -t nat -A POSTROUTING -s 192.168.0.10/20 -o eth0 -j MASQUERADE

其中eth0是对应系统网卡
ip地址对应pptpd配置中的remoteip

保存
/etc/init.d/iptables save

重启
service iptables restart
service pptpd restart

0 0
原创粉丝点击