配置GRE支持Keepalive特性
应用环境
GRE协议并不具备探测链路状态的功能。如果远端端口不可达,隧道并不能及时关闭该Tunnel连接,这样会造成源端会不断的向对端转发数据,而对端却因Tunnel不通而丢弃所有报文,由此会形成数据发送的空洞。
GRE Keepalive功能可以使Tunnel检测隧道状态。如果对端不可达,隧道连接就会及时关闭,避免形成数据空洞。
配置思路
使本端的GRE具有Keepalive特性,只需在本端路由器的隧道接口视图下键入link-alive命令。
配置注意事项
源端实现Linkalive功能并不要求对端也具备link-alive功能,对端只需实现转发功能。
组网需求
如下图所示,Router A和RouterB端配置了GRE隧道协议,要求GRE隧道的RouterA端具备Keepalive功能。
Link-alive基本功能组网图
适用产品和版本
路由器可以使用任意一款NE产品。版本为VRP5.30及后续版本。
配置步骤
步骤 1 实现RouterA与RouterB的互通
具体配过程略。
步骤 2 在Router A上配置隧道,使能Linkalive
<RouterA> system-view [RouterA] interface tunnel 1/0/0 [RouterA-Tunnel1/0/0] ip address 12.12.12.1 255.255.255.0 [RouterA-Tunnel1/0/0] source 172.16.1.1 [RouterA-Tunnel1/0/0] destination 172.16.1.2 [RouterA-Tunnel1/0/0] link-alive period 20 retry-times 3 [RouterA-Tunnel1/0/0] quit
步骤 3 在Router B上配置隧道
<RouterB> system-view [RouterB] interface tunnel 1/0/0 [RouterB-Tunnel1/0/0] ip address 12.12.12.2 255.255.255.0 [RouterB-Tunnel1/0/0] source 172.16.1.2 [RouterB-Tunnel1/0/0] destination 172.16.1.1
步骤 4 验证配置结果
从Router A上的Tunnel接口应该能ping通Router B的Tunnel接口。
[RouterA-Tunnel1/0/0] ping -a 12.12.12.1 12.12.12.2
PING 12.12.12.2: 56 data bytes, press CTRL_C to break
Reply from 12.12.12.2: bytes=56 Sequence=1 ttl=255 time=187 ms
Reply from 12.12.12.2: bytes=56 Sequence=2 ttl=255 time=93 ms
Reply from 12.12.12.2: bytes=56 Sequence=3 ttl=255 time=125 ms
Reply from 12.12.12.2: bytes=56 Sequence=4 ttl=255 time=94 ms
Reply from 12.12.12.2: bytes=56 Sequence=5 ttl=255 time=94 ms
--- 12.12.12.2 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 93/118/187 ms
# 打开Router A的调试开关查看Link-alive报文的消息。
[RouterA-Tunnel1/0/0] quit [RouterA] quit <RouterA> terminal moniter <RouterA> terminal debugging <RouterA> debugging tunnel *0.251227568 RouterA TUNNEL/8/ATKDBG:Starting linkalive timer successfully! ID: 748 *0.251227664 RouterA TUNNEL/8/ATKDBG:Tunnel-ctl: check Tunnel1/0/0 state. *0.251227744 RouterA TUNNEL/8/ATKDBG:Tunnel-ctl: check Tunnel1/0/0 state is 0, no change, return. *0.251232481 RouterA TUNNEL/8/ATKDBG:Preparing linkalive frame successfully *0.251232560 RouterA TUNNEL/8/ATKDBG:Tunnel1/0/0-Out: Mbuf length = 24 from GRE Tunnel out *0.251232656 RouterA TUNNEL/8/ATKDBG:Tunnel1/0/0-Out: GRE/IP encapsulated 172.16.1.1->172.16.1.2(len = 48). *0.251232785 RouterA TUNNEL/8/ATKDBG: Judge keepalive finished. Keepalive response packet from orginal router. *0.251232912 RouterA TUNNEL/8/ATKDBG: Receive the keepalive response on mainboard successfully.Finish. *0.251233024 RouterA TUNNEL/8/ATKDBG:Slot=1;Tunnel-In: Get packet,the tunnel is src(172.16.1.2)/dest(172.16.1.1),length = 24 . *0.251233168 RouterA TUNNEL/8/ATKDBG:Slot=1; Judge keepalive finished. Keepalive response packet from orginal router. *0.251233296 RouterA TUNNEL/8/ATKDBG:Slot=1; IO board received keepalive packet, resend to mainboard. *0.251233408 RouterA TUNNEL/8/ATKDBG:Tunnel-ctl: check Tunnel1/0/0 state. *0.251233488 RouterA TUNNEL/8/ATKDBG:Tunnel-ctl: check Tunnel1/0/0 state is 0, no change, return. *0.251234995 RouterA TUNNEL/8/ATKDBG: Judge keepalive finished. Keepalive packet from peer router. *0.251235104 RouterA TUNNEL/8/ATKDBG: Receive peer keepalive on mainboard successfully. Put into decapsulation *0.251235232 RouterA TUNNEL/8/ATKDBG:Tunnel1/0/0-In: GRE decapsulated IP 172.16.1.1->172.16.1.2(len = 24). *0.251235360 RouterA TUNNEL/8/ATKDBG:Slot=1;Tunnel-In: Get packet,the tunnel is src(172.16.1.2)/dest(172.16.1.1),length = 48 . *0.251235504 RouterA TUNNEL/8/ATKDBG:Slot=1;





