PPTP&L2TP&PPPOE client and server configure
一. PPPOE
1. server(参考http://laibulai.iteye.com/blog/1171898)
(1)安装rp-pppoe:yum install rp-pppoe
(2)配置 /etc/ppp/pppoe-server-options,内容:
# PPP options for the PPPoE server
# LIC: GPL
require-pap
require-chap
login
lcp-echo-interval 10
lcp-echo-failure 2
logfile /var/log/pppoe.log
ms-dns 8.8.4.4
iptables -A FORWARD -p tcp --syn -s 10.10.10.0/24 -j TCPMSS --set-mss 1256
echo 1 > /proc/sys/net/ipv4/ip_forward
sysctl -w net.ipv4.ip_forward=1
<1>修改/etc/xl2tpd/xl2tpd.conf
[global]
listen-addr = 45.62.96.30 #改成自己本机的IP
ipsec saref = yes
[lns default]
ip range = 192.168.1.128-192.168.1.254 #分配的客户端IP
local ip = 192.168.1.1 #本地IP 不用改
refuse chap = yes #改成refuse
refuse pap = yes
require authentication = yes
name = l2tp
ppp debug = yes
pppoptfile = /etc/ppp/options.xl2tpd
length bit = yes
<2>修改/etc/ppp/options.xl2tpd
ipcp-accept-local
ipcp-accept-remote
ms-dns 8.8.8.8
ms-dns 8.8.4.4
noccp
auth
crtscts
debug
hide-password
modem
lock
proxyarp
<3>修改/etc/ipsec.conf 在末尾添加(注:conn前面没有空格,其他行以tab空开)
conn L2TP-PSK-NAT
rightsubnet=vhost:%priv
also=L2TP-PSK-noNAT
conn L2TP-PSK-noNAT
authby=secret
pfs=no
auto=add
keyingtries=3
rekey=no
ikelifetime=8h
keylife=1h
type=transport
left=45.62.96.30 #这边替换成你的本机IP
leftprotoport=17/1701
right=%any
rightprotoport=17/%any
<4>添加/etc/ipsec.secrets 预定义密钥(注:PSK前面有空格)
vi /etc/ipsec.secrets
45.62.96.30 %any: PSK "test1234" #ip地址替换成你的本机ip
<5>设置网络策略(这个我也不懂)
直接在终端输入
for each in /proc/sys/net/ipv4/conf/*
do
echo 0 > $each/accept_redirects
echo 0 > $each/send_redirects
done
<6>创建账户文件
vi /etc/ppp/chap-secrets
里面格式为(如我的)
#用户名 * 密码 *
lizhug * 1234567890 *
<7>修改系统配置文件/etc/sysctl.conf 在结尾添加
net.ipv4.ip_forward = 1
net.ipv4.conf.default.rp_filter = 0
net.ipv4.conf.all.send_redirects = 0
net.ipv4.conf.default.send_redirects = 0
net.ipv4.conf.all.log_martians = 0
net.ipv4.conf.default.log_martians = 0
net.ipv4.conf.default.accept_source_route = 0
net.ipv4.conf.all.accept_redirects = 0
net.ipv4.conf.default.accept_redirects = 0
net.ipv4.icmp_ignore_bogus_error_responses = 1 执行 sysctl -p 是上面的设置生效
<8>修改防火墙设置,直接在终端执行
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
service iptables save
service iptables restart
<9>测试执行(注:这里遇到了faild initiallize nss database 的错误,通过更新nss-tools包成功:yum install nss-tools)
ipsec setup start
ipsec verify
出现如下提示就OK,如果出现了FAILED,直接粘贴google找修改方法
[root@default ~]# ipsec verify
Checking your system to see if IPsec got installed and started correctly:
Version check and ipsec on-path [OK]
Linux Openswan U2.6.32/K(no kernel code presently loaded)
Checking for IPsec support in kernel [OK]
SAref kernel support [N/A]
Checking that pluto is running [OK]
Pluto listening for IKE on udp 500 [OK]
Pluto listening for NAT-T on udp 4500 [OK]
Checking for 'ip' command [OK]
Checking /bin/sh is not /bin/dash [OK]
Checking for 'iptables' command [OK]
Opportunistic Encryption Support [DISABLED] 重启xl2tp
service xl2tpd restart
<10> 开放端口以及转发<参考:http://blog.csdn.net/musiccow/article/details/22904997>
原样执行下面所有命令,
#Allow ipsec traffic
iptables -A INPUT -m policy --dir in --pol ipsec -j ACCEPT
iptables -A FORWARD -m policy --dir in --pol ipsec -j ACCEPT #Do not NAT VPN traffic
iptables -t nat -A POSTROUTING -m policy --dir out --pol none -j MASQUERADE #Forwarding rules for VPN
iptables -A FORWARD -i ppp+ -p all -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT #Ports for Openswan / xl2tpd
iptables -A INPUT -m policy --dir in --pol ipsec -p udp --dport 1701 -j ACCEPT
iptables -A INPUT -p udp --dport 500 -j ACCEPT
iptables -A INPUT -p udp --dport 4500 -j ACCEPT
iptables -t nat -A POSTROUTING -s 192.168.1.0/24 -o eth0 -j MASQUERADE
再执行下面保存iptables
service iptables save
service iptables restart 11. 添加自启动
chkconfig xl2tpd on
chkconfig iptables on
chkconfig ipsec on
2.client
(1)安装:
yum install xl2tpd
yum install ppp
(2)配置/etc/xl2tpd/xl2tpd.conf
[lac testvpn(VPN名称)]
name = wufuqiang ; l2tp帐号
lns = 192.168.20.10 ; l2tp server的IP
pppoptfile = /etc/ppp/peers/testvpn.l2tpd ; pppd拨号时使用的配置文件
ppp debug = yes
(3)vi /etc/ppp/peers/testvpn.l2tpd
remotename testvpn
user wufuqiang
password 1234567890
unit 0
lock
nodeflate
nobsdcomp
noauth
persist
nopcomp
noaccomp
maxfail 5
debug
5、 配置文件都建好后,可以启动xl2tpd了,注意启动不代表拨号
运行方式1: 运行/etc/init.d/xl2tpd start即可,这种启动方式会自动去找/etc/xl2tpd/xl2tpd.conf这个配置文件,(每次修改xl2tpd.conf配置文件都要重启(restart)xl2tpd服务,重新加载配置文件方能成功!)
运行方式2:# xl2tpd -c "/your/config_file/path",如果使用此方法,要确保存在/var/run/xl2tpd/这个目录,其实看看/etc/init.d/xl2tpd这个文件也可以看出来,如果不存在,脚本会创建这个目录
6、 开始拨号:
# echo 'c testvpn' > /var/run/xl2tpd/l2tp-control
拨号成功的话,通过ifconfig可以看见有个ppp0的接口
7、 断开连接:
# echo 'd testvpn' > /var/run/xl2tpd/l2tp-control
8、启动xl2tpd到拨号,整个过程可查看日志
tail -f /var/log/message
三.PPTP(参考http://www.dabu.info/centos6-4-structures-pptp-vpn.html)
1.server
(1)检测
#modprobe ppp-compress-18 && echo ok
(2)安装ppp和iptables
#yum install -y perl ppp iptables //centos默认安装了iptables和ppp
版本要对yum list installed ppp显示版本
ppp 2.4.4——————>pptpd 1.3.4
ppp 2.4.5——————>pptpd 1.4.0
(3)安装pptpd
#rpm -Uvh http://poptop.sourceforge.net/yum/stable/rhel6/pptp-release-current.noarch.rpm
#yum install pptpd
(4)修改配置/etc/ppp/options.pptpd,加入以下内容
ms-dns 8.8.8.8
ms-dns 8.8.4.4
(5)配置文件/etc/ppp/chap-secrets
# Secrets for authentication using CHAP
# client server secret IP addresses
myusername pptpd mypassword *
//myusername是你的vpn帐号,mypassword是你的vpn的密码,*表示对任何ip,记得不要丢了这个星号。我这里根据这个格式,假设我的vpn的帐号是ksharpdabu,密码是 sky。那么,应该如下:
ksharpdabu pptpd sky *
(6)配置文件/etc/pptpd.conf
添加下面两行:
localip 192.168.9.1
remoteip 192.168.9.11-30 //表示vpn客户端获得ip的范围
关键点:pptpd.conf这个配置文件必须保证最后是以空行结尾才行,否则会导致启动pptpd服务时,出现“Starting pptpd:”,一直卡着不动的问题,无法启动服务,切记呀!
(7)配置文件/etc/sysctl.conf
将net.ipv4.ip_forward = 0 改成 net.ipv4.ip_forward = 1
保存修改后的文件
#/sbin/sysctl -p
(8)启动pptp vpn服务和iptables
#/sbin/service pptpd start 或者 #service pptpd start
2.client(参考https://linuxconfig.org/how-to-establish-pptp-vpn-client-connection-on-centos-rhel-7-linux)
(1)安装pptp
yum install pptp
(2)pptp支持模块
#modprobe nf_conntrack_pptp ;
或者添加mppe模块:
modprobe ppp_mppe
(3)配置 /etc/ppp/chap-secrets
admin pptp password *
(4)在/etc/ppp/peers/目录下创建linuxconfig文件,以下是内容
pty "pptp 192.168.20.10 --nolaunchpppd"
name wfqgtxvpn
remotename pptpd
require-mppe-128
file /etc/ppp/options.pptp
ipparam linuxconfig
(5)连接
#pppd call linuxconfig
查看/var/log/messages 日志,分析错误
(6)断开
#pkill pppd
PPTP&L2TP&PPPOE client and server configure的更多相关文章
- RouterOS安装以及搭建DHCP PPPoE PPTP L2TP服务
1.安装routeros https://mikrotik.com/download 网站下载routeros镜像 vdi格式 :VirtualBox默认创建的硬盘文件格式 vmdk格式:VMware ...
- UDP编程中client和server中使用recvfrom和sendto的区别
client中: sendto(sfd,buf,strlen(buf),0,(struct sockaddr *)&saddr,len); recvfrom(sfd,buf ...
- tmux protocol version mismatch (client 7, server 6)
$ tmux attach protocol version mismatch (client 7, server 6) $ pgrep tmux 3429 $ /proc/3429/exe atta ...
- VPN协议PPTP/L2TP/OpenVPN及SSH的区别与详解
大家在使用VPN的时候都会看到商家有提供PPTP VPN.L2TP VPN.OpenVPN.SSH代理等多种协议选择,但是许多朋友却不知道它们之间有什么区别,也不知道该如何选择,今天整理了一些日常收 ...
- New full duplex HTTP tunnel implementation (client and server)
https://issues.jboss.org/browse/NETTY-246?page=com.atlassian.jirafisheyeplugin:fisheye-issuepanel —— ...
- jvm的client和server
最近研究c++代码调用java的jar,发现64位的下的jvm在server路径,而32位的jvm则存在client路径下面,于是十分好奇,查了下,这里做个记录 JVM Server模式与client ...
- Android简单的聊天室开发(client与server沟通)
请尊重他人的劳动成果.转载请注明出处:Android开发之简单的聊天室(client与server进行通信) 1. 预备知识:Tcp/IP协议与Socket TCP/IP 是Transmission ...
- The client and server cannot communicate, because they do not possess a common algorithm
The client and server cannot communicate, because they do not possess a common algorithm This was re ...
- go http client, http server
Go语言中的HTTP client, server非常简单.具体如下. HTTP Server package main import ( "fmt" "html&quo ...
随机推荐
- UPC 2219: A^X mod P
题形:另类快速幂 题意: f(x) = K, x = 1 f(x) = (a*f(x-1) + b)%m , x > 1 Now, Your task is to calculate ( A^( ...
- hdu 4632 子字符串统计的区间dp
题意:查找这样的子回文字符串(未必连续,但是有从左向右的顺序)个数. 简单的区间dp,哎,以为很神奇的东西,其实也是dp,只是参数改为区间,没做过此类型的题,想不到用dp,以后就 知道了,若已经知道[ ...
- ecshop二次开发系统缓存优化之扩展数据缓存的必要性与方法
1.扩展数据缓存的必要性 大家都知道ecshop系统使用的是静态模板缓存,在后台可以设置静态模板的缓存时间,只要缓存不过期,用户访问页面就相当于访问静态页面,速度可想而知,看似非常完美,但是ecsho ...
- k8s之pod控制器
1.生产中,很少会跑一个自主式pod,一般由控制器去创建pod,其配置文件中内嵌了pod的创建方式. pod控制器:ReplicaSet.Deployment.DaemonSet.Job.Cronjo ...
- java单例模式教程之java实现单例模式的8大方法
单例模式是Java中常用的设计模式之一.单例模式属于创建型模式,它提供了一种创建对象的最佳方式. 单例模式只创建类的一个对象,之后在一定范围为可任意调用,确保只有单个对象被创建.这个类提供了一种访问其 ...
- 转置卷积&&膨胀卷积
Convolution arithmetic tutorial theano Convolution arithmetric github 如何理解深度学习中的deconvolution networ ...
- python3 查看已安装的模块
一.命令行下使用pydoc命令 在命令行下运行$ pydoc modules即可查看 二.在python交互解释器中使用help()查看 在交互式解释器中输入>>> help(&qu ...
- yarn 基本用法
1.初始化一个新的项目 yarn init 2.添加一个依赖包 yarn add [package] yarn add [package]@[version] yarn add [package]@[ ...
- android RecycleView复杂多条目的布局
用RecycleView来实现布局形式.默认仅仅能指定一种布局格式.可是实际中我们的布局常常会用到多种类型的布局方式.怎样实现呢? 今天来说下经常使用的2钟方式. 第一种: 通过自己定义addHead ...
- wdatepicker ie8等问题
官方文档:http://www.my97.net/demo/resource/2.4.asp 以下内容为使用中遇到的问题,具体该插件具有的方法请自行查阅官方文档. 1.当触发wdatepicker事件 ...