R2上的四個環回接口:2.2.0.2/24, 2.2.1.2/24, 2.2.2.2/24, 2.2.3.2/24
R6上的四個環回接口:6.6.0.6/24,6.6.1.6/24,6.6.2.6/24,6.6.3.6/24
一、 通過ACL進行過濾
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ospf 110 router-id 4.4.4.4
import-route rip 1 cost 50 tag 5555 route-policy rip-to-ospf
area 0.0.0.0
network 192.168.46.0 0.0.0.255
#
rip 1
version 2
network 172.16.0.0
import-route ospf 110 cost 5 route-policy ospf-to-rip
#
route-policy rip-to-ospf permit node 10
if-match acl 2000
#
route-policy ospf-to-rip permit node 10
if-match acl 2001
acl number 2000
rule 10 permit source 2.2.0.0 0.0.1.0
acl number 2001
rule 10 permit source 6.6.0.0 0.0.1.0
#使用ACL來過濾路由,需要使用基本ACL,即只匹配源地址,ACL使用通配符掩碼,通配符掩碼的表示方法是0需要匹配,1不需要匹配,0和1可以是不連續的。6.6.0.0 0.0.1.0換成二進制
6.6. 0000 0000.0,即除了第24位不需要檢查,其餘的位都要和6.6.0.0匹配。 所以滿足條件的是
6.6.0000 0000.0和6.6.0000 0001.0.即6.6.0.0和6.6.1.0兩條路由。 使用ACL來匹配路由,只能匹配網絡號,而不能匹配掩碼,所以不如前綴列表精確。
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
二、 通過 ip-prefix進行過濾
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ospf 110 router-id 4.4.4.4
import-route rip 1 cost 50 tag 1111 route-policy rip-to-ospf
area 0.0.0.0
network 192.168.46.0 0.0.0.255
#
rip 1
version 2
network 172.16.0.0
import-route ospf 110 cost 8 route-policy ospf-to-rip
#
route-policy rip-to-ospf permit node 10
if-match ip-prefix rip
#
route-policy ospf-to-rip permit node 10
if-match ip-prefix ospf
#
ip ip-prefix rip index 10 permit 2.2.0.0 23 greater-equal 24 less-equal 24
ip ip-prefix ospf index 10 permit 6.6.0.0 23 greater-equal 24 less-equal 24
#在我看來,上面的IP前綴列表中,如果網絡前綴後面既有mask-lenth,又有大於多少,小於多少的話,這個mask-lenth就表示這個它所匹配的網絡的前多少位需要和網絡前綴相同,後面的大於多少,小於多少則表示的是這個前綴的掩碼長度在多少之間。 如果網絡前綴後面只有一個mask-lenth,則表示ip-prefix匹配的網絡前多少位要和本網絡前綴相同,掩碼也就是這個mask-lenth的長度。
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~