实验拓扑如下
![](https://i-blog.csdnimg.cn/blog_migrate/5f700add9da2283ad2365be693dfd7f0.png)
先写IP地址和环回地址(依次按照R1到R4)
Interface IP Address/Mask Physical Protocol
GigabitEthernet0/0/0 12.1.1.1/24 up up
GigabitEthernet0/0/1 13.1.1.1/24 up up
GigabitEthernet0/0/2 unassigned down down
LoopBack0 1.1.1.1/32 up up(s)
NULL0 unassigned up up(s)
Interface IP Address/Mask Physical Protocol
GigabitEthernet0/0/0 12.1.1.2/24 up up
GigabitEthernet0/0/1 24.1.1.1/24 up up
GigabitEthernet0/0/2 unassigned down down
LoopBack0 2.2.2.2/32 up up(s)
NULL0 unassigned up up(s)
Interface IP Address/Mask Physical Protocol
GigabitEthernet0/0/0 34.1.1.1/24 up up
GigabitEthernet0/0/1 13.1.1.2/24 up up
GigabitEthernet0/0/2 unassigned down down
LoopBack0 3.3.3.3/32 up up(s)
NULL0 unassigned up up(s)
Interface IP Address/Mask Physical Protocol
GigabitEthernet0/0/0 24.1.1.2/24 up up
GigabitEthernet0/0/1 34.1.1.2/24 up up
GigabitEthernet0/0/2 unassigned down down
LoopBack0 4.4.4.4/32 up up(s)
NULL0 unassigned up up(s)
宣告OSPF和RIP
[Rl]rip 1
[Rl-rip-l]ver
[Rl-rip-l]version 2
[Rl-rip-1]net
[Rl-rip-1]network 12.0.0.0
[Rl-rip-1]net
[Rl-rip-l]network 13.0.0.0
[Rl-rip-l]net
[Rl-rip-1]network 1.0.0.0
[R2]rip 1
[R2-rip-l]version 2
[R2-rip-l]network 12.0.0.0
[R2-rip-l]network 2.0.0.0
[R2-rip-l]q
[R2]ospf l rou
[R2]ospf l router-id 2.2.2.2
[R2-ospf-l]area 0
[r2-ospf-1-area-0.0.0.0]net
[r2-ospf-1-area-0.0.0.0]network 24.1.1.1 0.0.0.0
[R3]rip 1
[R3-rip-1]version 2
[R3-rip-1]network 13.0.0.0
[R3-rip-1]q
[R3]ospf 1 rou
[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.1.1.1 0.0.0.0
[R4]ospf 1 rou
[R4]ospf 1 router-id 4.4.4.4
[R4-ospf-l]area 0
[R4-ospf-1-area-0.0.0.0]net
[R4-ospf-1-area-0.0.0.0]network 0.0.0.0 255.255.255.255
接下来做双点双向重发布
[R2]rip 1
[R2-rip-1]imp
[R2-rip-1]import-route ospf 1
[R2-rip-1]q
[R2]ospf 1
[R2-ospf-1]imp
[R2-ospf-1]import-route rip 1
[R3]rip 1
[R3-rip-1]imp
[R3-rip-1]import-route ospf 1
[R3-rip-1]q
[R3]ospf 1
[R3-ospf-1]imp
[R3-ospf-1]import-route rip 1
最后优化路径
[R1]acl 2000
[R1-acl-basic-2000]rule pe
[R1-acl-basic-2000]rule permit source 3.3.3.3 0.0.0.0
[R1-acl-basic-2000]q
[R1]rip 1
[R1-rip-1]q
[R1]int
[R1]interface g0/0/0
[R1-GiqabitEthernet0/0/0]rip metricin 2000 3
[R1] ip ip
[R1]ip ip-prefix xx pe
[R1]ip ip-prefix xx permit 24.1.1.0 24
[R1]undo ip ip
[R1]undo ip ip-prefix xx
[R1]ip ipv6
[R1]ip ipv6-prefix xx de
[R1]ip ip-prefix xx de
[R1]ip ip-prefix xx deny 24.1.1.0 24
[R1] ip ip
[R1]ip ip-prefix xx pe
[R1]ip ip-prefix xx permit 0.0.0.0 0 le
[R1]ip ip-prefix xx permit 0.0.0.0 0 less-equal 32
[R1]int
[R1]interface g0/0/1
[R1-GigabitEthernet0/0/1]q
[R1]rip 1
[R1-rip-1]fi
[R1-rip-1] filter-policy ip
[R1-rip-1]filter-policy ip-prefix xx im
[R1-rip-1]filter-policy ip-prefix xx import g0/0/1
[R2]ip ip-prefix xx pe
[R2]ip ip-prefix xx permit 34.1.1.0 24
[R2]rou
[R2]route-
[R2]route-policy hc
[R2]route-policy h cip de
[R2]route-policy h cip deny no
[R2]route-policy h cip deny node 10
Info: New Sequence of this List.
[R2-route-policy]if-
[R2-route-policy]if-match ip-
[R2-route-policy]if-match ip-prefix xx
[R2-route-policy]q
[R2]rou
[R2]route-
[R2]route-policy h cip pe
[R2]route-policy h cip permit n
[R2]route-policy h cip permit node 20
Info: New Sequence of this List.
[R2-route-policy]q
[R2]rip 1
[R2-rip-1]im
[R2-rip-1]import-route ospf 1 ro
[R2-rip-1]import-route osp f 1 route-policy hcip
[R3]ip ip-prefix n n pe
[R3]ip ip -prefix n n permit 2.2.2.2 32
[R3]rou
[R3]route-
[R3]route-policy yy pe
[R3]route-policy yy permit no
[R3]route-policy yy permit node 10
Info: New Sequence of this List.
[R3-route-policy]if-
[R3-route-policy]if-match ip-
[R3-route-policy]if-match ip-prefix nn
[R3-route-policy]ap
[R3-route-policy]apply cost
[3-route-policy]apply cost.
[Rr3-route-policy] apply cost 4
[R3-route-policy]q
[R3]rou
[R3]route-
[R3]route-policy yy pe
[R3]route-policy yy permit no
[R3]route-policy yy permit node 20
Info: New Sequence of this List.
[R3-route-policy]q
[R3]ospf 1
[R3-ospf-1]im
[R3-ospf-1]import-route rip 1 rou
[R3-ospf-1]import-route rip 1 route-policy yy
试验结束