过滤奇数或者偶数路由

192.168.1.0/24 192.168.00000001.0/24

192.168.2.0/24 192.168.00000010.0/24

192.168.3.0/24 192.168.00000011.0/24

192.168.4.0/24 192.168.00000100.0/24

192.168.5.0/24 192.168.00000101.0/24

192.168.6.0/24 192.168.00000110.0/24

192.168.7.0/24 192.168.00000111.0/24

192.168.8.0/24 192.168.00001000.0/24

可以发现,只要是192.168.x.0/24的x为偶数,则第24位为0,假如为奇,则第24位为1,因此根据此规律和ACL的0为完全匹配1为忽略匹配规则,可以写出如下两个acl,针对第24位进行匹配.

 

用于奇数位(odd)的网络号:rule permit source 192.168.1.0 0.0.254.0

192.168.00000001.0

000.000.11111110.0

用于偶数(even)位的网络号:rule permit source 192.168.0.0 0.0.254.0

192.168.00000000.0

000.000.11111110.0

实验:使用ACL匹配,引入奇数路由。

 

 R1配置

复制代码
interface GigabitEthernet0/0/0
 ip address 12.1.1.1 255.255.255.0 

acl number 2000  
 rule 5 permit source 192.168.1.0 0.0.254.0     #匹配奇数路由。


interface LoopBack0
 ip address 192.168.1.1 255.255.255.0 
#
interface LoopBack1
 ip address 192.168.0.1 255.255.255.0 
#
interface LoopBack2
 ip address 192.168.2.1 255.255.255.0 
#
interface LoopBack3
 ip address 192.168.3.1 255.255.255.0 
#
ospf 1 router-id 1.1.1.1 
 import-route direct route-policy 1
 area 0.0.0.0 
  network 12.1.1.1 0.0.0.0 
#
route-policy 1 permit node 10 
 if-match acl 2000 
复制代码

R2配置

复制代码
interface GigabitEthernet0/0/0
 ip address 12.1.1.2 255.255.255.0 
#
interface GigabitEthernet0/0/1
 ip address 23.1.1.2 255.255.255.0 

ospf 1 router-id 2.2.2.2 
 area 0.0.0.0 
  network 12.1.1.2 0.0.0.0 
 area 0.0.0.1 
  network 23.1.1.2 0.0.0.0 
复制代码

R3配置

interface GigabitEthernet0/0/0
 ip address 23.1.1.3 255.255.255.0

ospf 1 router-id 3.3.3.3 
 area 0.0.0.1 
  network 23.1.1.3 0.0.0.0 

测试

 

 只有1.3网段被引入了。

 

posted @   星火撩原  阅读(843)  评论(0编辑  收藏  举报
编辑推荐:
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
点击右上角即可分享
微信分享提示