路由:
实验步骤:
第一步:IP地址规划
简单划分一下:
R1-R2:12.1.1.0 /24
R2-R3: 23.1.1.0 /24
R3-R4: 34.1.1.0 /24
R1-R4: 14.1.1.0 /24
R1环回:1.1.1.1/24
R2环回:2.2.2.2/24
R3环回:3.3.3.3/24
R4环回:4.4.4.4/24
第二步:配置IP地址
R1:
[R1]int g0/0/0
[R1-GigabitEthernet0/0/0]ip add 12.1.1.1 24
[R1]int g0/0/1
[R1-GigabitEthernet0/0/1]ip add 14.1.1.1 24
[R1]int lo 0
[R1-LoopBack0]ip add 1.1.1.1 24
R2:
[R2]int g0/0/0
[R2-GigabitEthernet0/0/0]ip add 12.1.1.2 24
[R2]int g0/0/1
[R2-GigabitEthernet0/0/1]ip add 23.1.1.2 24
[R2]int LoopBack 0
[R2-LoopBack0]ip add 2.2.2.2 24
R3:
[R3]int g0/0/0
[R3-GigabitEthernet0/0/0]ip add 23.1.1.3 24
[R3]int g0/0/1
[R3-GigabitEthernet0/0/1]ip add 34.1.1.3 24
[R3]int LoopBack 0
[R3-LoopBack0]ip add 3.3.3.3 24
R4:
[R4]int g0/0/0
[R4-GigabitEthernet0/0/0]ip add 34.1.1.4 24q
[R4]int g0/0/1
[R4-GigabitEthernet0/0/1]ip add 14.1.1.4 24
[R4]int LoopBack 0
[R4-LoopBack0]ip add 4.4.4.4 24
第三步:RIP和OSPF配置
RIP:
R1:
[R1]rip 1
[R1-rip-1]version 2
[R1-rip-1]network 12.0.0.0
[R1-rip-1]network 14.0.0.0
[R1-rip-1]network 1.0.0.0
R2:
[R2]rip 1
[R2-rip-1]version 2
[R2-rip-1]network 12.0.0.0
[R2-rip-1]network 2.0.0.0
R4:
[R4]rip 1
[R4-rip-1]version 2
[R4-rip-1]network 14.0.0.0
OSPF:
R2:
[R2]ospf 1 router-id 2.2.2.2
[R2-ospf-1]area 0
[R2-ospf-1-area-0.0.0.0]network 23.1.1.0 0.0.0.255
R3:
[R3]ospf 1 router-id 3.3.3.3
[R3-ospf-1]area 0
[R3-ospf-1-area-0.0.0.0]network 23.1.1.0 0.0.0.255
[R3-ospf-1-area-0.0.0.0]network 34.1.1.0 0.0.0.255
[R3-ospf-1-area-0.0.0.0]network 3.3.3.0 0.0.0.255
R4:
[R4]ospf 1 rou
[R4]ospf 1 router-id 4.4.4.4
[R4-ospf-1]area 0
[R4-ospf-1-area-0.0.0.0]network 34.1.1.0 0.0.0.255
[R4-ospf-1-area-0.0.0.0]network 4.4.4.0 0.0.0.255
第四步:双点双向重发布
在R2和R4上配置:
R2:
[R2]rip 1
[R2-rip-1]import-route ospf 1
[R2]ospf 1
[R2-ospf-1]import-route rip 1
R4:
[R4]rip 1
[R4-rip-1]import-route ospf 1
[R4]ospf 1
[R4-ospf-1]import-route rip 1
看下R1上rip路由表:
可以看见在R1上两个32位的路由,在R3和R4上修改接口类型可以解决
[R3]int LoopBack 0
[R3-LoopBack0]ospf network-type broadcast
[R4]int LoopBack 0
[R4-LoopBack0]ospf network-type broadcast
第五步:路由策略
检查R1:
消去R1上4.4.4.4/24 的负载均衡,在R2上配置使去往R1的cost值加大
[R2]ip ip-prefix a permit 4.4.4.4 24
[R2]route-policy a permit node 10
[R2-route-policy]if-match ip-prefix a
[R2-route-policy]apply cost + 10
[R2]route-policy a permit node 20
[R2]rip 1
[R2-rip-1]import-route ospf 1 route-policy a
消去R1上23.1.1.0/24 的负载均衡,在R4上配置使去往R1的cost值加大
[R4]ip ip-prefix b permit 23.1.1.0 24
[R4]route-policy b permit node 10
[R4-route-policy]if-match ip-prefix b
[R4-route-policy]apply cost + 10
[R4]route-policy b permit node 20
[R4]rip 1
[R4-rip-1]import-route ospf 1 route-policy b
消去R1上34.1.1.0/24 的负载均衡,在R2上配置使去往R1的cost值加大
[R2]ip ip-prefix c permit 34.1.1.0 24
[R2]route-policy a permit node 15
[R2-route-policy]if-match ip-prefix c
[R2-route-policy]apply cost + 10
[R2]rip 1
[R2-rip-1]import-route ospf 1 route-policy a
检查此时R1:
已经消除了R1的负载均衡
检查R3:
消除R3上2.2.2.0/24的负载均衡,在R4上配置使去往R3的cost值加大
[R4]ip ip-prefix a permit 2.2.2.0 24
[R4]route-policy a permit node 10
[R4-route-policy]if-match ip-prefix a
[R4-route-policy]apply cost + 10
[R4]route-policy a permit node 20
[R4]ospf 1
[R4-ospf-1]import-route rip 1 route-policy a
消除R3上12.1.1.0/24的负载均衡,在R4上配置使去往R3的cost值加大
[R4]ip ip-prefix c permit 12.1.1.0 24
[R4]route-policy a permit node 15
[R4-route-policy]if-match ip-prefix c
[R4-route-policy]apply cost + 10
[R4]ospf 1
[R4-ospf-1]import-route rip 1 route-policy a
消除R3上14.1.1.0/24的负载均衡,在R2上配置使去往R3的cost值加大
[R2]ip ip-prefix b permit 14.1.1.0 24
[R2]route-policy b permit node 10
[R2-route-policy]if-match ip-prefix b
[R2-route-policy]apply cost + 10
[R2]route-policy b permit node 20
[R2]ospf 1
[R2-ospf-1]import-route rip 1 route-policy b
检查现在的R3:
已消除R3的负载均衡。