配置ip以及环回
R1
[R1]int g 0/0/0
[R1-GigabitEthernet0/0/0]ip add 12.0.0.1 24
[R1-GigabitEthernet0/0/0]int g 0/0/1
[R1-GigabitEthernet0/0/1]ip add 13.0.0.1 24
[R1-GigabitEthernet0/0/1]int l0
[R1-LoopBack0]ip add 1.1.1.1 24
R2
[R2]int g 0/0/0
[R2-GigabitEthernet0/0/0]ip add 12.0.0.2 24
[R2-GigabitEthernet0/0/0]int g 0/0/1
[R2-GigabitEthernet0/0/1]ip add 24.0.0.2 24
[R2-GigabitEthernet0/0/1]int l0
[R2-LoopBack0]ip add 2.2.2.2 24
R3
[R3]int g 0/0/0
[R3-GigabitEthernet0/0/0]ip add 13.0.0.2 24
[R3-GigabitEthernet0/0/0]int g 0/0/1
[R3-GigabitEthernet0/0/1]ip add 34.0.0.2 24
[R3-GigabitEthernet0/0/1]int l0
[R3-LoopBack0]ip add 3.3.3.3 24
R4
[R4]int g 0/0/0
[R4-GigabitEthernet0/0/0]ip add 24.0.0.1 24
[R4-GigabitEthernet0/0/0]int g 0/0/1
[R4-GigabitEthernet0/0/1]ip add 34.0.0.1 24
[R4-GigabitEthernet0/0/1]int l0
[R4-LoopBack0]ip add 4.4.4.4 24
配置RIP和OSPF
R1
[R1]rip 1
[R1-rip-1]version 2
[R1-rip-1]network 12.0.0.0
[R1-rip-1]network 13.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.2.2.2
[R2-rip-1]q
[R2]ospf 1 router-id 2.2.2.2
[R2-ospf-1]area 0
[R2-ospf-1-area-0.0.0.0]network 24.0.0.2 0.0.0.0
R3
[R3]rip 1
[R3-rip-1]version 2
[R3-rip-1]network 13.0.0.0
[R3-rip-1]q
[R3]ospf 1 router-id 3.3.3.3
[R3-ospf-1]area 0
[R3-ospf-1-area-0.0.0.0]network 3.3.3.3 0.0.0.0
[R3-ospf-1-area-0.0.0.0]network 34.0.0.2 0.0.0.0
R4
[R4]ospf 1 router-id 4.4.4.4
[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 24.0.0.1 0.0.0.0
[R4-ospf-1-area-0.0.0.0]network 34.0.0.1 0.0.0.0
重发布
[R2]rip 1
[R2-rip-1]import-route ospf 1
[R2-rip-1]ospf 1
[R2-ospf-1]import-route rip 1
[R3]rip 1
[R3-rip-1]import-route ospf 1
[R3-rip-1]ospf 1
[R3-ospf-1]import-route rip 1
路由策略
路由策略 ——route-policy 调用方法不唯一,此时在重分布过程中调用
1、
[R2]ip ip-prefix aa permit 34.0.0.0 24 #抓取流量(抓取流量可以使用ACL也可以使用前缀列表)
[R2]int g 0/0/0
[R2-GigabitEthernet0/0/0]rip metricout ip-prefix aa 10
[R2-GigabitEthernet0/0/0]q
2、
[R2]ip ip-prefix bb permit 13.0.0.0 24 #抓取流量(抓取流量可以使用ACL也可以使用前缀列表)
[R2]route-policy cc permit node 10 #创建路由策略并写规则
[R2-route-policy]if-match ip-prefix bb
[R2-route-policy]apply cost 10
[R2-route-policy]q
[R2]route-policy aa permit node 20
[R2]ospf 1
[R2-ospf-1]import-route rip 1 route-policy cc #调用