配置步骤:
首先进行IP地址规划,配置IP地址
R1:
配置代码
[R1]int g0/0/1
[R1-GigabitEthernet0/0/1]ip add 14.1.1.1 24[R1-GigabitEthernet0/0/1]int g0/0/0
[R1-GigabitEthernet0/0/0]ip add 12.1.1.1 24[R1-GigabitEthernet0/0/0]int l0
[R1-LoopBack0]ip add 1.1.1.1 24
R2:
配置代码
[R2]int g0/0/1
[R2-GigabitEthernet0/0/1]ip add 23.1.1.1 24[R2-GigabitEthernet0/0/1]int g0/0/0
[R2-GigabitEthernet0/0/0]ip add 12.1.1.2 24[R2-GigabitEthernet0/0/0]int l0
[R2-LoopBack0]ip add 2.2.2.2 24
R3:
配置代码
[R3]int g0/0/1
[R3-GigabitEthernet0/0/1]ip add 34.1.1.1 24[R3-GigabitEthernet0/0/1]int g0/0/0
[R3-GigabitEthernet0/0/0]ip add 23.1.1.2 24[R3-GigabitEthernet0/0/0]int l0
[R3-LoopBack0]ip add 3.3.3.3 24
R4:
配置代码
[R4]int g0/0/1
[R4-GigabitEthernet0/0/1]ip add 14.1.1.2 24[R4-GigabitEthernet0/0/1]int g0/0/0
[R4-GigabitEthernet0/0/0]ip add 34.1.1.2 24[R4-GigabitEthernet0/0/0]int l0
[R4-LoopBack0]ip add 4.4.4.4 24
配置RIP :
R1:
配置代码
[R1]rip 1
[R1-rip-1]version 2
[R1-rip-1]network 1.0.0.0
[R1-rip-1]network 12.0.0.0
[R1-rip-1]network 14.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.1 0.0.0.0
R3:
配置代码
[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 23.1.1.2 0.0.0.0[R3-ospf-1-area-0.0.0.0]network 34.1.1.1 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 34.1.1.2 0.0.0.0
配置多点双向重发布:
R2:
[R2]ospf 1
[R2-ospf-1]import-route rip
R4:
[R4]rip 1
[R4-rip-1]import-route ospf 1
修改R4的环回接口网络模式:
为什么修改: 有图可见框起来的路由是ospf从rip那里学来的,本身直连4.4.4.4/24,所以这条路有多余,解决办法:
[R4]int l0
[R4-LoopBack0]ospf network-type broadcast
RIP区域干涉选路,配置最优路径
R1 :
配置代码
进入接口调用
[R1]interface g0/0/0
[R1-GigabitEthernet0/0/0]rip metricin ip-prefix 4 2
[R1-GigabitEthernet0/0/0]int g0/0/1定义要抓取的流量
[R1-GigabitEthernet0/0/1]rip metricin ip-prefix 3 2[R1]ip ip-prefix 4 index 10 permit 4.4.4.0 24
[R1]ip ip-prefix 4 index 20 permit 34.1.1.0 24
[R1]ip ip-prefix 3 index 10 permit 23.1.1.0 24
选路结果:
OSPF 区域干涉选路,配置最优路径
R2:
配置代码
重发布的时候要调用路由策略
[R2]route-policy dd permit node 10
[R2-route-policy]if-match ip-prefix dd
修改dd表中node 10节点流量的属性,类型改为1
[R2-route-policy]apply cost-type type-1
[R2]route-policy dd permit node 20
[R2-route-policy]if-match ip-prefix dd
[R2-route-policy]apply cost-type type-1
定义空列表,允许其他流量访问
[R2]route-policy dd permit node 50
定义要抓取的流量
[R2]ip ip-prefix dd index 10 permit 2.2.2.0 24
[R2]ip ip-prefix dd index 20 permit 12.1.1.0 24
R4:
配置代码
定义要抓取的流量
[R4]ip ip-prefix dd permit 14.1.1.0 24
对抓取的流量修改属性
[R4]route-policy dd permit node 10
[R4-route-policy]if-match ip-prefix dd
[R4-route-policy]apply cost-type type-1定义空列表,允许其他流量访问
[R4]route-policy dd permit node 50
重发布的时候调用
[R4]ospf
[R4-ospf-1]import-route rip route-policy dd
测试:
R3访问 12网段,最优路径是23网段,关闭R3的g/0/0接口,关闭之后,走34网段
R3pingR1环回
R1访问34网段,最优路径是14网段,关闭R1的g0/0/接口, 走的就是12网段
R1pingR3的环回