`
haoningabc
  • 浏览: 1465984 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

xl2tp 中继器

阅读更多
参考https://haoningabc.iteye.com/admin/blogs/2517083

aws的redhat8搭建的xl2tp不能直接连ios了,不知道为什么,是8的问题还是aws的问题?
目前用腾讯云的centos7作为xl2tp的中转:
ios连centos7 ,centos7上搭建xl2tp的客户端和服务端,客户端连接aws的redhat8的xl2tp


关键问题注意4:

前提
ios:192.168.2.128

tx
eth0:172.17.0.13
ppp0:172.17.0.13 --->192.168.1.99
ppp1:192.168.2.99---->192.168.2.128

aws:
外网 13.115.114.179 
eth0:172.31.12.85 
ppp0:192.168.1.99 --->172.17.0.13



1.注意1400
两个xl2tp
ifconfig eth0 mtu 1400
ifconfig ppp0 mtu 1400
ifconfig lo mtu 1400

所有可见的地方全1400
1500似乎有时候有问题
/etc/xl2tpd/xl2tpd.conf--->/etc/ppp/options.xl2tpd 设置mtu和mru为 1400



2.注意 promisc ,
tx和aws 两个 eth0 和两个 ppp0都需要
ifconfig eth0 promisc
ifconfig ppp0 promisc

3.iptables

tx :
iptables -t nat -A POSTROUTING -s 172.17.0.0/24  -o eth0  -j MASQUERADE
iptables -t nat -A POSTROUTING -s 192.168.2.0/24  -o ppp0  -j MASQUERADE
aws:
iptables -t nat -A POSTROUTING -s 172.17.0.0/24  -o eth0  -j 
 MASQUERADE

注意这里 虽然aws的本机段式172.31.12.85
这个操作是把ppp0 后面的 tx的ip段 172.17.0.13 做了snat
snat原理参考:
https://blog.csdn.net/jk110333/article/details/8229828



4.ip route

客户端连 server的时候
route del default 的时候就断网了(这个是关键问题)
需要
route add -host 13.115.114.179 dev eth0
如果是加网段:
route add -net  117.136.38.0 netmask 255.255.255.0 dev eth0


用这个方式把固定需要接入tx的ios和远程ssh的客户端ip全加进来,否则后续都连不上了
三个ip地方确认: 1. aws的server,2.ssh客户端ip 3.ios 客户端的ip


5.系统 没有firewalld 有NetworkManager


6.sysctl -p /etc/sysctl.conf

7. xl2tpd
tx作为客户端,和服务端
客户端需要配置lac testvpn ,具体的链接密码放在/etc/ppp/peers/aws.l2tpd
注意,配置完systemctl start  xl2tpd可能启动不了,重启才行,是内核模块的问题?


xl2tpd的配置 客户端需要
[lac testvpn]
lns =  13.115.114.179
pppoptfile = /etc/ppp/peers/aws.l2tpd
ppp debug = yes
[global]
force userspace = yes

服务端需要
[global]
ipsec saref = no
force userspace = yes



具体设置:

##################
基本安装:
dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm 
dnf install screen
dnf install libreswan xl2tpd  NetworkManager-l2tp -y  
yum install iptables nc  -y
telnet不能检测udp端口,用nc检测
nc -vuz 13.115.114.179 4500

##########################
配置xl2tpd
tx 客户端配置:
vim /etc/xl2tpd/xl2tpd.conf
[lac testvpn]
;name = root
;lns = 13.114.212.191
;lns =  52.196.182.31
lns =  13.115.114.179
;pppoptfile = /etc/ppp/peers/testvpn.l2tpd
pppoptfile = /etc/ppp/peers/aws.l2tpd
ppp debug = yes

[global]
;ipsec saref = no
force userspace = yes
; listen-addr = 192.168.1.98
;
; requires openswan-2.5.18 or higher - Also does not yet work in combination
; with kernel mode l2tp as present in linux 2.6.23+
; ipsec saref = yes
; Use refinfo of 22 if using an SAref kernel patch based on openswan 2.6.35 or
;  when using any of the SAref kernel patches for kernels up to 2.6.35.
; saref refinfo = 30
;
; force userspace = yes
;
; debug tunnel = yes

[lns default]
ip range = 192.168.2.128-192.168.2.254
local ip = 192.168.2.99
require chap = yes
refuse pap = yes
require authentication = yes
name = LinuxVPNserver
ppp debug = yes
pppoptfile = /etc/ppp/options.xl2tpd
length bit = yes



tx作为客户端角色的自配置,主要配置用户名和密码;
/etc/ppp/peers/aws.l2tpd
remotename testvpn
user "root"
password "Haohao123"
unit 0
nodeflate
nobsdcomp
noauth
persist
nopcomp
noaccomp
maxfail 5
debug


tx作为服务端服务端角色的子配置,主要mtu和mru 设置1400
/etc/ppp/options.xl2tpd
ipcp-accept-local
ipcp-accept-remote
ms-dns  8.8.8.8
noccp
require-mschap-v2
auth
idle 1800
mtu 1400
mru 1400
nodefaultroute
debug
proxyarp
connect-delay 5000



aws端的xltpd的配置:
/etc/xl2tpd/xl2tpd.conf
只加了
[global]
ipsec saref = no
force userspace = yes

内容为:
[global]
ipsec saref = no
force userspace = yes
; listen-addr = 192.168.1.98
;
; requires openswan-2.5.18 or higher - Also does not yet work in combination
; with kernel mode l2tp as present in linux 2.6.23+
; ipsec saref = yes
; Use refinfo of 22 if using an SAref kernel patch based on openswan 2.6.35 or
;  when using any of the SAref kernel patches for kernels up to 2.6.35.
; saref refinfo = 30
;
; force userspace = yes
;
; debug tunnel = yes

[lns default]
ip range = 192.168.1.128-192.168.1.254
local ip = 192.168.1.99
require chap = yes
refuse pap = yes
require authentication = yes
name = LinuxVPNserver
ppp debug = yes
pppoptfile = /etc/ppp/options.xl2tpd
length bit = yes


aws的xl2tpd服务端的子配置
/etc/ppp/options.xl2tpd
ipcp-accept-local
ipcp-accept-remote
ms-dns  8.8.8.8
ms-dns  1.1.1.1
# ms-dns  192.168.1.1
# ms-dns  192.168.1.3
# ms-wins 192.168.1.2
# ms-wins 192.168.1.4
noccp
auth
#obsolete: crtscts
idle 1800
mtu 1400
mru 1400
nodefaultroute
debug
#obsolete: lock
proxyarp
connect-delay 5000
# To allow authentication against a Windows domain EXAMPLE, and require the
# user to be in a group "VPN Users". Requires the samba-winbind package
# require-mschap-v2
# plugin winbind.so
# ntlm_auth-helper '/usr/bin/ntlm_auth --helper-protocol=ntlm-server-1 --require-membership-of="EXAMPLE\\VPN Users"'
# You need to join the domain on the server, for example using samba:
# http://rootmanager.com/ubuntu-ipsec-l2tp-windows-domain-auth/setting-up-openswan-xl2tpd-with-native-windows-clients-lucid.html




关于ipsec的配置:
tx上 没有改/etc/ipsec.conf
新增;/etc/ipsec.d/l2tp-ipsec.conf
conn L2TP-PSK-NAT
    rightsubnet=0.0.0.0/0
    dpddelay=10
    dpdtimeout=20
    dpdaction=clear
    encapsulation=yes
    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=172.17.0.13
    leftprotoport=17/1701
    right=%any
    rightprotoport=17/%any


left为本机eth0的ip
这里没有配置nexthop,不知道是否需要

aws上的ipsec的配置:
没有改/etc/ipsec.conf
新增:
/etc/ipsec.d/l2tp-ipsec.conf
conn L2TP-PSK-NAT
    rightsubnet=0.0.0.0/0
    dpddelay=10
    dpdtimeout=20
    dpdaction=clear
    forceencaps=yes
    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=172.31.12.85
    leftprotoport=17/1701
    right=%any
    rightprotoport=17/%any

和tx类似:
left为本机eth0的ip


#####################
密码文件:
tx:
/etc/ipsec.d/default.secrets

:   PSK "Haohao123!"
aws:

: PSK "Haohao123"


tx:
cat /etc/ppp/chap-secrets
root    *   haha123 *

aws:
cat /etc/ppp/chap-secrets
# Secrets for authentication using CHAP
# client	server	secret			IP addresses
root	*	Haohao123  *




这两个结合一下
ipv4.sh:
#!/bin/sh
for each in /proc/sys/net/ipv4/conf/*
do
    echo 0 > $each/accept_redirects
    echo 0 > $each/send_redirects
done

/etc/sysctl.conf
net.ipv4.ip_forward = 1  
net.ipv4.conf.all.accept_redirects = 0  
net.ipv4.conf.all.rp_filter = 0  
net.ipv4.conf.all.send_redirects = 0  
net.ipv4.conf.default.accept_redirects = 0  
net.ipv4.conf.default.rp_filter = 0  
net.ipv4.conf.default.send_redirects = 0  
net.ipv4.conf.eth0.accept_redirects = 0  
net.ipv4.conf.eth0.rp_filter = 0  
net.ipv4.conf.eth0.send_redirects = 0  
net.ipv4.conf.lo.accept_redirects = 0  
net.ipv4.conf.lo.rp_filter = 0  
net.ipv4.conf.lo.send_redirects = 0


sysctl -p /etc/sysctl.conf

ipsec verify


配置完xl2tpd 启动不了
重启init 6
试验一下 果然ok了
nc -vuz 13.115.114.179 4500

nc -vuz 13.115.114.179 1701


route add -host 81.68.183.137 dev eth0   
# route add -host 10.20.30.148 gw 10.20.30.40 


route add -host 13.115.114.179 dev eth0

最后
systemctl start ipsec
ipsec verify
检查
systemctl start xl2tpd



tail -f /var/log/message


ifconfig
ip route检查


客户端启动脚本:
checkppp0.sh
#!/bin/sh
ppp0=`ifconfig |grep ppp0`
if [ ! -n "$ppp0" ] ;then
    a="will start vpn"
    echo 'c testvpn' > /var/run/xl2tpd/l2tp-control
    sleep 5
    route del default
    ip link set ppp0 up
    /usr/sbin/route add default dev ppp0
    touch /opt/c
else
    ip link set ppp0 up
    /usr/sbin/route add default dev ppp0
    a="noting to do"
fi
/usr/sbin/ifconfig ppp0

echo $a
#route add -net  117.136.38.0 netmask 255.255.255.0 dev eth0
#ip route get 172.17.0.13










分享到:
评论

相关推荐

    xl2tpd-1.2.4开源源代码,可用于linux系统

    xl2tpd-1.2.4是l2tp的lns端的开源源代码,可用于linux系统

    ipsec+l2tp安装配置及插件

    linux下ipsec+l2tp安装配置及插件

    CentOS7.2 安装L2TP/IPSec 服务端/客户端 ( libreswan+xl2tpd )

    配套说明: http://blog.csdn.net/gogoytgo/article/details/79420745

    xl2tpd-1.3.0开源源代码

    xl2tpd-1.3.0可用于l2tp的lns或者服务器端,这是个开源的代码库

    centos7搭建基于strongswan ipsec的 l2tp服务器

    centos7下搭建ipsec l2tp服务器,使用strongswan来构建ipsec.

    xl2tpd:L2TPd 的官方 Xelerance 分叉

    一些 ISP 使用 L2TP 将用户会话从拨入服务器(调制解调器银行、ADSL DSLAM)传输到后端 PPP 服务器。 另一个重要的应用是虚拟专用网络,其中IPsec协议用于保护L2TP连接(L2TP / IPsec由定义。xl2tpd可以与IPsec实现...

    xl2tpd的makefile文件

    xl2tpd的makefile文件

    美国NITON+XL2+800介绍.pdf

    NITON XL2 800是一款专为金属合金成分分析设计的手持式X射线荧光光谱仪。这款设备结合了快速、准确和可靠的特点,为用户提供量身定制的解决方案,尤其适用于非技术人员操作。它配备了中文彩色显示屏,方便用户理解和...

    NetworkManager-l2tp:对NetworkManager的L2TP和L2TPIPsec支持

    对于L2TP支持,它使用xl2tpd( ) 为了获得IPsec支持,它使用以下任一方法: 利伯斯旺( ) strongSwan( ) 对于用户身份验证,它支持: 用户名/密码凭据。 TLS证书。 对于机器身份验证,它支持: 预共享...

    一个L2TP调试案例

    一个L2TP的调试案例,故障排除 故障分析

    美国尼通XL2-980合金分析仪.pdf

    【Niton XL2-980合金分析仪】是由美国尼通公司制造的一款手持式光谱仪,专门用于合金的快速、准确分析。这款设备在IT行业中的应用主要体现在材料科学和质量控制领域,尤其适合那些需要现场进行金属成分检测的场景。 ...

    tomato-K26-1.28.0542-MIPSR1-4M-8M

    解决BUG: [L2TP] xl2tpd由1 26升级1 30 试图解决俄罗斯用户无法L2TP拨号的问题 解决BUG: [L2TP] 解决WAN连接类型为L2TP时 L2TP拨上后1分钟左右就断线的BUG 功能加强: [USB] 升级3G上网卡驱动usb modeswitch data ...

    EXCEL表格转换成CAD图纸

    花了两天时间,仿照 KozMos XL2CAD 的程序同样写了一个Excel2CAD程序,控制对话框就直接照搬 KozMos XL2CAD的对话框,操作方式完全和他一样! 2013年6月22日公布全部源码 2013.06.11更新程序 : 增加按Excel页面...

    ubuntu_script_l2tp_ipsec.sh

    Ubuntu下使用strongswan和xl2ptd搭建l2pt/ipsec服务,使用预共享密钥和账号密码登录的脚本。

    基于L2TP和IPSec集成的车载无线终端传输网络设计

    在应对突发事件救援行动中,指挥中心能否通过互联网取得第一手资料,必要的条件...为克服以上不足,详细阐述了由L2TP和IPSec集成的一种新颖的隧道网络过程,并介绍了L2TP和IPSec的集成方案,最后完成了对本方案的测试。

    Persian xl2tpd-开源

    适用于Linux和其他基于POSIX的操作系统的第2层隧道协议VPN客户端/守护程序。 “注意:Packets Analyzer无法检测到l2tp数据包。”

    pppd-backend:执行后端程序以检查 pppd 的用户名密码对

    在 /etc/ppp/pptp-options 和 /etc/ppp/options.xl2tp 中,添加: debug plugin backend.so backend_command "/etc/ppp/auth.sh" 将命令替换为您要执行的内容。 可执行文件的第一个参数是用户名。 如果用户有效,...

    0xl2oot.github.io:我的博客-为了我的爱

    Jekyll 是一个静态站点生成器,它将文本格式的内容转换成静态网页,特别适合用于创建个人博客。Jekyll 使用 Markdown 语言撰写博客文章,这种语言简洁易读,同时也方便开发者进行排版和样式设计。此外,Jekyll 还...

    ubuntu环境下多种服务器搭建教程

    安装相关软件,配置 `/etc/xl2tpd/xl2tpd.conf` 和 `/etc/ppp/peers/l2tp-server` ,设置认证方式、IP地址池等,启动服务后,用户就能通过L2TP连接到服务器。 4. PPPOE服务器搭建:PPPOE(拨号以太网)用于模拟传统...

Global site tag (gtag.js) - Google Analytics