VPN爱好者福音(纯技术分享篇)-爱陆通5G工业路由器建立L2TP VPN全过程报文解析
应用场景说明:
在项目应用上经常需要用到VPN技术来实现组网,常见的VPN有IPSEC、L2TP、PPTP、SSL、GER、OPENvpn等等,当下由于5G网络IP都是内网IP,因此想实现远程访问5G工业路由器最广泛有效的方式就是建立VPN网络。L2TP VPN作为经常使用的VPN技术之一,深受项目技术人员的拥戴和喜爱。
虽然L2TP VPN技术是通用的,但实际项目中往往会遇到各种疑难杂症,这个就是涉及到工业路由器厂家的研发人员对L2TP VPN底层报文交互的理解和专业度了,也涉及工业路由器和服务器建立VPN之后系统资源的调配和释放,这也是为什么项目技术人员经常遇到L2TP VPN运行了一段时间后出现断网假连接的现象。
实际上VPN技术非常考验5G工业路由器厂家的技术实力,也很考验5G工业路由器产品长期不间断运行的可靠性,VPN实现功能不难,但能否适配各种品牌的VPN服务器且长期不间断稳定运行是体现5G工业路由器品质的重要参数。
以下为5G工业路由器建立L2TP VPN网络的报文全过程详细解读,可以有助于项目技术人员遇到无法建立VPN时快速定位和排查问题。
L2TP建立流程
上图所示为L2TP隧道和会话的建立过程,之后会经过建立PPP拨号,开始数据的封装传输。
1. 建立L2TP隧道
先由客户端发起隧道建立请求SCCRQ,服务器收到请求后进行应答SCCRP,最后客户端在收到应答后再给服务器返回确认SCCCN;隧道建立。
2. 建立L2TP会话
会话建立的过程与隧道类似,首先由客户端发起会话建立请求ICRQ,服务器收到请求后返回应答ICRP,客户端收到应答后返回确认ICCN,会话建立。
3. 建立PPP连接
LCP阶段:确认之间最大传输单元、认证方式(pap/chap)、魔术字防环
认证阶段:pap密码认证协议 采用明文的方式认证用户名密码。
chap挑战握手认证协议 采用附加随机挑战值进行md5加密方式认证用户名密码。
IPCP阶段:确认上层网络协议、检测IP冲突、请求IP地址(可选)
4. 数据封装传输
5.链路保持
为了确认对端的隧道依然存在,需要定时发送与对端的维护报文,其流程为:客户端和服务区都向对端发出Hello报文,对端回应ZLB。
日志报文解析
<5>Dec 6 08:23:00 l2tp-sh[9679]: Launching VPN process
<5>Dec 6 08:23:00 l2tp-sh[9679]: Process launched
<5>Dec 6 08:23:00 l2tp-sh[8876]: vpn is 0
<5>Dec 6 08:23:00 l2tp-sh[9703]: Waiting.......
<5>Dec 6 08:23:00 ipsec_setup: ...Openswan IPsec stopped
<5>Dec 6 08:23:03 l2tp-sh[9703]: PID file created
<5>Dec 6 08:23:03 l2tp-sh[9703]: Attempting initial connect
<6>Dec 6 08:23:03 l2tp[9858]: Started on Router PID:9858
<6>Dec 6 08:23:03 l2tp[9858]: Listening on IP address 0.0.0.0, port 1701
<6>Dec 6 08:23:03 l2tp[9858]: Tunnel connecting host 47.107.39.47, port 1701.
<5>Dec 6 08:23:03 l2tp[9858]: Connecting to host 47.107.39.47[47.107.39.47], port 1701(向服务器发起l2tp连接)
<6>Dec 6 08:23:03 l2tp[9858]: deal (null)(0). Tunnel is 0, call is 0.
<6>Dec 6 08:23:03 l2tp[9858]: sending SCCRQ. Tunnel is 0, call is 0.(建立l2tp隧道,客户端向服务器请求隧道ID)
<6>Dec 6 08:23:03 l2tp[9858]: 101--->
<6>Dec 6 08:23:03 l2tp[9858]: c8 02 00 65 00 00 00 00 00 00 00 00 80 08 00 00 | ...e............
<6>Dec 6 08:23:03 l2tp[9858]: 00 00 00 01 80 08 00 00 00 02 01 00 80 0a 00 00 | ................
<6>Dec 6 08:23:03 l2tp[9858]: 00 03 00 00 00 03 80 0a 00 00 00 04 00 00 00 00 | ................
<6>Dec 6 08:23:03 l2tp[9858]: 00 08 00 00 00 06 06 90 80 0c 00 00 00 07 52 6f | ..............Ro
<6>Dec 6 08:23:03 l2tp[9858]: 75 74 65 72 00 11 00 00 00 08 72 6f 75 74 65 72 | uter......router
<6>Dec 6 08:23:03 l2tp[9858]: 2c 6c 32 74 70 80 08 00 00 00 09 b5 ce 80 08 00 | ,l2tp...........
<6>Dec 6 08:23:03 l2tp[9858]: 00 00 0a 00 04 | .....
<6>Dec 6 08:23:03 l2tp[9858]: <---112
<6>Dec 6 08:23:03 l2tp[9858]: c8 02 00 70 b5 ce 00 00 00 00 00 01 80 08 00 00 | ...p............
<6>Dec 6 08:23:03 l2tp[9858]: 00 00 00 02 80 08 00 00 00 02 01 00 80 0a 00 00 | ................
<6>Dec 6 08:23:03 l2tp[9858]: 00 03 00 00 00 03 80 0a 00 00 00 04 00 00 00 00 | ................
<6>Dec 6 08:23:03 l2tp[9858]: 00 08 00 00 00 06 06 90 80 15 00 00 00 07 69 7a | ..............iz
<6>Dec 6 08:23:03 l2tp[9858]: 74 73 34 65 33 38 73 71 73 79 72 39 7a 00 13 00 | ts4e38sqsyr9z...
<6>Dec 6 08:23:03 l2tp[9858]: 00 00 08 78 65 6c 65 72 61 6e 63 65 2e 63 6f 6d | ...xelerance.com
<6>Dec 6 08:23:03 l2tp[9858]: 80 08 00 00 00 09 04 a2 80 08 00 00 00 0a 00 04 | ................
<6>Dec 6 08:23:03 l2tp[9858]: deal Start-Control-Connection-Reply(2). Tunnel is 1186, call is 0.(服务器回应客户端,发送隧道ID)
<6>Dec 6 08:23:03 l2tp[9858]: sending SCCCN. Tunnel is 1186, call is 0.(客户端向服务器确认隧道ID)
<6>Dec 6 08:23:03 l2tp[9858]: 20--->
<6>Dec 6 08:23:03 l2tp[9858]: c8 02 00 14 04 a2 00 00 00 01 00 01 80 08 00 00 | ................
<6>Dec 6 08:23:03 l2tp[9858]: 00 00 00 03 | ....
<5>Dec 6 08:23:03 l2tp[9858]: Connection established to 47.107.39.47, 1701. Local: 46542, Remote: 1186 (ref=0/0).
<5>Dec 6 08:23:03 l2tp[9858]: Calling on tunnel 46542
<6>Dec 6 08:23:03 l2tp[9858]: deal (null)(0). Tunnel is 1186, call is 0.
<6>Dec 6 08:23:03 l2tp[9858]: sending ICRQ. Tunnel is 1186, call is 0.(建立l2tp会话,客户端向服务器请求会话ID)
<6>Dec 6 08:23:03 l2tp[9858]: 48--->
<6>Dec 6 08:23:03 l2tp[9858]: c8 02 00 30 04 a2 00 00 00 02 00 01 80 08 00 00 | ...0............
<6>Dec 6 08:23:03 l2tp[9858]: 00 00 00 0a 80 08 00 00 00 0e 39 e3 80 0a 00 00 | ..........9.....
<6>Dec 6 08:23:03 l2tp[9858]: 00 0f 00 00 00 01 80 0a 00 00 00 12 00 00 00 00 | ................
<6>Dec 6 08:23:03 l2tp[9858]: <---12
<6>Dec 6 08:23:03 l2tp[9858]: c8 02 00 0c b5 ce 00 00 00 01 00 02 | ............
<6>Dec 6 08:23:03 l2tp[9858]: <---28
<6>Dec 6 08:23:03 l2tp[9858]: c8 02 00 1c b5 ce 39 e3 00 01 00 03 80 08 00 00 | ......9.........
<6>Dec 6 08:23:03 l2tp[9858]: 00 00 00 0b 80 08 00 00 00 0e 09 f1 | ............
<6>Dec 6 08:23:03 l2tp[9858]: deal Incoming-Call-Reply(11). Tunnel is 1186, call is 2545.(服务器回应客户端,发送会话ID)
<6>Dec 6 08:23:03 l2tp[9858]: sending ICCN. Tunnel is 1186, call is 2545.(客户端向服务器确认会话ID)
<5>Dec 6 08:23:03 l2tp[9858]: Call established with 47.107.39.47, Local: 14819, Remote: 2545, Serial: 1 (ref=0/0)
<6>Dec 6 08:23:03 l2tp[9858]: 50--->
<6>Dec 6 08:23:03 l2tp[9858]: c8 02 00 32 04 a2 09 f1 00 03 00 02 80 08 00 00 | ...2............
<6>Dec 6 08:23:03 l2tp[9858]: 00 00 00 0c 80 0a 00 00 00 18 00 98 96 80 80 0a | ................
<6>Dec 6 08:23:03 l2tp[9858]: 00 00 00 13 00 00 00 01 00 0a 00 00 00 26 00 98 | .............&..
<6>Dec 6 08:23:03 l2tp[9858]: 96 80 | ..
<6>Dec 6 08:23:03 l2tp[9858]: <---12
<6>Dec 6 08:23:03 l2tp[9858]: c8 02 00 0c b5 ce 00 00 00 02 00 03 | ............
<6>Dec 6 08:23:03 l2tp[9858]: <---12
<6>Dec 6 08:23:03 l2tp[9858]: c8 02 00 0c b5 ce 39 e3 00 02 00 04 | ......9.....
<6>Dec 6 08:23:03 l2tp-ppp[9859]: Plugin pppol2tp.so loaded.
<6>Dec 6 08:23:03 l2tp-ppp[9859]: using channel 3
<6>Dec 6 08:23:03 l2tp-ppp[9859]: Using interface ppp1
<5>Dec 6 08:23:03 l2tp-ppp[9859]: Connect: ppp1 <--> (开始ppp拨号)
<6>Dec 6 08:23:03 l2tp-ppp[9859]: PPPoL2TP options: debugmask 0
<6>Dec 6 08:23:03 l2tp-ppp[9859]: 16--->
<6>Dec 6 08:23:03 l2tp-ppp[9859]: c0 21 01 01 00 0e 01 04 05 aa 05 06 b8 55 94 4d | .!...........U.M
<6>Dec 6 08:23:03 l2tp-ppp[9859]: <---18
<6>Dec 6 08:23:03 l2tp-ppp[9859]: ff 03 c0 21 02 01 00 0e 01 04 05 aa 05 06 b8 55 | ...!...........U
<6>Dec 6 08:23:03 l2tp-ppp[9859]: 94 4d | .M
<6>Dec 6 08:23:06 l2tp-ppp[9859]: 16--->
<6>Dec 6 08:23:06 l2tp-ppp[9859]: c0 21 01 01 00 0e 01 04 05 aa 05 06 b8 55 94 4d | .!...........U.M
<6>Dec 6 08:23:06 l2tp-ppp[9859]: <---33
<6>Dec 6 08:23:06 l2tp-ppp[9859]: ff 03 c0 21 01 01 00 1d 01 04 05 82 02 06 00 00 | ...!............
<6>Dec 6 08:23:06 l2tp-ppp[9859]: 00 00 03 05 c2 23 05 05 06 9c d7 01 36 07 02 08 | .....#......6...
<6>Dec 6 08:23:06 l2tp-ppp[9859]: 02 | .
<6>Dec 6 08:23:06 l2tp-ppp[9859]: 12--->
<6>Dec 6 08:23:06 l2tp-ppp[9859]: c0 21 04 01 00 0a 02 06 00 00 00 00 | .!..........
<6>Dec 6 08:23:06 l2tp-ppp[9859]: <---18
<6>Dec 6 08:23:06 l2tp-ppp[9859]: ff 03 c0 21 02 01 00 0e 01 04 05 aa 05 06 b8 55 | ...!...........U
<6>Dec 6 08:23:06 l2tp-ppp[9859]: 94 4d | .M
<6>Dec 6 08:23:06 l2tp-ppp[9859]: <---27
<6>Dec 6 08:23:06 l2tp-ppp[9859]: ff 03 c0 21 01 02 00 17 01 04 05 82 03 05 c2 23 | ...!...........#
<6>Dec 6 08:23:06 l2tp-ppp[9859]: 05 05 06 9c d7 01 36 07 02 08 02 | ......6....
<6>Dec 6 08:23:06 l2tp-ppp[9859]: 25--->
<6>Dec 6 08:23:06 l2tp-ppp[9859]: c0 21 02 02 00 17 01 04 05 82 03 05 c2 23 05 05 | .!...........#..
<6>Dec 6 08:23:06 l2tp-ppp[9859]: 06 9c d7 01 36 07 02 08 02 | ....6....
<6>Dec 6 08:23:06 l2tp-ppp[9859]: PPPoL2TP options: debugmask 0
<6>Dec 6 08:23:07 l2tp-ppp[9859]: <---43
<6>Dec 6 08:23:07 l2tp-ppp[9859]: ff 03 c2 23 01 2d 00 27 14 2e 9d 45 cf 4c 04 b2 | ...#.-.'...E.L..
<6>Dec 6 08:23:07 l2tp-ppp[9859]: ef 80 09 ca 76 4d f8 98 9e 16 91 14 da 4c 69 6e | ....vM.......Lin
<6>Dec 6 08:23:07 l2tp-ppp[9859]: 75 78 56 50 4e 73 65 72 76 65 72 | uxVPNserver
<6>Dec 6 08:23:07 l2tp-ppp[9859]: 27--->
<6>Dec 6 08:23:07 l2tp-ppp[9859]: c2 23 02 2d 00 19 10 e6 f0 07 65 c9 14 06 8d db | .#.-......e.....
<6>Dec 6 08:23:07 l2tp-ppp[9859]: 80 5c 16 da 85 a0 ee 74 65 73 74 | ......test
<6>Dec 6 08:23:07 l2tp-ppp[9859]: <---22
<6>Dec 6 08:23:07 l2tp-ppp[9859]: ff 03 c2 23 03 2d 00 12 41 63 63 65 73 73 20 67 | ...#.-..Access.g
<6>Dec 6 08:23:07 l2tp-ppp[9859]: 72 61 6e 74 65 64 | ranted
<6>Dec 6 08:23:07 l2tp-ppp[9859]: CHAP authentication succeeded: Access granted
<5>Dec 6 08:23:07 l2tp-ppp[9859]: CHAP authentication succeeded(CHAP认证通过)
<6>Dec 6 08:23:07 l2tp-ppp[9859]: 24--->
<6>Dec 6 08:23:07 l2tp-ppp[9859]: 80 21 01 01 00 16 03 06 c0 a8 01 80 81 06 00 00 | .!..............
<6>Dec 6 08:23:07 l2tp-ppp[9859]: 00 00 83 06 00 00 00 00 | ........
<6>Dec 6 08:23:07 l2tp-ppp[9859]: <---20
<6>Dec 6 08:23:07 l2tp-ppp[9859]: ff 03 80 21 01 01 00 10 02 06 00 2d 0f 01 03 06 | ...!.......-....
<6>Dec 6 08:23:07 l2tp-ppp[9859]: c0 a8 01 63 | ...c
<6>Dec 6 08:23:07 l2tp-ppp[9859]: 12--->
<6>Dec 6 08:23:07 l2tp-ppp[9859]: 80 21 04 01 00 0a 02 06 00 2d 0f 01 | .!.......-..
<6>Dec 6 08:23:07 l2tp-ppp[9859]: <---20
<6>Dec 6 08:23:07 l2tp-ppp[9859]: ff 03 80 21 03 01 00 10 81 06 08 08 08 08 83 06 | ...!............
<6>Dec 6 08:23:07 l2tp-ppp[9859]: 01 01 01 01 | ....
<6>Dec 6 08:23:07 l2tp-ppp[9859]: 24--->
<6>Dec 6 08:23:07 l2tp-ppp[9859]: 80 21 01 02 00 16 03 06 c0 a8 01 80 81 06 08 08 | .!..............
<6>Dec 6 08:23:07 l2tp-ppp[9859]: 08 08 83 06 01 01 01 01 | ........
<6>Dec 6 08:23:07 l2tp-ppp[9859]: <---14
<6>Dec 6 08:23:07 l2tp-ppp[9859]: ff 03 80 21 01 02 00 0a 03 06 c0 a8 01 63 | ...!.........c
<6>Dec 6 08:23:07 l2tp-ppp[9859]: 12--->
<6>Dec 6 08:23:07 l2tp-ppp[9859]: 80 21 02 02 00 0a 03 06 c0 a8 01 63 | .!.........c
<6>Dec 6 08:23:07 l2tp-ppp[9859]: <---26
<6>Dec 6 08:23:07 l2tp-ppp[9859]: ff 03 80 21 02 02 00 16 03 06 c0 a8 01 80 81 06 | ...!............
<6>Dec 6 08:23:07 l2tp-ppp[9859]: 08 08 08 08 83 06 01 01 01 01 | ..........
<5>Dec 6 08:23:07 l2tp-ppp[9859]: local IP address 192.168.1.128
<5>Dec 6 08:23:07 l2tp-ppp[9859]: remote IP address 192.168.1.99
<5>Dec 6 08:23:07 l2tp-ppp[9859]: primary DNS address 8.8.8.8
<5>Dec 6 08:23:07 l2tp-ppp[9859]: secondary DNS address 1.1.1.1(ppp拨号成功,获取本端及对端隧道IP,及服务器设置的dns)
<6>Dec 6 08:23:10 dial[2293]: Kpon:ppp0 114.114.114.114[114.114.114.114] success(s:3/5)
<6>Dec 6 08:24:03 l2tp[9858]: 20--->
<6>Dec 6 08:24:03 l2tp[9858]: c8 02 00 14 04 a2 00 00 00 04 00 02 80 08 00 00 | ................
<6>Dec 6 08:24:03 l2tp[9858]: 00 00 00 06 | ....
<6>Dec 6 08:24:03 l2tp[9858]: <---20
<6>Dec 6 08:24:03 l2tp[9858]: c8 02 00 14 b5 ce 00 00 00 02 00 04 80 08 00 00 | ................
<6>Dec 6 08:24:03 l2tp[9858]: 00 00 00 06 | ....
<6>Dec 6 08:24:03 l2tp[9858]: deal Hello(6). Tunnel is 1186, call is 0.(客户端发送Hello报文,服务器回复ZLB,维持隧道)
<6>Dec 6 08:24:03 l2tp[9858]: 12--->
<6>Dec 6 08:24:03 l2tp[9858]: c8 02 00 0c 04 a2 00 00 00 05 00 03 | ............
<6>Dec 6 08:24:03 l2tp[9858]: <---12
<6>Dec 6 08:24:03 l2tp[9858]: c8 02 00 0c b5 ce 00 00 00 03 00 05 | ............
<6>Dec 6 08:24:10 dial[2293]: Kpon:ppp0 114.114.114.114[114.114.114.114] success(s:3/5)
<6>Dec 6 08:25:04 l2tp[9858]: 20--->
<6>Dec 6 08:25:04 l2tp[9858]: c8 02 00 14 04 a2 00 00 00 05 00 03 80 08 00 00 | ................
<6>Dec 6 08:25:04 l2tp[9858]: 00 00 00 06 | ....
<6>Dec 6 08:25:04 l2tp[9858]: <---20
<6>Dec 6 08:25:04 l2tp[9858]: c8 02 00 14 b5 ce 00 00 00 03 00 05 80 08 00 00 | ................
<6>Dec 6 08:25:04 l2tp[9858]: 00 00 00 06 | ....