2.Static route 静态路由与最长匹配
R1
int E0/0/0
ip add 192.168.1.1 255.255.255.0
R2
int E0/0/0
ip add 192.168.1.2 24
ip route-s 192.168.1.1 255.255.255.0 NULL0 //Null 0为逻辑接口,数据包到达此接口即丢弃。
[R2]dis cur | in route
ospf 10 router-id 2.2.2.2
ip route-static 192.168.1.1 255.255.255.255 NULL0
[R2] dis ip rou
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 6 Routes : 6
Destination/Mask Proto Pre Cost Flags NextHop Interface
2.2.2.2/32 Direct 0 0 D 127.0.0.1 LoopBack0
127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0
127.0.0.1/32 Direct 0 0 D 127.0.0.1 InLoopBack0
192.168.1.0/24 Direct 0 0 D 192.168.1.2 Ethernet0/0/0
192.168.1.1/32 Static 60 0 D 0.0.0.0 NULL0
192.168.1.2/32 Direct 0 0 D 127.0.0.1 Ethernet0/0/0
路由选路时,会遵循最长匹配原则,此静态路由为32位为最长匹配。导致数据包被发送到Null0接口,进而丢弃。
[R2]ping 192.168.1.1
PING 192.168.1.1: 56 data bytes, press CTRL_C to break
Request time out
Request time out
Request time out
Request time out
Request time out
--- 192.168.1.1 ping statistics ---
5 packet(s) transmitted
0 packet(s) received
100.00% packet loss
百分之百丢包率,无法ping通。
【RS】关于路由器ping不通直连的几种原因(2)