路由递归
路由必须有直连的下一跳才能够指导转发,但是路由生成时下一跳可能不是直连的,因此需要计算出一个直连的下一跳和对应的出接口,这个过程就叫做路由递归。路由递归也被称为路由迭代
路由器静态路由只配置下一跳的路由迭代问题
问题:静态路由没有配置只下一跳ip没有出接口,以太链路接口down之后路由迭代怎么迭代?
通过查询华为文档和实验确定华为路由器的规则如下:
下一跳所在接口down后,如果静态路由没有指定出接口,会对下一跳地址(Next-hop IP)进行路由迭代,也就是查找全局路由表(但不匹配默认路由迭代),看能否匹配到下一跳地址的路由,如果有则迭代成功,如果没有则迭代失败。
#如果网络中存在大段的互联地址段汇总路由,而业务静态路由只配置下一跳IP地址,当出接口down掉之后就存在静态路由迭代出错问题导致业务受损,这种情况下会迭代到受到汇总的互联地址段路由的接口上。
//
//
//
以下通过实验案例证明
拓扑图如下:
模拟环境使用ENSP,ENSP设备使用 NE5000E V800R011C00SPC607B607
实验过程如下
1、NE1 初始配置如下:
ip route-static 10.100.96.0 255.255.248.0 NULL0 preference 255 //说明:汇总黑洞路由用于BGP 中network使用,进行大段路由发布
ip route-static 192.168.0.0 255.255.248.0 NULL0 preference 255 //说明:汇总黑洞路由用于BGP 中network使用,进行大段路由发布
ip route-static 100.100.100.0 255.255.255.0 192.168.2.2
#
interface Ethernet1/0/2
undo shutdown
ip address 192.168.2.1 255.255.255.252
1.1、NE1的Ethernet1/0/2链路UP时路由情况如下:
通过查看路由表100.100.100.0/24的路由正常,因为Ethernet1/0/2是UP的,192.168.2.2 是直连路由。
[~NE1-]dis ip routing-table | exclude Direct
0.0.0.0/0 O_ASE 150 2 D 192.168.1.2 Ethernet1/0/0
10.100.96.0/21 Static 255 0 DB 0.0.0.0 NULL0
100.100.100.0/24 Static 60 0 RD 192.168.2.2 Ethernet1/0/2
112.19.100.0/24 O_ASE 150 1 D 192.168.1.2 Ethernet1/0/0
192.168.0.0/20 O_ASE 150 1 D 192.168.1.2 Ethernet1/0/0
192.168.0.0/21 Static 255 0 DB 0.0.0.0 NULL0
//
//
2、当NE1路由shutdown掉Ethernet1/0/2接口时,查看路由迭代。
由于100.100.100.0/24没有配置出接口,导致根据192.168.2.2 来查询路由匹配
192.168.0.0/21 Static 255 0 DB 0.0.0.0 NULL0,
迭代接口到NULL0。如下
100.100.100.0/24 Static 60 0 RDB 192.168.2.2 NULL0
造成NE1路由shutdown掉Ethernet1/0/2之后静态路由仍然生效但出接口不正确,IP不通,业务受到影响。
如下图
[~NE1]interface Ethernet1/0/2
[~NE1-Ethernet1/0/2]shutdown
[~NE1-Ethernet1/0/2]dis ip routing-table | exclude Direct
------------------------------------------------------------------------------
Destination/Mask Proto Pre Cost Flags NextHop Interface
0.0.0.0/0 O_ASE 150 2 D 192.168.1.2 Ethernet1/0/0
10.100.96.0/21 Static 255 0 DB 0.0.0.0 NULL0
100.100.100.0/24 Static 60 0 RDB 192.168.2.2 NULL0
112.19.100.0/24 O_ASE 150 1 D 192.168.1.2 Ethernet1/0/0
192.168.0.0/20 O_ASE 150 1 D 192.168.1.2 Ethernet1/0/0
192.168.0.0/21 Static 255 0 DB 0.0.0.0 NULL0
[~NE1-Ethernet1/0/2]
//
//
3、假设当NE1也未配置黑洞路由192.168.0.0/21时,查看路由迭代
由于100.100.100.0/24没有配置出接口,导致根据192.168.2.2 来查询路由匹配
192.168.0.0/20 O_ASE 150 1 D 192.168.1.2 Ethernet1/0/0
迭代接口到Ethernet1/0/0(与NE3的互联链路)。如下
100.100.100.0/24 Static 60 0 RD 192.168.2.2 Ethernet1/0/0
造成NE1路由shutdown掉Ethernet1/0/2之后静态路由仍然生效但出接口不正确,IP不通,业务受到影响。
如下图
[~NE1]undo ip route-static 192.168.0.0 255.255.248.0 NULL0
[~NE1]dis ip routing-table 192.168.2.2
Route Flags: R - relay, D - download to fib, T - to vpn-instance, B - black hole
route
------------------------------------------------------------------------------
Destination/Mask Proto Pre Cost Flags NextHop Interface
192.168.0.0/20 O_ASE 150 1 D 192.168.1.2 Ethernet1/0/0
以下查看当前路由表
[~NE1]dis ip routing-table | exclude Direct
----------------------------------------------------------------------------
Destination/Mask Proto Pre Cost Flags NextHop Interface
0.0.0.0/0 O_ASE 150 2 D 192.168.1.2 Ethernet1/0/0
10.100.96.0/21 Static 255 0 DB 0.0.0.0 NULL0
100.100.100.0/24 Static 60 0 RD 192.168.2.2 Ethernet1/0/0
112.19.100.0/24 O_ASE 150 1 D 192.168.1.2 Ethernet1/0/0
192.168.0.0/20 O_ASE 150 1 D 192.168.1.2 Ethernet1/0/0
[~NE1]undo ip route-static 192.168.0.0 255.255.248.0 NULL0
//
//
4、假设当NE1也未配置黑洞路由192.168.0.0/21,NE2也取消192.168.0.0/20 O_ASE的路由发布之后,192.168.2.2只匹配到默认路由,我们再看路由迭代。
由于100.100.100.0/24没有配置出接口,导致根据192.168.2.2 来查询路由匹配到默认路由
0.0.0.0/0 O_ASE 150 2 D 192.168.1.2 Ethernet1/0/0
或
0.0.0.0/0 Static 60 0 RD 192.168.1.2 Ethernet1/0/0
由于无法迭代到默认路由,出接口down掉之后100.100.100.0/24的静态路由配置不生效。业务正常。
如下图
[~NE1]dis ip routing-table 192.168.2.2
Route Flags: R - relay, D - download to fib, T - to vpn-instance, B - black hole
route
------------------------------------------------------------------------------
Routing Table : _public_
Summary Count : 1
Destination/Mask Proto Pre Cost Flags NextHop Interface
0.0.0.0/0 O_ASE 150 2 D 192.168.1.2 Ethernet1/0/0
[~NE1]dis ip routing-table | exclude Direct
------------------------------------------------------------------------------
Destination/Mask Proto Pre Cost Flags NextHop Interface
0.0.0.0/0 O_ASE 150 2 D 192.168.1.2 Ethernet1/0/0
10.100.96.0/21 Static 255 0 DB 0.0.0.0 NULL0
[~NE1]
[~NE1]dis ip routing-table | ex Direct
Destination/Mask Proto Pre Cost Flags NextHop Interface
0.0.0.0/0 Static 60 0 RD 192.168.1.2 Ethernet1/0/0
10.100.96.0/21 Static 255 0 DB 0.0.0.0 NULL0
[~NE1]