衡量路由的优先程度,到达同一个目标有两种路由协议,此时优选路由优先级较小的路由协议。
冗余:备份,可靠性较高
在网络中主路由失效的情况下,会加入到路由表中并承担数据转发业务。
IP地址:192.168.1.2
子网掩码:255.255.255.0
网关:192.168.1.1
IP地址:192.168.1.2
子网掩码:255.255.255.0
网关:192.168.1.1
IP地址:210.1.1.2
子网掩码:255.255.255.0
网关:210.1.1.1
system-view //进入全局配置模式
[Huawei]undo info-center enable //关闭信息告警提示
[Huawei]sysname R1 //改名
[R1]interface e0/0/0 //进入接口
[R1-Ethernet0/0/0]ip address 192.168.1.1 24 //设置IP地址
[R1-Ethernet0/0/0]quit //退出
[R1]interface e0/0/1 //进入接口
[R1-Ethernet0/0/1]ip address 12.1.1.1 24 //设置IP地址
[R1-Ethernet0/0/1]quit //退出
[R1]interface g0/0/0 //进入接口
[R1-GigabitEthernet0/0/0]ip address 23.1.1.1 24 //设置IP地址
[R1-GigabitEthernet0/0/0]quit 退出
[R1]
system-view //进入全局配置模式
[Huawei]undo info-center enable //关闭信息告警提示
[Huawei]sysname DX //改名
[DX]interface e0/0/1 //进入接口
[DX-Ethernet0/0/1]ip address 210.1.1.1 24 //设置IP地址
[DX-Ethernet0/0/1]quit 退出
[DX]interface e0/0/0 //进入接口
[DX-Ethernet0/0/0]ip address 12.1.1.2 24 //设置IP地址
[DX-Ethernet0/0/0]quit //退出
[DX]interface g0/0/0 //进入接口
[DX-GigabitEthernet0/0/0]ip address 23.1.1.2 24 //设置IP地址
[DX-GigabitEthernet0/0/0]quit 退出
[DX]
[R1]dis ip routing-table //查看路由表
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 8 Routes : 8
Destination/Mask Proto Pre Cost Flags NextHop Interface
12.1.1.0/24 Direct 0 0 D 12.1.1.1 Ethernet0/0/1
12.1.1.1/32 Direct 0 0 D 127.0.0.1 Ethernet0/0/1
23.1.1.0/24 Direct 0 0 D 23.1.1.1 GigabitEthernet
0/0/0
23.1.1.1/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/0
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.1 Ethernet0/0/0
192.168.1.1/32 Direct 0 0 D 127.0.0.1 Ethernet0/0/0
[R1]
[DX]dis ip routing-table //查看路由表
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 8 Routes : 8
Destination/Mask Proto Pre Cost Flags NextHop Interface
12.1.1.0/24 Direct 0 0 D 12.1.1.2 Ethernet0/0/0
12.1.1.2/32 Direct 0 0 D 127.0.0.1 Ethernet0/0/0
23.1.1.0/24 Direct 0 0 D 23.1.1.2 GigabitEthernet
0/0/0
23.1.1.2/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/0
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
210.1.1.0/24 Direct 0 0 D 210.1.1.1 Ethernet0/0/1
210.1.1.1/32 Direct 0 0 D 127.0.0.1 Ethernet0/0/1
[DX]
[R1]ip route-static 210.1.1.0 24 12.1.1.2 preference 70 //配置静态路由,设置优先级为70
[R1]ip route-static 210.1.1.0 24 23.1.1.2 //配置静态路由,默认优先级为60
[R1]dis ip routing-table 查看路由表
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 9 Routes : 9
Destination/Mask Proto Pre Cost Flags NextHop Interface
12.1.1.0/24 Direct 0 0 D 12.1.1.1 Ethernet0/0/1
12.1.1.1/32 Direct 0 0 D 127.0.0.1 Ethernet0/0/1
23.1.1.0/24 Direct 0 0 D 23.1.1.1 GigabitEthernet
0/0/0
23.1.1.1/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/0
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.1 Ethernet0/0/0
192.168.1.1/32 Direct 0 0 D 127.0.0.1 Ethernet0/0/0
210.1.1.0/24 Static 60 0 RD 23.1.1.2 GigabitEthernet //到达某相同目标网段路由表中始终放置最优路由
0/0/0
[R1]
[DX]ip route-static 192.168.1.0 24 12.1.1.1 preference 70 //配置静态路由,设置优先级为70
[DX]ip route-static 192.168.1.0 24 23.1.1.1 //配置静态路由,默认优先级为60
[DX]dis ip routing-table //查看路由表
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 9 Routes : 9
Destination/Mask Proto Pre Cost Flags NextHop Interface
12.1.1.0/24 Direct 0 0 D 12.1.1.2 Ethernet0/0/0
12.1.1.2/32 Direct 0 0 D 127.0.0.1 Ethernet0/0/0
23.1.1.0/24 Direct 0 0 D 23.1.1.2 GigabitEthernet
0/0/0
23.1.1.2/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/0
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 Static 60 0 RD 23.1.1.1 GigabitEthernet //到达某相同目标网段路由表中始终放置最优路由
0/0/0
210.1.1.0/24 Direct 0 0 D 210.1.1.1 Ethernet0/0/1
210.1.1.1/32 Direct 0 0 D 127.0.0.1 Ethernet0/0/1
[DX]
PC>ping 210.1.1.2 //测试是否可以ping通PC3
Ping 210.1.1.2: 32 data bytes, Press Ctrl_C to break
From 210.1.1.2: bytes=32 seq=1 ttl=126 time=125 ms //ping通
From 210.1.1.2: bytes=32 seq=2 ttl=126 time=63 ms
From 210.1.1.2: bytes=32 seq=3 ttl=126 time=93 ms
From 210.1.1.2: bytes=32 seq=4 ttl=126 time=78 ms
From 210.1.1.2: bytes=32 seq=5 ttl=126 time=94 ms
--- 210.1.1.2 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 63/90/125 ms
PC>
PC>ping 210.1.1.2 //测试是否可以ping通PC3
Ping 210.1.1.2: 32 data bytes, Press Ctrl_C to break
From 210.1.1.2: bytes=32 seq=1 ttl=126 time=78 ms //ping通
From 210.1.1.2: bytes=32 seq=2 ttl=126 time=78 ms
From 210.1.1.2: bytes=32 seq=3 ttl=126 time=46 ms
From 210.1.1.2: bytes=32 seq=4 ttl=126 time=93 ms
From 210.1.1.2: bytes=32 seq=5 ttl=126 time=109 ms
--- 210.1.1.2 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 46/80/109 ms
PC>
[R1]interface g0/0/0 //关闭g0/0/0接口
[R1-GigabitEthernet0/0/0]shutdown
[R1-GigabitEthernet0/0/0]quit
[R1]
[R1]dis ip routing-table //查看路由表
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 7 Routes : 7
Destination/Mask Proto Pre Cost Flags NextHop Interface
12.1.1.0/24 Direct 0 0 D 12.1.1.1 Ethernet0/0/1
12.1.1.1/32 Direct 0 0 D 127.0.0.1 Ethernet0/0/1
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.1 Ethernet0/0/0
192.168.1.1/32 Direct 0 0 D 127.0.0.1 Ethernet0/0/0
210.1.1.0/24 Static 70 0 RD 12.1.1.2 Ethernet0/0/1 //shutdwonG0/0/0接口,这条路由会显示在路由表中
[R1]
[DX]dis ip routing-table //查看路由表
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 7 Routes : 7
Destination/Mask Proto Pre Cost Flags NextHop Interface
12.1.1.0/24 Direct 0 0 D 12.1.1.2 Ethernet0/0/0
12.1.1.2/32 Direct 0 0 D 127.0.0.1 Ethernet0/0/0
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 Static 70 0 RD 12.1.1.1 Ethernet0/0/0 //shutdwonG0/0/0接口,这条路由会显示在路由表中
210.1.1.0/24 Direct 0 0 D 210.1.1.1 Ethernet0/0/1
210.1.1.1/32 Direct 0 0 D 127.0.0.1 Ethernet0/0/1
[DX]
PC>ping 192.168.1.2 //测试是否可以ping通PC1
Ping 192.168.1.2: 32 data bytes, Press Ctrl_C to break
Request timeout!
From 192.168.1.2: bytes=32 seq=2 ttl=126 time=94 ms //ping通
From 192.168.1.2: bytes=32 seq=3 ttl=126 time=78 ms
From 192.168.1.2: bytes=32 seq=4 ttl=126 time=110 ms
From 192.168.1.2: bytes=32 seq=5 ttl=126 time=62 ms
--- 192.168.1.2 ping statistics ---
5 packet(s) transmitted
4 packet(s) received
20.00% packet loss
round-trip min/avg/max = 0/86/110 ms
PC>ping 192.168.1.3 //测试是否可以ping通PC2
Ping 192.168.1.3: 32 data bytes, Press Ctrl_C to break
Request timeout!
From 192.168.1.3: bytes=32 seq=2 ttl=126 time=94 ms //ping通
From 192.168.1.3: bytes=32 seq=3 ttl=126 time=94 ms
From 192.168.1.3: bytes=32 seq=4 ttl=126 time=110 ms
From 192.168.1.3: bytes=32 seq=5 ttl=126 time=94 ms
--- 192.168.1.3 ping statistics ---
5 packet(s) transmitted
4 packet(s) received
20.00% packet loss
round-trip min/avg/max = 0/98/110 ms
PC>