linux pptpd,linux平板
各位老铁们,大家好,今天由我来为大家分享linux pptpd,以及linux平板的相关问题知识,希望对大家有所帮助。如果可以帮助到大家,还望关注收藏下本站,您的支持是我们最大的动力,谢谢大家了哈,下面我们开始吧!
Linux下pppd出现问题,我无法上网,怎么办
这个问题也困扰了我好久。首先解决这个问题要检查:
1.pptpd服务器安装配置正确,
2. iptables input表添加tcp 1723 47和gre协议
3.nat表的postrouting添加-o eth0-j MASQUERAID和-j SNAT--to
但是可以连接就是没有网:
4.检查ip_forword=1开启地址转发。还是不行
5.看forward链清除默认项,--ok了,我现在设置防火墙都是先iptables-F然后在添加就没有问题了
第5部最重要,因为默认系统会有一个其他的。linux的学习建议参考《linux就该这样学》
加油吧,企鹅人们!!!
Linux上PPTPVPN的一键安装以及设置开机启动的方法
设置pptp vpn开机启动
有的人懒的重启后手动开启服务,所以下面我再补上开机自动启动pptp vpn和 iptables的命令
复制代码代码如下:#chkconfig pptpd on//开机启动pptp vpn服务
#chkconfig iptables on//开机启动iptables
贴个openvz的pptp vpn一件安装包吧:centos,fedora,redhat 6.x使用的脚本(vps上从没安装过的可以试试这个脚本):点击下载
复制代码代码如下:#!/bin/bash
# Interactive pptp vpn install script for an OpenVZ VPS
# surport: Cenost,Fedora 6.x
# Augest 24, 2014 v1.00
#url:
echo"######################################################"
echo"Interactive PoPToP Install Script for an OpenVZ VPS"
echo
echo"Make sure to contact your provider and have them enable"
echo"IPtables and ppp modules prior to setting up PoPToP."
echo"PPP can also be enabled from SolusVM."
echo
echo"You need to set up the server before creating more users."
echo"A separate user is required per connection or machine."
echo"######################################################"
echo
echo
echo"######################################################"
echo"Select on option:"
echo"1) Set up new PoPToP server AND create one user"
echo"2) Create additional users"
echo"######################################################"
read x
if test$x-eq 1; then
echo"Enter username that you want to create(eg. client1 or john):"
read u
echo"Specify password that you want the server to use:"
read p
## get the VPS IP
#ip=`ifconfig venet0:0| grep'inet addr'| awk{'print$2'}| sed s/.*://`
echo
echo"######################################################"
echo"Downloading and Installing ppp and pptpd"
echo"######################################################"
yum install ppp-y
rpm-Uvh
yum install pptpd-y
echo
echo"######################################################"
echo"Creating Server Config"
echo"######################################################"
cp/etc/ppp/options.pptpd/etc/ppp/options.pptpd.bak
sed-i'70a ms-dns 8.8.8.8'/etc/ppp/options.pptpd
# setting up pptpd.conf
sed-i'101a localip 192.168.9.1'/etc/pptpd.conf
sed-i'102a remoteip 192.168.9.11-30'/etc/pptpd.conf
# adding new user
echo"$u*$p*">>/etc/ppp/chap-secrets
echo
echo"######################################################"
echo"Forwarding IPv4 and Enabling it on boot"
echo"######################################################"
cat>>/etc/sysctl.conf<<END
net.ipv4.ip_forward=1
END
sysctl-p
echo
echo"######################################################"
echo"Updating IPtables Routing and Enabling it on boot"
echo"######################################################"
iptables-t nat-A POSTROUTING-o eth0-j MASQUERADE
# saves iptables routing rules and enables them on-boot
iptables-save>/etc/iptables.conf
cat>/etc/network/if-pre-up.d/iptables<<END
#!/bin/sh
iptables-restore</etc/iptables.conf
END
chmod+x/etc/network/if-pre-up.d/iptables
cat>>/etc/ppp/ip-up<<END
ifconfig ppp0 mtu 1400
END
echo
echo"######################################################"
echo"Restarting PoPToP"
echo"######################################################"
sleep 5
/etc/init.d/pptpd restart
echo
echo"######################################################"
echo"Server setup complete!"
echo"Connect to your VPS at$ip with these credentials:"
echo"Username:$u##### Password:$p"
echo"######################################################"
# runs this if option 2 is selected
elif test$x-eq 2; then
echo"Enter username that you want to create(eg. client1 or john):"
read u
echo"Specify password that you want the server to use:"
read p
# adding new user
echo"$u*$p*">>/etc/ppp/chap-secrets
echo
echo"######################################################"
echo"Addtional user added!"
echo"Connect to your VPS at$ip with these credentials:"
echo"Username:$u##### Password:$p"
echo"######################################################"
else
echo"Invalid selection, quitting."
exit
fi
#!/bin/bash
# Interactive pptp vpn install script for an OpenVZ VPS
# surport: Cenost,Fedora 6.x
# Augest 24, 2014 v1.00
#url:
echo"######################################################"
echo"Interactive PoPToP Install Script for an OpenVZ VPS"
echo
echo"Make sure to contact your provider and have them enable"
echo"IPtables and ppp modules prior to setting up PoPToP."
echo"PPP can also be enabled from SolusVM."
echo
echo"You need to set up the server before creating more users."
echo"A separate user is required per connection or machine."
echo"######################################################"
echo
echo
echo"######################################################"
echo"Select on option:"
echo"1) Set up new PoPToP server AND create one user"
echo"2) Create additional users"
echo"######################################################"
read x
if test$x-eq 1; then
echo"Enter username that you want to create(eg. client1 or john):"
read u
echo"Specify password that you want the server to use:"
read p
## get the VPS IP
#ip=`ifconfig venet0:0| grep'inet addr'| awk{'print$2'}| sed s/.*://`
echo
echo"######################################################"
echo"Downloading and Installing ppp and pptpd"
echo"######################################################"
yum install ppp-y
rpm-Uvh
yum install pptpd-y
echo
echo"######################################################"
echo"Creating Server Config"
echo"######################################################"
cp/etc/ppp/options.pptpd/etc/ppp/options.pptpd.bak
sed-i'70a ms-dns 8.8.8.8'/etc/ppp/options.pptpd
# setting up pptpd.conf
sed-i'101a localip 192.168.9.1'/etc/pptpd.conf
sed-i'102a remoteip 192.168.9.11-30'/etc/pptpd.conf
# adding new user
echo"$u*$p*">>/etc/ppp/chap-secrets
echo
echo"######################################################"
echo"Forwarding IPv4 and Enabling it on boot"
echo"######################################################"
cat>>/etc/sysctl.conf<<END
net.ipv4.ip_forward=1
END
sysctl-p
echo
echo"######################################################"
echo"Updating IPtables Routing and Enabling it on boot"
echo"######################################################"
iptables-t nat-A POSTROUTING-o eth0-j MASQUERADE
# saves iptables routing rules and enables them on-boot
iptables-save>/etc/iptables.conf
cat>/etc/network/if-pre-up.d/iptables<<END
#!/bin/sh
iptables-restore</etc/iptables.conf
END
chmod+x/etc/network/if-pre-up.d/iptables
cat>>/etc/ppp/ip-up<<END
ifconfig ppp0 mtu 1400
END
echo
echo"######################################################"
echo"Restarting PoPToP"
echo"######################################################"
sleep 5
/etc/init.d/pptpd restart
echo
echo"######################################################"
echo"Server setup complete!"
echo"Connect to your VPS at$ip with these credentials:"
echo"Username:$u##### Password:$p"
echo"######################################################"
# runs this if option 2 is selected
elif test$x-eq 2; then
echo"Enter username that you want to create(eg. client1 or john):"
read u
echo"Specify password that you want the server to use:"
read p
# adding new user
echo"$u*$p*">>/etc/ppp/chap-secrets
echo
echo"######################################################"
echo"Addtional user added!"
echo"Connect to your VPS at$ip with these credentials:"
echo"Username:$u##### Password:$p"
echo"######################################################"
else
echo"Invalid selection, quitting."
exit
fi
复制下面代码到install.sh中,然后 sh isntall.sh。这个是只支持debian和ubuntu系列,centos不支持。
复制代码代码如下:
#!/bin/bash
# Interactive PoPToP install script for an OpenVZ VPS
# Tested on Debian 5, 6, and Ubuntu 11.04
# April 2, 2013 v1.11
#
echo"######################################################"
echo"Interactive PoPToP Install Script for an OpenVZ VPS"
echo
echo"Make sure to contact your provider and have them enable"
echo"IPtables and ppp modules prior to setting up PoPToP."
echo"PPP can also be enabled from SolusVM."
echo
echo"You need to set up the server before creating more users."
echo"A separate user is required per connection or machine."
echo"######################################################"
echo
echo
echo"######################################################"
echo"Select on option:"
echo"1) Set up new PoPToP server AND create one user"
echo"2) Create additional users"
echo"######################################################"
read x
if test$x-eq 1; then
echo"Enter username that you want to create(eg. client1 or john):"
read u
echo"Specify password that you want the server to use:"
read p
# get the VPS IP
ip=`ifconfig venet0:0| grep'inet addr'| awk{'print$2'}| sed s/.*://`
echo
echo"######################################################"
echo"Downloading and Installing PoPToP"
echo"######################################################"
apt-get update
apt-get-y install pptpd
echo
echo"######################################################"
echo"Creating Server Config"
echo"######################################################"
cat>/etc/ppp/pptpd-options<<END
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
nodefaultroute
lock
nobsdcomp
END
# setting up pptpd.conf
echo"option/etc/ppp/pptpd-options">/etc/pptpd.conf
echo"logwtmp">>/etc/pptpd.conf
echo"localip$ip">>/etc/pptpd.conf
echo"remoteip 10.1.0.1-100">>/etc/pptpd.conf
# adding new user
echo"$u*$p*">>/etc/ppp/chap-secrets
echo
echo"######################################################"
echo"Forwarding IPv4 and Enabling it on boot"
echo"######################################################"
cat>>/etc/sysctl.conf<<END
net.ipv4.ip_forward=1
END
sysctl-p
echo
echo"######################################################"
echo"Updating IPtables Routing and Enabling it on boot"
echo"######################################################"
iptables-t nat-A POSTROUTING-j SNAT--to$ip
# saves iptables routing rules and enables them on-boot
iptables-save>/etc/iptables.conf
cat>/etc/network/if-pre-up.d/iptables<<END
#!/bin/sh
iptables-restore</etc/iptables.conf
END
chmod+x/etc/network/if-pre-up.d/iptables
cat>>/etc/ppp/ip-up<<END
ifconfig ppp0 mtu 1400
END
echo
echo"######################################################"
echo"Restarting PoPToP"
echo"######################################################"
sleep 5
/etc/init.d/pptpd restart
echo
echo"######################################################"
echo"Server setup complete!"
echo"Connect to your VPS at$ip with these credentials:"
echo"Username:$u##### Password:$p"
echo"######################################################"
# runs this if option 2 is selected
elif test$x-eq 2; then
echo"Enter username that you want to create(eg. client1 or john):"
read u
echo"Specify password that you want the server to use:"
read p
# get the VPS IP
ip=`ifconfig venet0:0| grep'inet addr'| awk{'print$2'}| sed s/.*://`
# adding new user
echo"$u*$p*">>/etc/ppp/chap-secrets
echo
echo"######################################################"
echo"Addtional user added!"
echo"Connect to your VPS at$ip with these credentials:"
echo"Username:$u##### Password:$p"
echo"######################################################"
else
echo"Invalid selection, quitting."
exit
fi
#!/bin/bash
# Interactive PoPToP install script for an OpenVZ VPS
# Tested on Debian 5, 6, and Ubuntu 11.04
# April 2, 2013 v1.11
#
echo"######################################################"
echo"Interactive PoPToP Install Script for an OpenVZ VPS"
echo
echo"Make sure to contact your provider and have them enable"
echo"IPtables and ppp modules prior to setting up PoPToP."
echo"PPP can also be enabled from SolusVM."
echo
echo"You need to set up the server before creating more users."
echo"A separate user is required per connection or machine."
echo"######################################################"
echo
echo
echo"######################################################"
echo"Select on option:"
echo"1) Set up new PoPToP server AND create one user"
echo"2) Create additional users"
echo"######################################################"
read x
if test$x-eq 1; then
echo"Enter username that you want to create(eg. client1 or john):"
read u
echo"Specify password that you want the server to use:"
read p
# get the VPS IP
ip=`ifconfig venet0:0| grep'inet addr'| awk{'print$2'}| sed s/.*://`
echo
echo"######################################################"
echo"Downloading and Installing PoPToP"
echo"######################################################"
apt-get update
apt-get-y install pptpd
echo
echo"######################################################"
echo"Creating Server Config"
echo"######################################################"
cat>/etc/ppp/pptpd-options<<END
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
nodefaultroute
lock
nobsdcomp
END
# setting up pptpd.conf
echo"option/etc/ppp/pptpd-options">/etc/pptpd.conf
echo"logwtmp">>/etc/pptpd.conf
echo"localip$ip">>/etc/pptpd.conf
echo"remoteip 10.1.0.1-100">>/etc/pptpd.conf
# adding new user
echo"$u*$p*">>/etc/ppp/chap-secrets
echo
echo"######################################################"
echo"Forwarding IPv4 and Enabling it on boot"
echo"######################################################"
cat>>/etc/sysctl.conf<<END
net.ipv4.ip_forward=1
END
sysctl-p
echo
echo"######################################################"
echo"Updating IPtables Routing and Enabling it on boot"
echo"######################################################"
iptables-t nat-A POSTROUTING-j SNAT--to$ip
# saves iptables routing rules and enables them on-boot
iptables-save>/etc/iptables.conf
cat>/etc/network/if-pre-up.d/iptables<<END
#!/bin/sh
iptables-restore</etc/iptables.conf
END
chmod+x/etc/network/if-pre-up.d/iptables
cat>>/etc/ppp/ip-up<<END
ifconfig ppp0 mtu 1400
END
echo
echo"######################################################"
echo"Restarting PoPToP"
echo"######################################################"
sleep 5
/etc/init.d/pptpd restart
echo
echo"######################################################"
echo"Server setup complete!"
echo"Connect to your VPS at$ip with these credentials:"
echo"Username:$u##### Password:$p"
echo"######################################################"
# runs this if option 2 is selected
elif test$x-eq 2; then
echo"Enter username that you want to create(eg. client1 or john):"
read u
echo"Specify password that you want the server to use:"
read p
# get the VPS IP
ip=`ifconfig venet0:0| grep'inet addr'| awk{'print$2'}| sed s/.*://`
# adding new user
echo"$u*$p*">>/etc/ppp/chap-secrets
echo
echo"######################################################"
echo"Addtional user added!"
echo"Connect to your VPS at$ip with these credentials:"
echo"Username:$u##### Password:$p"
echo"######################################################"
else
echo"Invalid selection, quitting."
exit
fi
Linux系统上PPTP协议VPN服务器架设方法
VPN服务常用的协议一般有两种:
PPTP——PPTP(点对点隧道协议)是一个很好的,轻量级的VPN协议,高速提供基本的在线安全。 PPTP是内建于各种桌面和移动设备,并有128位加密功能。相比L2TP速度更快。
L2TP——附带IPsec(IP安全)的L2TP(第2层隧道协议)是非常安全的协议,其内置于多种桌面和移动设备。L2TP/IPsec采用256位加密,但额外的安全开销比PPTP需要更多的CPU使用率。
我们在这篇文章中要讲的便是PPTP的VPN架设,点对点隧道协议(PPTP)是由包括微软和3Com等公司组成的PPTP论坛开发的一种点对点隧道协,基于拨号使用的PPP协议使用PAP或CHAP之类的加密算法,或者使用 Microsoft的点对点加密算法MPPE。其通过跨越基于 TCP/IP的数据网络创建 VPN实现了从远程客户端到专用企业服务器之间数据的安全传输。PPTP支持通过公共网络(例如 Internet)建立按需的、多协议的、虚拟专用网络。PPTP允许加密 IP通讯,然后在要跨越公司 IP网络或公共 IP网络(如 Internet)发送的 IP头中对其进行封装。
PPTP是一个比较简单的VPN构建方式,但是很难找到比较全的说明文档。因此,记录一篇说明文档,详细记录架设VPN服务器以及总结一些其他比较容易遇到的问题。
安装PPTP
基本上安装pptp是比较简单的了,比如在我的CentOS6.4 x64上,只需要两个命令:
复制代码代码如下:
rpm-i
yum-y install pptpd
如果是Ubuntu的话,更加简单了:
复制代码代码如下:
apt-get install pptpd
配置IP地址
基本上程序的安装是全自动完成的了,下面需要进行一些简单的配置,编辑/etc/pptpd.conf,在最后加入IP地址配置:
复制代码代码如下:
localip 10.0.0.1
remoteip 10.0.0.100-200
上面的IP地址是可以随便填的,ABC三类的内网地址都可以,主要兼顾其他地方的IP配置,不要出现IP冲突就可以了,后面的remoteip,默认从第一个10.0.0.100开始分配给客户,localip表示分配给服务器的内部网关地址。
配置客户端DNS
要配置客户端的dns,首先要确定配置文件,查看/etc/pptpd.conf中指定的option文件,如果没有指定,那就默认是/etc/ppp/pptpd-options,下面是我的默认配置文件,因此要修改/etc/ppp/pptpd-options.pptpd
在配置文件中加上:
复制代码代码如下:
ms-dns 202.96.128.86
ms-dns 202.96.128.166
这里配置成客户端所在地的DNS就好了。
配置VPN账号
然后是创建VPN的账号,账号保存在/etc/ppp/chap-secrets,我们打开编辑这个文件,按下面的格式加入自己的账号以及密码,依次为:账号,协议,密码,ip地址。
这里的ip地址如果明文表示静态分配,如果填*就表示动态分配。
启动服务
配置完毕,可以启动服务并且加入启动项了
复制代码代码如下:
service pptpd restart
chkconfig pptpd on
查看一下服务器是否在1723上面监听了
配置系统转发
现在的VPN服务可以连上,但是不能通过VPN服务器进行转发,也就是不能够上网或者访问其他服务器等,需要开启系统转发和NAT。编辑系统配置文件/etc/sysctl.conf,设置如下值为1
复制代码代码如下:
net.ipv4.ip_forward= 1
如果未来ipv6普及了,估计应该就是改ipv6了,修改完毕之后要马上生效,使用命令
复制代码代码如下:
sysctl-p
配置防火墙转发
复制代码代码如下:
iptables-t nat-A POSTROUTING-o eth0-j MASQUERADE
或
复制代码代码如下:
iptables-t nat-A POSTROUTING-s 10.0.0.0/24-o eth0-j SNAT--to 115.115.115.115
其中第一种比较简单,自动伪装ip,第二种的10.0.0.0/24指的是VPN虚拟内网,而115.115.115.115代表外网地址,进行NAT。如果VPN服务器是用来代理上网的,仅有上面的配置会出现访问网站缓慢的情况,需要手动修改一下转发包的mss
复制代码代码如下:
iptables-A FORWARD-p tcp--syn-s 10.0.0.0/24-j TCPMSS--set-mss 1356
这样就不会出现打不开网页的问题了,最后可以保存一下防火墙。
复制代码代码如下:
iptables-save
常见的问题
619错误
很多人在拨VPN的时候卡在验证用户名和密码,然后会出现619的错误,这种错误90%以上是由于客户端到服务器的网络中有设备不支持GRE协议或NAT-T造成的,最常见的是由于客户端的路由器等不支持造成的,在更换以后立马能拨上VPN。而这种错误在服务端的日志也有体现。例如
复制代码代码如下:
LCP: timeout sending Config-Requests
下面是双方加解密不一致的:
复制代码代码如下:
LCP terminated by peer(^O^XH-^@<M-Mt^@^@^@^@)
pptp需要用到的端口
pptp使用到的端口只有一个,那就是1723,网上有很多误人子弟的文章还说要开47端口,真是坑爹,因为GRE协议号是47,并不代表需要开47端口,因此如果是要映射端口的话,1723就完全够了,不要信网上的某些教程,如果使用了iptable来作为防火墙,需要加入规则
复制代码代码如下:
iptables-A INPUT-p tcp--dport 1723-j ACCEPT
iptables-A INPUT-p 47-j ACCEPT
如果是在内网中,需要网关转发,那么网关需要如下配置:
复制代码代码如下:
iptables-t nat-A PREROUTING-i eth0-p tcp--dport 1723-j DNAT--to SERVER_IP
iptables-t nat-A PREROUTING-i eth0-p 47-j DNAT--to SERVER_IP