ACL过滤奇数或者偶数路由


ACL过滤奇数或者偶数路由   一个多协议网络中,客户地址分配很细,很多:  www.zhishiwu.com   192.168.1.0/24 192.168.2.0/24 192.168.3.0/24 192.168.4.0/24 192.168.5.0/24 …………………….. 某些网络需要将所有的偶数位的网段进行过滤   分析: 由于要求R1仅能够学习到R3的奇数位的网络号或是偶数号的网络号.将各个子 网拆成二进制观察规律 192.168.1.0/24192.168.00000001.0/24 192.168.2.0/24192.168.00000010.0/24 192.168.3.0/24192.168.00000011.0/24 192.168.4.0/24192.168.00000100.0/24 192.168.5.0/24192.168.00000101.0/24 192.168.6.0/24192.168.00000110.0/24 192.168.7.0/24192.168.00000111.0/24 192.168.8.0/24192.168.00001000.0/24   可以发现,只要是192.168.x.0/24的x为偶数,则第24位为0,假如为奇,则第24位为1,因此根据此规律和ACL的0为完全匹配1为忽略匹配规则,可以写出如下两个acl,针对第24位进行匹配.    www.zhishiwu.com   用于奇数位(odd)的网络号:access-list 2 permit 192.168.1.0 0.0.254.0 192.168.00000001.0 000.000.11111110.0   用于偶数(even)位的网络号:access-list 1 permit 192.168.0.0 0.0.254.0 192.168.00000000.0 000.000.11111110.0   实验验证   基本配置如图:  
ACL过滤奇数或者偶数路由

  直接在R2重分发,R1学到了全部网络。 R1#sh ip route      1.0.0.0/32 is subnetted, 1 subnets C       1.1.1.1 is directly connected, Loopback0      23.0.0.0/24 is subnetted, 1 subnets O E2    23.1.1.0 [110/20] via 12.1.1.2, 00:00:05, FastEthernet0/0 O E2 192.168.4.0/24 [110/20] via 12.1.1.2, 00:00:05, FastEthernet0/0      12.0.0.0/24 is subnetted, 1 subnets C       12.1.1.0 is directly connected, FastEthernet0/0 O E2 192.168.1.0/24 [110/20] via 12.1.1.2, 00:00:05, FastEthernet0/0 O E2 192.168.2.0/24 [110/20] via 12.1.1.2, 00:00:05, FastEthernet0/0 O E2 192.168.3.0/24 [110/20] via 12.1.1.2, 00:00:05, FastEthernet0/0   R2(config)#ip access-list standard permit_odd R2(config-std-nacl)#per 192.168.1.0  0.0.254.255  #只允许奇数(反掩码写成0.0.254.0也行) R2(config)#route-map permit_odd per 10 R2(config-route-map)#match ip add permit_odd R2(config-router)#redistribute rip subnets route-map permit_odd   查看R1路由表,发现只剩下奇数路由,实验成功,允许偶数网段同理。 R1#sh ip route      1.0.0.0/32 is subnetted, 1 subnets C       1.1.1.1 is directly connected, Loopback0      12.0.0.0/24 is subnetted, 1 subnets C       12.1.1.0 is directly connected, FastEthernet0/0 O E2 192.168.1.0/24 [110/20] via 12.1.1.2, 00:04:24, FastEthernet0/0 O E2 192.168.3.0/24 [110/20] via 12.1.1.2, 00:04:24, FastEthernet0/0  

(免责声明:文章内容如涉及作品内容、版权和其它问题,请及时与我们联系,我们将在第一时间删除内容,文章内容仅供参考)

未经允许不得转载:本文采用知识共享 署名4.0国际许可协议 [BY-NC-SA] 进行授权!路由网 » ACL过滤奇数或者偶数路由