路由存在但 RPF 检查失败
路由存在但 RPF 检查失败
Debug Flow 输出 reverse path check fail, drop 时,最常见的原因是入接口没有到源地址的路由,补充回程路由即可解决,参考故障排查 → Debug Flow 工具 → Debug Flow 排错举例。
但在等价路由(ECMP)场景下还有一种容易误判的情况:路由表中明明存在经入接口到源地址的路由,报文仍然被反向路径检查丢弃。这是因为反向路径检查以内核路由表为准,路由可能因超出 ecmp-max-paths 限制而没有写入内核。
RPF 机制的详细说明可参考路由 → 路由介绍。
问题现象
使用 Debug Flow 抓取被丢弃的流量。
diagnose debug reset diagnose debug flow filter addr 192.168.200.1 diagnose debug flow show function-name enable diagnose debug flow trace start 99 diagnose debug enable提示
查看完成后,使用
diagnose debug disable关闭 debug 输出。Debug Flow 显示从
VPN_4接口收到的报文因反向路径检查失败被丢弃。trace_id=2 func=print_pkt_detail line=5920 msg="vd-root:0 received a packet(proto=6, 192.168.200.1:60896->10.10.10.1:443) tun_id=10.100.1.1 from VPN_4. flag [S], seq 485006843, ack 0, win 65535" trace_id=2 func=init_ip_session_common line=6110 msg="allocate a new session-0015ab87" trace_id=2 func=iprope_dnat_check line=5480 msg="in-[VPN_4], out-[]" trace_id=2 func=iprope_dnat_tree_check line=824 msg="len=0" trace_id=2 func=iprope_dnat_check line=5505 msg="result: skb_flags-02000008, vid-0, ret-no-match, act-accept, flag-00000000" trace_id=2 func=ip_route_input_slow line=1695 msg="reverse path check fail, drop"查询到源地址 192.168.200.1 的路由,路由表中存在 4 条等价路径,其中包含入接口
VPN_4,但 FortiGate 仍然丢弃该报文。FGT # get router info routing-table details 192.168.200.1 Routing table for VRF=0 Routing entry for 192.168.200.0/24 Known via "static", distance 10, metric 0, best * directly connected, VPN_1 * directly connected, VPN_2 * directly connected, VPN_3 * directly connected, VPN_4
原因分析
检查路由是否真正写入内核路由表,以下两条命令均可查看。
get router info kernel diagnose ip route list内核路由表中 192.168.200.0/24 只有 3 条路径,缺少经入接口
VPN_4的路由。FGT # get router info kernel tab=254 vf=0 scope=0 type=1 proto=11 prio=1 0.0.0.0/0.0.0.0/0->192.168.200.0/24 pref=0.0.0.0 gwy=0.0.0.0 flag=00 hops=0 oif=80(VPN_1) gwy=0.0.0.0 flag=00 hops=0 oif=94(VPN_2) gwy=0.0.0.0 flag=00 hops=0 oif=77(VPN_3)检查 ECMP 配置,发现
ecmp-max-paths被设置为 3,内核最多只安装 3 条等价路径,第 4 条路由不会写入内核路由表。FGT # config system settings FGT (settings) # get | grep ecmp v4-ecmp-mode : source-ip-based ecmp-max-paths : 3
反向路径检查基于内核路由表:路由表中虽然显示 4 条等价路径,但内核只安装了前 3 条,从 VPN_4 收到的报文查不到反向路由,因此被丢弃。
解决方法
将
ecmp-max-paths调整为不小于实际等价路径数量的值。config system settings set ecmp-max-paths 4 end再次执行
get router info kernel,确认经VPN_4的路由已写入内核路由表,流量恢复正常。
重要
ecmp-max-paths 的默认值和最大值均为 255,这是设计限制。当等价路由超过 255 条时,第 256 条及之后的路由同样不会写入内核路由表,仍会出现“路由表有路由、Debug Flow 却报 RPF 丢包”的现象。
提示
如果回程路由通过 BGP 学习,还应检查源地址在路由表中是否命中黑洞路由。发现黑洞路由时,可使用 execute router restart 重启路由进程,使 BGP 路由重新生效。该命令会触发全部动态路由重新收敛,建议在维护窗口执行。