前缀列表,专门用来匹配路由条目,而不是流量,相当于升级版的基础ACL,其不仅可以匹配路由条目目的来源,还可以匹配匹配路由条目的掩码。
ip:prefix 用于过滤甲前缀,能同时匹配前缀号和掩码长度 不能用于数据包过滤 缺省情况下,存在最后一条默认匹配模式为deny 当引用前缀列表不存在时,默认匹配模式为permit
如图所示,待过滤路由按照索引号从小到大的顺序进行匹配:
地址前缀列表过滤路由的原则可以总结为:顺序匹配、唯一匹配、默认拒绝。
地址前缀列表通过ip ip-prefix命令进行配置,常用格式如下:
ip ip-prefix ip-prefix-name [ index index-number ] { permit | deny } ipv4-address mask-length [ greater-equal greater-equal-value ] [ less-equal less-equal-value ]
其中ipv4-address mask-length [ greater-equal greater-equal-value ] [ less-equal less-equal-value ] 用于限定过滤路由的网络号及掩码范围,参数含义如表所示。
参数含义:
当待过滤的路由已匹配当前表项的网络号时,掩码长度可以进行精确匹配或者在一定掩码长度范围内匹配:
除了与路由策略等工具配合使用,还可以通过filter-policy配合使用对全局的发布和接收的路由信息过滤(filter-policy可以用ACL或者前缀列表进行匹配):
# 配置名为p1的地址前缀列表,只允许10.0.192.0/8网段内,掩码长度在17到18之间的路由通过。
system-view
[AC6605] ip ip-prefix p1 permit 10.0.192.0 8 greater-equal 17 less-equal 18
# 配置名为p2的地址前缀列表,只允许掩码长度在17到18之间的路由通过。
system-view
[AC6605] ip ip-prefix p2 permit 0.0.0.0 0 greater-equal 17 less-equal 18
# 配置名为p3的地址前缀列表,拒绝0.0.0.1~0.255.255.255范围内的所有路由通过,允许其他路由通过。
system-view
[AC6605] ip ip-prefix p3 index 10 deny 0.0.0.0 8 match-network
[AC6605] ip ip-prefix p3 index 20 permit 0.0.0.0 0 less-equal 32
[SwitchB] ip ip-prefix huawei index 10 permit 192.168.0.0 16
[SwitchB] route-policy RP permit node 10
[SwitchB-route-policy] if-match ip-prefix huawei
[SwitchB-route-policy] quit
[SwitchB] ospf
[SwitchB-ospf-1] import-route static route-policy RP
[SwitchB-ospf-1] quit
留言与评论(共有 0 条评论) “” |