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 ...
随机推荐
- HTTP基础认证Basic Authentication
HTTP基础认证Basic Authentication Basic Authentication是一种HTTP访问控制方式,用于限制对网站资源的访问.这种方式不需要Cookie和Session,只需 ...
- Xamarin.Forms的ActivityIndicator和ProgressBar比较
Xamarin.Forms的ActivityIndicator和ProgressBar比较 在Xamarin.Forms中,控件ActivityIndicator和ProgressBar都用来表示 ...
- [CQOI2018] 社交网络
题目背景 当今社会,在社交网络上看朋友的消息已经成为许多人生活的一部分.通常,一个用户在社交网络上发布一条消息(例如微博.状态.Tweet等) 后,他的好友们也可以看见这条消息,并可能转发.转发的消息 ...
- 官方Java编码规范
先由Sun制定,之后Sun把Java卖给了Oracle,最后就成了Oracle制定的了.但是版本比较旧了,停留在1999年. 相比Google的编码规范,罪名写的却别就是Sun采用的是4个空格进行缩进 ...
- Windows系统文件详解【大全】
这是网络上转载的一篇文章,找不到原创的出处了--详细的介绍了WINDOWS系统文件的用途,我想各位保存一份以后说不定会有用吧,呵呵..这里按A到Z为大家分好类了,查询的话可以按键盘的Ctrl+F进行搜 ...
- Basic Vim Configuration
原文: https://computers.tutsplus.com/tutorials/basic-vim-configuration--cms-21498 原来,vim的配置文件,.vimrc也是 ...
- C#应用程序配置文件.config介绍
我们经常会希望在程序中写入一些配置信息,例如版本号,以及数据库的连接字符串等.你可能知道在WinForm应用程序中可以利用Properties.Settings来进行类似的工作,但这些其实都利用了Ap ...
- 非常不错的ajax原理总结
在工作中用了Ajax N多次了,也看过一些相关方面的书籍,也算是认识了它,但是一直没有认真总结和整理过相关的东东,失败!近有闲情,将之总结如下:[名称]Ajax是Asynchronous JavaSc ...
- jquery 的父子节点
1.一级父节点 parent() n级父节点 parents(???). 2.一级子节点 children() n级子节点 用find(???)
- run kubernetes
use kubeadm in lab only,,, do not use it in production install docker 1.12.6 -.. please noted ...