目录
实验要求
建立如图所示拓扑:
满足下列所有条件:
- 除R5的环回地址固定外,整个其他所有的网段基于192.168.1.0/24进行合理的IP地址划分。
- R1-R4每天路由器存在两个环回接口,用于模拟链接PC的网段,地址也在192.168.1.0/24这个网络范围内。
- R1-R4上不能直接编写到达5.5.5.0/24的静态路由,但依然可以访问。
- 全网可达,尽量减少每台路由器,路由器条目的数量,避免环路出现。
- R4与R5之间,正常1000m链路通信,故障时自动改为100m。
实验过程
一、配置IP地址和环回地址
第一步:网段划分
如图所示:
第二步:配置各接口的IP地址
R1
[Huawei]interface g0/0/0
[Huawei-GigabitEthernet0/0/0]ip address 192.168.1.1 30
[Huawei-GigabitEthernet0/0/0]interface g0/0/1
[Huawei-GigabitEthernet0/0/1]ip address 192.168.1.5 30
R2
[Huawei]interface g0/0/0
[Huawei-GigabitEthernet0/0/0]ip address 192.168.1.2 30
[Huawei-GigabitEthernet0/0/0]interface g0/0/1
[Huawei-GigabitEthernet0/0/1]ip address 192.168.1.9 30
R3
[Huawei]interface g0/0/0
[Huawei-GigabitEthernet0/0/0]ip address 192.168.1.6 30
[Huawei-GigabitEthernet0/0/0]interface g0/0/1
[Huawei-GigabitEthernet0/0/1]ip address 192.168.1.13 30
R4
[Huawei]interface g0/0/0
[Huawei-GigabitEthernet0/0/0]ip address 192.168.1.10 30
[Huawei-GigabitEthernet0/0/0]interface g0/0/1
[Huawei-GigabitEthernet0/0/1]ip address 192.168.1.17 30
[Huawei-GigabitEthernet0/0/1]interface g0/0/2
[Huawei-GigabitEthernet0/0/2]ip address 192.168.1.14 30
[Huawei-GigabitEthernet0/0/2]interface g0/0/3
[Huawei-GigabitEthernet0/0/3]ip address 192.168.1.21 30
R5
[Huawei]interface g0/0/0
[Huawei-GigabitEthernet0/0/0]ip address 192.168.1.18 30
[Huawei-GigabitEthernet0/0/0]interface g0/0/1
[Huawei-GigabitEthernet0/0/1]ip address 192.168.1.22 30
第三步:配置环回地址
R1
[Huawei]int LoopBack 0
[Huawei-LoopBack0]ip address 192.168.1.33 28
[Huawei-LoopBack0]q
[Huawei]int LoopBack 1
[Huawei-LoopBack1]ip address 192.168.1.49 28
R2
[Huawei]int LoopBack 0
[Huawei-LoopBack0]ip address 192.168.1.65 28
[Huawei-LoopBack0]q
[Huawei]int LoopBack 1
[Huawei-LoopBack1]ip address 192.168.1.81 28
R3
[Huawei]int LoopBack 0
[Huawei-LoopBack0]ip address 192.168.1.97 28
[Huawei-LoopBack0]q
[Huawei]int LoopBack 1
[Huawei-LoopBack1]ip address 192.168.1.113 28
R4
[Huawei]int LoopBack 0
[Huawei-LoopBack0]ip address 192.168.1.129 28
[Huawei-LoopBack0]q
[Huawei]int LoopBack 1
[Huawei-LoopBack1]ip address 192.168.1.145 28
R5
[Huawei]int LoopBack 0
[Huawei-LoopBack0]ip address 5.5.5.5 24
配置完成后检查是否配置成功
R1
R2
R3
R4
R5
二、完成条件三:R1-R4上不能直接编写到达5.5.5.0/24的静态路由,但依然可以访问。
满足该条件需要用到缺省路由: 一种特殊的静态路由,当路由器在查看完本地所有的直连、静态和动态路由后仍然没有可达路径时才使用该路由。
[RX]ip route-static 0.0.0.0 0 192.168.X.X(下一跳)
R1
[Huawei]ip route-static 0.0.0.0 0 192.168.1.2
[Huawei]ip route-static 0.0.0.0 0 192.168.1.6
R2
[Huawei]ip route-static 0.0.0.0 0 192.168.1.10
R3
[Huawei]ip route-static 0.0.0.0 0 192.168.1.14
R4
[Huawei]ip route-static 0.0.0.0 0 192.168.1.18
三、满足条件四,实现全网可达并且避免环路问题
实现全网可达,需对每一个路由器配置静态路由
R1配置静态路由
[Huawei]ip route-static 192.168.1.64 27 192.168.1.2
[Huawei]ip route-static 192.168.1.96 27 192.168.1.6
[Huawei]ip route-static 192.168.1.8 30 192.168.1.2
[Huawei]ip route-static 192.168.1.12 30 192.168.1.6
[Huawei]ip route-static 192.168.1.128 27 192.168.1.2
[Huawei]ip route-static 192.168.1.128 27 192.168.1.6
[Huawei]ip route-static 192.168.1.16 30 192.168.1.6
[Huawei]ip route-static 192.168.1.16 30 192.168.1.2
R2配置静态路由
[Huawei]ip route-static 192.168.1.32 27 192.168.1.5
[Huawei]ip route-static 192.168.1.0 30 192.168.1.5
[Huawei]ip route-static 192.168.1.64 27 192.168.1.5
[Huawei]ip route-static 192.168.1.64 27 192.168.1.14
[Huawei]ip route-static 192.168.1.16 30 192.168.1.10
[Huawei]ip route-static 192.168.1.128 27 192.168.1.10
[Huawei]ip route-static 192.168.1.12 30 192.168.1.10
[Huawei]ip route-static 192.168.1.96 27 192.168.1.10
[Huawei]ip route-static 192.168.1.96 27 192.168.1.1
[Huawei]ip route-static 192.168.1.4 30 192.168.1.1
[Huawei]ip route-static 192.168.1.32 27 192.168.1.1
R3配置静态路由
[Huawei]ip route-static 192.168.1.32 27 192.168.1.5
[Huawei]ip route-static 192.168.1.0 30 192.168.1.5
[Huawei]ip route-static 192.168.1.64 27 192.168.1.5
[Huawei]ip route-static 192.168.1.64 27 192.168.1.14
[Huawei]ip route-static 192.168.1.8 30 192.168.1.14
[Huawei]ip route-static 192.168.1.128 27 192.168.1.14
[Huawei]ip route-static 192.168.1.16 30 192.168.1.14
R4配置静态路由
[Huawei]ip route-static 192.168.1.96 27 192.168.1.13
[Huawei]ip route-static 192.168.1.4 30 192.168.1.13
[Huawei]ip route-static 192.168.1.32 27 192.168.1.13
[Huawei]ip route-static 192.168.1.32 27 192.168.1.9
[Huawei]ip route-static 192.168.1.0 30 192.168.1.9
[Huawei]ip route-static 192.168.1.64 27 192.168.1.9
R1配置静态路由
[Huawei]ip route-static 192.168.1.32 27 192.168.1.17
[Huawei]ip route-static 192.168.1.64 27 192.168.1.17
[Huawei]ip route-static 192.168.1.96 27 192.168.1.17
[Huawei]ip route-static 192.168.1.128 27 192.168.1.17
[Huawei]ip route-static 192.168.1.0 30 192.168.1.17
[Huawei]ip route-static 192.168.1.4 30 192.168.1.17
[Huawei]ip route-static 192.168.1.8 30 192.168.1.17
[Huawei]ip route-static 192.168.1.12 30 192.168.1.17
避免环路问题
在黑洞路由器上配置一个通往汇总网段的空接口路由(避免路由黑洞与缺省路由相遇,否则必将出现环路)
R1
[Huawei]ip route-static 192.168.1.32 27 null 0
R2
[Huawei]ip route-static 192.168.1.64 27 null 0
R3
[Huawei]ip route-static 192.168.1.96 27 null 0
R4
[Huawei]ip route-static 192.168.1.128 27 null 0
检查配置是否成功
R1
R2
R3
R4
四、满足条件五:R4与R5之间,正常1000m链路通信,故障时自动改为100m
思路: 浮动静态路由-------当主链路出现故障时,能够根据浮动静态来实现备链路的切换。(先比较优先级,小的加表,大的不要;若优先级相同,同时加表;在静态路由中通过修改路由的优先级,可以实现备份路由的作用)
[RX]ip route-static 2.2.2.0 24 21.1.1.2 preference 61
配置R4缺省路由的优先级
ip route-static 0.0.0.0 0 192.168.1.22 preference 61
配置R5向R4的通信备份
[Huawei]ip route-static 192.168.1.0 255.255.255.255 192.168.1.21 preference 61
[Huawei]ip route-static 192.168.1.4 255.255.255.255 192.168.1.21 preference 61
[Huawei]ip route-static 192.168.1.8 255.255.255.255 192.168.1.24 preference 61
[Huawei]ip route-static 192.168.1.12 255.255.255.255 192.168.1.21 preference 61
[Huawei]ip route-static 192.168.1.32 255.255.255.255 192.168.1.21 preference 61
[Huawei]ip route-static 192.168.1.64 255.255.255.255 192.168.1.24 preference 61
[Huawei]p route-static 192.168.1.96 255.255.255.255 192.168.1.21 preference 61
[Huawei]p route-static 192.168.1.128 255.255.255.255 192.168.1.21 preference 61
查看R5的浮动静态路由:
挂掉0/0/3接口,再ping5.5.5.5查看是否成功
[Huawei]interface g0/0/3
[Huawei-GigabitEthernet0/0/3]shutdown
检测是否成功
R4查看路由的转发
最后R5查看或有路由有没有变成优先低级的路由