不同于用于匹配流量的IP访问列表,IP前缀列表主要是用来指定具体的网络可达的。前缀列表用来匹配前缀(网段)和前缀长度(子网掩码)。前缀列表有两个参数很难理解。

下面是普通的前缀列表的参数:

ip prefix-list [name] [permit | deny] [prefix]/[len]
name为任意的名字或者数字,prefix是指定的路由前缀(网段),len是指定的前缀长度(子网掩码)。例子如下:

ip prefix-list LIST permit 1.2.3.0/24

上面的例子中指定匹配网段1.2.3.0,并且指定子网掩码为255.255.255.0,这个列表不匹配1.2.0.0/24,也不匹配1.2.3.4/32

ip prefix-list LIST permit 0.0.0.0/0

上面的例子指定匹配网段0.0.0.0和子网掩码0.0.0.0。这个列表用来匹配默认路由。

通常情况下,在使用前缀列表的时候加上“GE”(大于或等于)和“LE”(小于或等于)时比较容易发生混淆。这是因为当使用“GE”和“LE”时,列表的长度(len)发生了改变。

另外一种前缀列表的参数:

ip prefix-list [name] [permit | deny] [prefix]/[len] ge [min_length] le [max_length]

name为任意的名字或者数字,prefix是将要进行比较的路由前缀(网段),len是指从最左边开始的比特位,min_length为最小的子网掩码的值,max_length为最大的子网掩码的值

使用GE和LE,必须满足下面的条件:

len < GE <= LE

上面的参数很容易混淆,简单的说就是一个匹配前缀或子网的地址的范围。

看下面的例子:

ip prefix-list LIST permit 1.2.3.0/24 le 32

上面的例子表示前缀1.2.3.0前面的24位必须匹配。此外,子网掩码必须小于或等于32位

ip prefix-list LIST permit 0.0.0.0/0 le 32

上面的例子意味着0位需要匹配,此外子网掩码必须小于或等于32位。一位所有的网段的掩码都小于或等于32位,并且一位都不用匹配,所以这句话等于permit any

ip prefix-list LIST permit 10.0.0.0/8 ge 21 le 29

上面的例子说明网段10.0.0.0的前8位必须匹配,此外子网掩码必须在21位和29位之间。

注意:

使用前缀列表不能像访问列表那样匹配具体的应用流。
前缀列表也不能用来具体匹配奇数或偶数的前缀,或什么可以被15整除的前缀
在前缀列表中,比特位必须是连续的,并且从左边开始
ip prefix-list fuck permit 0.0.0.0/0 ge 1 表示除了默认路由外的所有路由
ip prefix-list test16 seq 5 permit 0.0.0.0/1 ge 8 le 8 配置A类地址
ip prefix-list test16 seq 10 permit 128.0.0.0/2 ge 16 le 16 配置B类地址
ip prefix-list test16 seq 15 permit 192.0.0.0/3 ge 24 le 24 配置C类地址

Exercises:

1. Construct a prefix list that permits only the 192.168.1.0/24 network.

ip prefix-list test1 seq 5 permit 192.168.1.0/24

2. Construct a prefix list that denies network 119.0.0.0, and permits all
other prefixes (including all subnets of 119.0.0.0).

ip prefix-list test2 seq 5 deny 119.0.0.0/8
ip prefix-list test2 seq 10 permit 0.0.0.0/0 le 32

3. Construct a prefix list that permits only the default route.

ip prefix-list test3 seq 5 permit 0.0.0.0/0

4. Construct a prefix list the permits everything except the default route.

ip prefix-list test4 seq 5 deny 0.0.0.0/0
ip prefix-list test4 seq 10 permit 0.0.0.0/0 le 32

5. Construct a prefix list that permits network 172.16.0.0 and any of its
subnets, and denies all other prefixes.

ip prefix-list test5 seq 5 permit 172.16.0.0/16 le 32

6. Construct a prefix list that permits only the following prefixes:
10.2.8.32/27
10.2.8.32/28
10.2.8.32/29
10.2.8.32/30

ip prefix-list test6 seq 5 permit 10.2.8.32/27 le 30

7. Construct a prefix list that:

Permits 197.25.94.128/25
Denies 197.25.94.192/26
Permits 197.25.94.224/27
Denies 197.25.94.240/28
Permits 197.25.94.248/29
Denies 197.25.94.252/30
Permits all other prefixes, except for 198.82.0.0/16

ip prefix-list test7 seq 5 deny 197.25.94.192/26
ip prefix-list test7 seq 10 deny 197.25.94.240/28
ip prefix-list test7 seq 15 deny 197.25.94.252/30
ip prefix-list test7 seq 20 deny 198.82.0.0/16
ip prefix-list test7 seq 25 permit 0.0.0.0/0 le 32

8. Construct a prefix list that permits any prefix matching the first 20
bits of 175.29.64.0 which has a mask of at least /26 but not exceeding /29,
and denies all other prefixes.

ip prefix-list test8 seq 5 permit 175.29.64.0/20 ge 26 le 29

9. Construct a prefix list that denies any prefix matching the first 19
bits of 15.26.96.0 with any mask up to and including /32, and permits any
other prefix.

ip prefix-list test9 seq 5 deny 15.26.96.0/19 le 32
ip prefix-list test9 seq 10 permit 0.0.0.0/0 le 32

10. Construct a prefix list that denies the RFC 1918 private networks and
any of their subnets, and permits everything else.

ip prefix-list test10 seq 5 deny 10.0.0.0/8 le 32
ip prefix-list test10 seq 10 deny 172.16.0.0/12 le 32
ip prefix-list test10 seq 15 deny 192.168.0.0/16 le 32
ip prefix-list test10 seq 20 permit 0.0.0.0/0 le 32

11. Construct a prefix list that permits any subnet of network 15.0.0.0
(but not the network), and denies everything else. Your router lies within
AS 65011. Place the prefix list in service in the inbound direction with
BGP neighbor 1.2.3.4.

ip prefix-list test11 seq 5 permit 15.0.0.0/8 ge 9

To place it in service:
router bgp 65011
neighbor 1.2.3.4 prefix-list test11 in

12. Construct a prefix list that denies 162.56.0.0/16 and all of its
subnets (with the exception of 162.56.209.208/29, which is permitted), and
permits all other prefixes. Your router lies within AS 65012. Place the
prefix list in service in the outbound direction with its BGP neighbor
having address 5.6.7.8.

ip prefix-list test12 seq 5 permit 162.56.209.208/29
ip prefix-list test12 seq 10 deny 162.56.0.0/16 le 32
ip prefix-list test12 seq 15 permit 0.0.0.0/0 le 32

转载于:https://blog.51cto.com/hellab/1105326

前缀列表(prefix-list)讲解相关推荐

  1. 地址前缀列表(IP Prefix List)

    地址前缀列表 IP Prefix List 优点(与ACL比较): 1.性能及可控性高于ACL 2.能同时精确匹配网络号和前缀长度(ACl无法匹配掩码/前缀长度) 3.前缀列表不能用于数据包的过滤(A ...

  2. 前缀列表---Prefix-List

    在谈起前缀列表之前,我们首先简单的分析一下常用的抓取路由的ACL(访问控制列表)的作用:1.抓数据2.抓路由. 举个简单的例子来看一看: 1.标准ACL: R1(config)#access-list ...

  3. 各种控制列表--前缀列表

    前缀列表 不同于用于匹配流量的IP访问列表,IP前缀列表主要是用来指定具体的网络可达的.前缀列表用来匹配前缀(网段)和前缀长度(子网掩码).在BGP路由选择协议中,可以对BGP路由选择更新进行过滤,要 ...

  4. Pandas批量删除dataframe列名中的前缀实战:使用lstrip函数批量删除列名中的前缀(prefix)、使用replace函数批量删除列名中的前缀(prefix)

    Pandas批量删除dataframe列名中的前缀实战:使用lstrip函数批量删除列名中的前缀(prefix).使用replace函数批量删除列名中的前缀(prefix) 目录

  5. CCIE理论-第十五篇-IPV6-重分布+ACL+前缀列表

    CCIE理论-第十五篇-IPV6-重分布+ACL+前缀列表 重分布前面讲过,这里再讲一次+实操+效果看看 在ipv6中重分布直连路由是需要加上include-connected的 环境 就这么简单哈, ...

  6. 10.3 配置前缀列表

    原理概述 前缀列表即IP-Prefix List,它可以将与所定义的前缀列表相匹配的路由,根据定义的匹配模式进行过滤.前缀列表中的匹配条目由IP地址和掩码组成,IP地址可以是网段地址或主机地址,掩码长 ...

  7. IP前缀列表配置实验

    实验拓扑如下: 蓝框中运行ospf协议,r3上面有4条静态路由:172.16.0.0/24,172.16.1.0/24,172.16.2.0/24,172.16.0.0/16,分别指向ar1和ar2. ...

  8. 华为前缀列表ip ip-prefix

    华为前缀列表ip ip-prefix  解决ACL不能够匹配多网段的工具 作用:只能匹配网段信息,相较于ACL更加精确 配置方法:一.ip ip-prefix test index 10 permit ...

  9. 华为交换机前缀列表配置

    交换机前缀列表配置 拓扑 设备配置 已配置ospf,目前网内设备都能互通 要求: 使用前缀列表配置路由过滤,使得192.168.2.0 .192.168.3.0. 192.168.4.0这3个网段之间 ...

最新文章

  1. Java终止当前线程的方法
  2. centos6.9配置LAMT页面500错误解决
  3. boost::tti模块测试函数模板
  4. java 新功能_Java 14的新功能
  5. java在文档末尾添加_如何在打开表单后将子文件添加到Word文档的末尾?
  6. 3d环形图片展示 js_网易公开课Three.js实践 勋章系统
  7. Client访问Tomcat简单流程(Struts2)
  8. python tree 库_Python——tree
  9. 【笔记】JavaScript高级篇——面向对象、原型、继承
  10. linux下 添加一个新账户tom,linux 账户管理命令 useradd、groupadd使用方法
  11. Unity使用自定义资源(.asset)配置数据
  12. arp包导致linux设备丢包,arp包导致的网络拥挤
  13. 【牛腩新闻发布系统】--初识牛腩
  14. svn图标消失解决办法
  15. Google Test - Google Testing and Mocking Framework
  16. pandas 筛选行 整行复制粘贴
  17. android APP闪退后如何屏蔽自启动
  18. Android studio 多渠道打包(包括不同的包使用不同的资源文件、不同的包写不同的代码,包名等等)
  19. 本地无需安装数据库,实现plsql远程连接数据库
  20. Python兔鼠大战游戏源代码

热门文章

  1. matlab在电气工程中的数值分析
  2. python3装饰器详解_Python装饰器详解
  3. “Could not import PIL.Image. The use of array_to_img requires PIL.”错误的解决办法
  4. 【 MATLAB 】Fourier Transforms ( fft )
  5. Spring JDBC Template
  6. 谈asp.net解决方案的项目生成时的输出路径
  7. linux ping策略打开_Linux禁止ping以及开启ping的方法
  8. Android投票列表设计,AndroidCustomView一个简单的投票排名对比图
  9. 工业电脑中PCI、CPCI、PXI插槽的区别
  10. 输入/输出延迟单元( IODELAY)简介