依照图配置IP
配置RIP
[r1]rip 1
[r1-rip-1]version 2
[r1-rip-1]network 1.0.0.0
[r1-rip-1]network 192.168.1.0
[r4]rip 1
[r4-rip-1]version 2
[r4-rip-1]network 192.168.2.0
配置OSPF
[r1]ospf 1[r1-ospf-1]area 0
[r1-ospf-1-area-0.0.0.0]network 1.1.1.1 0.0.0.0
[r1-ospf-1-area-0.0.0.0]network 192.168.3.1 0.0.0.0
[r4]ospf 1
[r4-ospf-1]area 0
[r4-ospf-1-area-0.0.0.0]network 4.4.4.4 0.0.0.0
[r4-ospf-1-area-0.0.0.0]network 192.168.4.1 0.0.0.0
进行双向重发布,控制选路
ospf重发布到RIP的控制选路
[r1]ip ip-prefix a index 10 permit 192.168.4.0 30
[r1]ip ip-prefix a index 20 permit 4.4.4.0 24 //前缀列表
[r1-GigabitEthernet0/0/0]rip metricout ip-prefix a 3 //在该接口出方向上匹配前缀列表a,度量加3
[r1-rip-1]import-route ospf 1
[r4]ip ip-prefix a index 10 permit 192.168.3.0 30
[r4-GigabitEthernet0/0/0]rip metricout ip-prefix a 3
[r4-rip-1]import-route ospf 1
RIP重发布到OSPF的控制选路
[r1]ip ip-prefix c permit 1.1.1.0 24
[r4]ip ip-prefix b index 10 permit 192.168.1.0 30
[r4]route-policy huahua permit node 10 //创建名位huahua的路由策略,大动作允许,序列号10
[r4-route-policy]if-match ip-prefix b //匹配前缀列表a
[r4-route-policy]apply cost 3 //将度量改位3
[r4]route-policy huahua permit node 20 //空表,允许所有
[r4-ospf-1]import-route rip 1 route-policy huahua
[r1]ip ip-prefix c permit 192.168.2.0 30
[r1]route-policy huahua permit node 10
[r1-route-policy]if-match ip-prefix c
[r1-route-policy]apply cost 3
[r1]route-policy huahua permit node 30
[r1-ospf-1]import-route rip 1 route-policy huahua
R2路由表
R3路由表
将R3的G0/0/0口shutdown后,R3的路由表