使用distribute-list(分发列表)控制路由更新

12年前 (2014-03-24)网络技术

distribute list可以用来控制路由更新,它需要用到access list。一般情况下,access list并不能控制由路由器自己生成的数据流,但是如果将access list应用到distribute list,则可以用来允许、拒绝路由选择更新。

下面是本实例用到的拓扑:

实验操作:

R1:

interface Loopback0
 ip address 172.16.0.1 255.255.255.0
!
interface Loopback1
 ip address 172.16.1.1 255.255.255.0
!
interface Loopback2
 ip address 172.16.2.1 255.255.255.0
!
interface Loopback3
 ip address 172.16.3.1 255.255.255.0
!
interface FastEthernet0/0
 ip address 10.1.1.1 255.255.255.0
!
router eigrp 1
 network 10.1.1.0 0.0.0.255
 network 172.16.0.0 0.0.0.255
 network 172.16.1.0 0.0.0.255
 network 172.16.2.0 0.0.0.255
 network 172.16.3.0 0.0.0.255
 no auto-summary

 

R2:

interface FastEthernet0/0
 ip address 10.1.1.2 255.255.255.0
!
interface FastEthernet1/0
 ip address 10.1.2.2 255.255.255.0
!
interface FastEthernet2/0
 ip address 10.1.3.2 255.255.255.0
!
router eigrp 1
 network 10.1.1.0 0.0.0.255
 network 10.1.2.0 0.0.0.255
 network 10.1.3.0 0.0.0.255
 no auto-summary

R3:

interface FastEthernet1/0
 ip address 10.1.2.1 255.255.255.0
!
router eigrp 1
 network 10.1.2.0 0.0.0.255
 auto-summary

 

R4:

interface FastEthernet2/0
 ip address 10.1.3.1 255.255.255.0
 !
router eigrp 1
 network 10.1.3.0 0.0.0.255
 distribute-list 1 in FastEthernet2/0
 auto-summary
!
access-list 1 deny   172.16.0.0 0.0.1.255
access-list 1 permit any

 

 

 另一种方法是在R2的f2/0接口执行  distribute-list  1  out  f2/0  ,这样比上种方法更好,减少了路由条目在R2---->R4链路上的流动

完成之后,在R4上查看:

R4#sh ip route
     172.16.0.0/24 is subnetted, 2 subnets
D       172.16.2.0 [90/158720] via 10.1.3.2, 00:18:52, FastEthernet2/0
D       172.16.3.0 [90/158720] via 10.1.3.2, 00:18:52, FastEthernet2/0
     10.0.0.0/24 is subnetted, 3 subnets
C       10.1.3.0 is directly connected, FastEthernet2/0
D       10.1.2.0 [90/30720] via 10.1.3.2, 00:25:06, FastEthernet2/0
D       10.1.1.0 [90/30720] via 10.1.3.2, 00:25:06, FastEthernet2/0

 

而R3与R4形成对比

R3#sh ip route
     172.16.0.0/24 is subnetted, 4 subnets
D       172.16.0.0 [90/158720] via 10.1.2.2, 00:19:04, FastEthernet1/0
D       172.16.1.0 [90/158720] via 10.1.2.2, 00:19:04, FastEthernet1/0
D       172.16.2.0 [90/158720] via 10.1.2.2, 00:19:04, FastEthernet1/0
D       172.16.3.0 [90/158720] via 10.1.2.2, 00:19:04, FastEthernet1/0
     10.0.0.0/24 is subnetted, 3 subnets
D       10.1.3.0 [90/30720] via 10.1.2.2, 00:25:29, FastEthernet1/0
C       10.1.2.0 is directly connected, FastEthernet1/0
D       10.1.1.0 [90/30720] via 10.1.2.2, 00:25:29, FastEthernet1/0

 

总结:

用分布控制列表过滤路由更新,分布控制列表只抑制某些特定的路由不被发送或接受。

 命令格式:

A.应用于进入路由更新

 (config-router)#distribute-list  access-list number   in  {interfacename}

B.应用于出口路由更新

(config-router)#distribute-list    access-listnumber     out   (interface name |routing pro|as-number)