赞
踩
Centos下pptd ***搭建
*** 服务器ip: 172.16.113.40 *** :10.0.0.1
linux 客户端: 172.16.113.41
一 、***服务器配置
# yum install kernel-devel
# cat /dev/net/tun
cat: /dev/net/tun: File descriptor in bad state // 如果显示这条信息,则表明通过
# cat /dev/ppp
cat: /dev/ppp: No such deviceor address //如果显示这条信息,则表明通过
# yum install ppp // 安装pptp依赖包ppp
# yum install pptpd // 安装pptpd
# vim /etc/ppp/options.pptpd
ms-dns 192.168.21.2 //我这里内网因为有dns服务器,所以填写的是内网dns服务器地址,如果没有内网dns需要填写供应商提供的dns地址;
ms-dns 8.8.8.8 //备用dns
# vim /etc/pptpd.conf
localip 10.0.0.1 //***拨入用户服务器IP地址,(也可以写成10.0.0.1-100,这样每个客户端都会对应一个单独的服务器IP)
remoteip 10.0.0.101-200 // ***拨入用户客户端动态分配地址池
# vim /etc/ppp/chap-secrets //设置×××账号密码
#client server secret IPaddresses
loyu pptpd 123456 *
loyu1 pptpd 123456 *
//第1列是***客户端登录的用户名,第3列是***客户端登录的密码,第4列是登录的用户的主机的IP地址定义,"*"表示可以是任意的IP地址。
# vim /etc/sysctl.conf //修改内核设置,使其支持转发
net.ipv4.ip_forward = 1 //将“net.ipv4.ip_forward”的值改为1
# sysctl -p //重新加载
如果报错:
error:"net.bridge.bridge-nf-call-ip6tables" is an unknown key
error: "net.bridge.bridge-nf-call-iptables"is an unknown key
error:"net.bridge.bridge-nf-call-arptables" is an unknown key
解决方法
# modprobe bridge
# sysctl -p
# service pptpd start //启动服务
# chkconfig pptpd on //加入开机启动项
# chkconfig --list pptpd //查看开机启动
# ss -tnl //pptpd服务监听1723端口
# iptables -F //清楚现有的iptables策略
# iptables -t nat -A POSTROUTING -s 10.0.0.0/24 -j MASQUERADE //设置IPTABLES转发策略;
# serviceiptables save //保存iptables设置
二、linux客户端连接***
# yum install ppp pptp pptp-setup //安装ppp pptp pptp-setup
# pptpsetup --create loyu*** --server 172.16.113.40 --username loyu --password loyu --encrypt //创建×××连接
# modprobe ppp_mppe //加载模块
# pppd call loyu*** //连接×××连接,这里的loyu***是上面创建***连接
//如果报以下错误
Using interface ppp0
Connect: ppp0 /dev/pts/3
CHAP authentication succeeded
LCP terminated by peer (MPPE required but peer refused)
Modem hangup
//解决方法
# vim /etc/ppp/peers/loyu*** //loyu***是上面创建的连接
require-mppe-128 //文件尾部,加上以下内容
//如果报以下错误:
Refusing MPPE stateful mode offered by peer
MPPE required but peer negotiation failed
//解决方法:
说明服务端不支持MPPE加密,pptpsetup时不需要使用--encrypt选项。或者去掉上面的,require-mppe-128
# ifconfig |grep ppp //连接成功
ppp0 Link encap:Point-to-Point Protocol
# route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
10.0.0.1 * 255.255.255.255 UH 0 0 0 ppp0
172.16.113.40 * 255.255.255.255 UH 0 0 0 eth0
172.16.113.0 * 255.255.255.0 U 0 0 0 eth0
link-local * 255.255.0.0 U 1002 0 0 eth0
default 172.16.113.1 0.0.0.0 UG 0 0 0 eth0
# route add -net 10.0.0.0 netmask 255.255.255.0 dev ppp0 //在客户端添加路由,实现客户端,服务端能互相访问
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
10.0.0.1 * 255.255.255.255 UH 0 0 0 ppp0
172.16.113.40 * 255.255.255.255 UH 0 0 0 eth0
10.0.0.0 * 255.255.255.0 U 0 0 0 ppp0 //这就是刚添加的路由
172.16.113.0 * 255.255.255.0 U 0 0 0 eth0
link-local * 255.255.0.0 U 1002 0 0 eth0
default 172.16.113.1 0.0.0.0 UG 0 0 0 eth0
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。