分发列表(分布列表)
实验1:基本分发列表
s1 172.16.0.1/24 s1 .2 s0 192.168.5.2/24 s1 192.168.5.7/24
R1----------------------------R2------------------------------R7
lo1 10.0.0 .1/24 lo0 7.7.7.7/24
要求:拒绝 10.0.0 .0网段路由发布到R7上,全网运行EIGRP协议。
R2(config)#access-list 1 deny 10.0.0 .0 0.0.0.255 拒绝所有10.0.0.0的网段流量。
R2(config)#access-list 1 permit any 允许除了 10.0.0 .0其他所有网段IP。
R2(config)#router ei 555
R2(config-router)#
R2(config-router)#distribute-list 1 out s0 应用分发列表对访问控制列表
“
1
”
中所指定流量在s0的出口处进行过滤。
过滤前:
R7#s ip rou
05:27:07: %SYS-5-CONFIG_I: Configured from console by console
Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF , IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
* - candidate default, U - per-user static route, o - ODR
P - periodic downloaded static route
Gateway of last resort is not set
D 172.16.0.0/16 [90/2681856] via 192.168.5.2, 00:00:02, Serial1
7.0.0 .0/8 is variably subnetted, 2 subnets, 2 masks
D 7.0.0 .0/8 is a summary, 00:00:04, Null0
C 7.7.7 .0/24 is directly connected, Loopback0
C 192.168.5.0/24 is directly connected, Serial1
D 10.0.0 .0/8 [90/2809856] via 192.168.5.2, 00:00:02, Serial1
过滤前可以看到
R1
的
10
网段
IP
。
过滤后
:
R7#s ip rou
Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF , IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
* - candidate default, U - per-user static route, o - ODR
P - periodic downloaded static route
Gateway of last resort is not set
D 172.16.0.0/16 [90/2681856] via 192.168.5.2, 00:00:01, Serial1
7.0.0 .0/8 is variably subnetted, 2 subnets, 2 masks
D 7.0.0 .0/8 is a summary, 00:00:01, Null0
C 7.7.7 .0/24 is directly connected, Loopback0
C 192.168.5.0/24 is directly connected, Serial1
实验:将路由映射与重分布进行结合
拓扑图:
s0 44.0.0.4/8 s6 .1 s0 .1 s0 66.0.0.6/8
R4----------------------------------R1--------------------------------------R6
RIPv2 OSPF 66
lo0 10.1.0 .1/16 要求:10.1.0.0和172.16.1.0重分布到OSPF中后度量值为500并且设置为外部1类OSPF,拒绝10.2.0.0网段进行重分布, 其它IP重分布进来后度量值为5000并且设置其为外部2类OSPF。
lo1 10.2.0 .1/16
lo2 172.16.1.1/24
lo4 11.1.1 .1/24
hostname r1
interface Serial0
ip address 66.0.0.1 255.0.0.0
no ip route-cache
no ip mroute-cache
clockrate 64000
interface Serial6
ip address 44.0.0.1 255.0.0.0
no ip route-cache
no ip mroute-cache
clockrate 64000
router ospf 66
redistribute rip subnets route-map teacher
将
RIP
重分布到
OSPF
中时
,
应用策略
“
teacher
”
。
network 66.0.0.1 0.0.0 .0 area 0
!
router rip
version 2
redistribute ospf 66 metric 4
network 44.0.0.0
no auto-summary
access-list 23 permit 10.1.0 .0 0.0.255.255
定义标准访问控制列表
23
,
匹配源地址
10.1.0.0
。
access-list 29 permit 172.16.0.0 0.0.255.255
access-list 37 permit 10.2.0 .0 0.0.255.255
route-map teacher permit 10
定义路由映射表
“
teacher
”
,
策略为允许
,
序列号为
10
。
match ip address 23 29 当匹配访问控制列表23 29当中定义的源地址时
set metric 500 设置重分布后的度量值为500。
set metric-type type-1 设置外部OSPF的类型为1类,(1类:总度量值=外部+内部)
!
route-map teacher deny 20 定义路由映射表
“
teacher
”
,策略为拒绝(不进行重分布),序列号为20。
match ip address 37 当匹配访问控制列表37中,定义的源地址时。
!
route-map teacher permit 30 当以上条件都不满足时。
set metric 5000 其余的重分布后的度量值设置为5000。
set metric-type type-2 设置外部OSPF的类型为2类,(2类:总度量值=外部 ,而忽略内部度量值,因为认为外部远远大于内部)
========================================================================
R6#s ip rou
Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF , IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route
Gateway of last resort is not set
C 66.0.0.0/8 is directly connected, Serial0
6.0.0 .0/24 is subnetted, 1 subnets
C 6.6.6 .0 is directly connected, Loopback0
172.16.0.0/24 is subnetted, 1 subnets
O E1 172.16.1.0 [110/564] via 66.0.0.1, 00:33:45, Serial0
10.0.0 .0/16 is subnetted, 1 subnets
O E1 10.1.0 .0 [110/564] via 66.0.0.1, 00:33:45, Serial0
11.0.0 .0/16 is subnetted, 1 subnets
O E2 11.1.0 .0 [110/5000] via 66.0.0.1, 00:35:57, Serial0
O E2 44.0.0.0/8 [110/5000] via 66.0.0.1, 00:35:58, Serial0