配ip
[r1]int g0/0/0
[r1-GigabitEthernet0/0/0]ip address 12.1.1.1 24
[r1-GigabitEthernet0/0/0]int g0/0/1
[r1-GigabitEthernet0/0/1]ip address 14.1.1.1 24
[r1]int LoopBack 0
[r1-LoopBack0]ip address 172.168.1.1 32
[r1]int LoopBack 1
[r1-LoopBack1]ip address 172.16.1.1 32
[r1]int LoopBack 2
[r1-LoopBack2]ip address 172.16.2.1 32
[r1]int LoopBack 3
[r1-LoopBack3]ip address 172.16.3.1 32
[r1]int LoopBack 4
[r1-LoopBack4]ip address 172.16.4.1 32
[r2]int LoopBack 0
[r2-LoopBack0]ip address 172.168.2.1 32
[r2]int g0/0/0
[r2-GigabitEthernet0/0/0]ip address 12.1.1.2 24
[r2-GigabitEthernet0/0/0]int g0/0/1
[r2-GigabitEthernet0/0/1]ip address 23.1.1.2 24
[r3]int g0/0/0
[r3-GigabitEthernet0/0/0]ip address 23.1.1.3 24
[r3-GigabitEthernet0/0/0]int g0/0/1
[r3-GigabitEthernet0/0/1]ip address 34.1.1.3 24
[r3]int LoopBack 0
[r3-LoopBack0]ip address 172.168.3.1 32
[r4]int g0/0/0
[r4-GigabitEthernet0/0/0]ip address 34.1.1.4 24
[r4-GigabitEthernet0/0/0]int g0/0/1
[r4-GigabitEthernet0/0/1]ip address 14.1.1.4 24
[r4]int LoopBack 0
[r4-LoopBack0]ip address 172.168.4.1 32
起rip ospf
[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 172.168.0.0
[r1-rip-1]network 172.16.0.0
[r2]rip 1
[r2-rip-1]version 2
[r2-rip-1]network 12.0.0.0
[r2-rip-1]network 172.168.0.0
[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.2 0.0.0.0
[r3]ospf 1 router-id 3.3.3.3
[r3-ospf-1]area 0
[r3-ospf-1-area-0.0.0.0]network 172.168.3.0 0.0.0.255
[r3-ospf-1-area-0.0.0.0]network 23.1.1.3 0.0.0.0
[r3-ospf-1-area-0.0.0.0]network 34.1.1.3 0.0.0.0
[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.4 0.0.0.0
[r4-ospf-1-area-0.0.0.0]network 172.168.4.0 0.0.0.255
[r4]rip 1
[r4-rip-1]version 2
[r4-rip-1]network 14.0.0.0
多点双向重发布
[r2]rip 1
[r2-rip-1]import-route ospf 1
[r2]ospf 1
[r2-ospf-1]import-route rip
[r4]rip
[r4-rip-1]import-route ospf 1
[r4]ospf 1
[r4-ospf-1]import-route rip
使用路由策略解决负载均衡和选路不佳
[r2]ip ip-prefix a permit 172.168.4.1 32
[r2]route-policy a permit node 10
[r2-route-policy]if-match ip-prefix a
[r2-route-policy]apply cost 5
[r4]ip ip-prefix b permit 172.168.2.1 32
[r4]route-policy a permit node 20
[r4-route-policy]if-match ip-prefix b
[r4-route-policy]apply cost 5
[r2-ospf-1]import-route rip 1 route-policy a
[r4-ospf-1]import-route rip 1 route-policy b
检测
查看路由表
r1环回
172.16.1.0/32 deny
172.16.2.0/32 type 1
172.16.3.0/32 cost 6
172.16.4.0/32 type 1 cost 9
[r2]ip ip-prefix 1 permit 172.16.1.1 32
[r2]ip ip-prefix 2 permit 172.16.2.1 32
[r2]ip ip-prefix 3 permit 172.16.3.1 32
[r2]ip ip-prefix 4 permit 172.16.4.1 32
[r2]route-policy huawei deny node 10
[r2-route-policy]if-match ip-prefix 1
[r2]route-policy huawei permit node 20
[r2-route-policy]if-match ip-prefix 2
[r2-route-policy]apply cost-type type-1
[r2]route-policy huawei permit node 30
[r2-route-policy]if-match ip-prefix 3
[r2-route-policy]apply cost 6
[r2]route-policy huawei permit node 40
[r2-route-policy]if-match ip-prefix 4
[r2-route-policy]apply cost-type type-1
[r2-route-policy]apply cost 9
[r2]route-policy huawei permit node 50
[r2]ospf 1
[r2-ospf-1]import-route rip 1 route-policy huawei
[r4]ip ip-prefix 1 permit 172.16.1.1 32
[r4]ip ip-prefix 2 permit 172.16.2.1 32
[r4]ip ip-prefix 3 permit 172.16.3.1 32
[r4]ip ip-prefix 4 permit 172.16.4.1 32
[r4]route-policy huawei deny node 10
[r4-route-policy]if-match ip-prefix 1
[r4-route-policy]route-policy huawei permit node 20
[r4-route-policy]if-match ip-prefix 2
[r4-route-policy]apply cost-type type-1
[r4-route-policy]route-policy huawei permit node 30
[r4-route-policy]if-match ip-prefix 3
[r4-route-policy]apply cost 6
[r4-route-policy]route-policy huawei permit node 40
[r4-route-policy]if-match ip-prefix 4
[r4-route-policy]apply cost-type type-1
[r4-route-policy]apply cost 9
[r4-route-policy]route-policy huawei permit node 50
[r4-route-policy]ospf 1
[r4-ospf-1]import-route rip 1 route-policy huawei
检测
查看路由表