1、前缀列表prefix-list解析
2.2.2.0/24
2.2.2.0/25
2.2.2.0/26
ACL只可以控制网络号,无法控制掩码
access-list 1 permit 2.2.2.0 0.0.0.255
这条ACL并不能精确匹配到2.2.2.0/24,2.2.2.0/25和2.2.2.0/26同样也被包含在内,因为他们的网络号一致。
Prefix-List既可以控制网络号,也可以控制掩码
2.2.2.0/26
ip prefix-list 1 permit 2.2.2.0/24(网络号:2.2.2.0 掩码:24位)
ip prefix-list 1 permit 2.2.2.0/24 le 32(网络号:2.2.2.0 掩码:24-32位)
ip prefix-list 1 permit 2.2.2.0/24 ge 26(网络号:2.2.2.0 掩码:26-32位)
ip prefix-list 1 permit 2.2.2.0/24 ge 26 le 30(网络号:2.2.2.0 掩码:24-30位)
ip prefix-list 1 permit 0.0.0.0/0 le 32(permit any)
prefix-list从上往下执行,默认deny any
ACL可以抓数据包和路由,可以应用于接口和路由进程下,Prefix-List只能抓路由只能用于路由进程下
2、实验拓扑
3、实验配置
R1配置
interface Serial0/0
ip address 12.1.1.1 255.255.255.0
interface Serial0/1
ip address 13.1.1.1 255.255.255.0
interface Serial0/2
ip address 14.1.1.1 255.255.255.0
router eigrp 90
redistribute ospf 110 metric 1500 100 255 1 1500
network 14.1.1.0 0.0.0.255
no auto-summary
router ospf 110
router-id 1.1.1.1
log-adjacency-changes
redistribute rip subnets
network 13.1.1.0 0.0.0.255 area 0
router rip
version 2
network 12.0.0.0
no auto-summary
R2配置
interface Loopback0
ip address 2.2.2.2 255.255.255.0
interface Serial0/0
ip address 12.1.1.2 255.255.255.0
router rip
version 2
network 2.0.0.0
network 12.0.0.0
no auto-summary
R3配置
interface Loopback0
ip address 3.3.3.3 255.255.255.0
interface Serial0/0
ip address 13.1.1.3 255.255.255.0
router ospf 110
router-id 3.3.3.3
log-adjacency-changes
network 3.3.3.0 0.0.0.255 area 0
network 13.1.1.0 0.0.0.255 area 0
R4配置
interface Loopback0
ip address 4.4.4.4 255.255.255.0
interface Serial0/0
ip address 14.1.1.4 255.255.255.0
router eigrp 90
network 4.4.4.0 0.0.0.255
network 14.1.1.0 0.0.0.255
no auto-summary
4、前缀列表应用
此时我们可以看到R4可以学到3.3.3.3/32和13.1.1.0/24这两条路由,这里我们希望通过分发列表让R4只学到3.3.3.3/32这条路由。
R1配置
ip prefix-list 1 permit 3.3.3.3/32
router eigrp 90
distribute-list prefix 1 out ospf 110
此时R4只学到3.3.3.3/32这条路由。