(CCNP)利用分发列表控制路由重分发_第1张图片

 拓扑图是利用route-map控制重分发的那个实验一样的,这里不需要r4路由器大家可以把它忽略掉。

 上一篇我讲过控制路由重分发有两种工具,route-map和分发列表。route-map已经讲过,这一个实验就是利用分发列表来控制路由重分发的。

 废话不多说了,先讲讲拓扑结构。3台路由器,其中r1上运行ripv2,在r1上有4个环回接口。r2为asbr路由器,分别运行着ripv2和ospf,r3也为ospf。

 

r1:

in e1/1

ip add 192.168.1.2 255.255.255.0

no sh

in e1/0

ip add 192.168.2.1 255.255.255.0

no sh

in loop 1

ip add 172.16.0.1 255.255.255.0

in loop 2

ip add 172.16.1.1 255.255.255.0

in loop 3

ip add 172.16.2.1 255.255.255.0

in loop 4

ip add 172.16.3.1 255.255.255.0

router rip

version 2

no au

net 192.168.1.0

net 192.168.2.0

net 172.16.0.0

r2:

in e1/1

ip add 192.168.2.2 255.255.255.0

no sh

in e1/0

ip add 192.168.3.1 255.255.255.0

no sh

router rip

version 2

net 192.168.2.0

redistribute ospf 1 metric 2 重分发ospf路由到rip

router ospf 1

net 192.168.3.1 0.0.0.0 a 0

redistribute rip metric-type 1 subnets

distribute-list 1 out rip 这条命令分发列表应用access-list 1

 

access-list 1 permit 172.16.1.0 0.0.0.255

access-list 1 permit 172.16.2.0 0.0.0.255 这3条acl控制匹配哪些路由条目,允许的将会被重分发

access-list 1 permit 192.168.1.0 0.0.0.255

 

r3:

in e1/1

ip add 192.168.3.2 255.255.255.0

no sh

ip ospf 1 a 0

 

看看效果,在r3上我们只重分发了匹配acl1的3条路由条目,而且把分发类型改为了1类,而默认是2类。

R3#show ip rou

Codes: C - connected, S - static, 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

       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

 

     172.16.0.0/24 is subnetted, 2 subnets

O E1    172.16.1.0 [110/30] via 192.168.3.1, 00:32:06, Ethernet1/1

O E1    172.16.2.0 [110/30] via 192.168.3.1, 00:32:06, Ethernet1/1

O E1 192.168.1.0/24 [110/30] via 192.168.3.1, 00:32:06, Ethernet1/1

C    192.168.3.0/24 is directly connected, Ethernet1/1

 

 

 

而这个是没有应用分发列表前的路由条目

r3#show ip rou

Codes: C - connected, S - static, 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

       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

 

     172.16.0.0/24 is subnetted, 4 subnets

O E1    172.16.0.0 [110/30] via 192.168.3.1, 00:00:15, Ethernet1/1

O E1    172.16.1.0 [110/30] via 192.168.3.1, 00:01:20, Ethernet1/1

O E1    172.16.2.0 [110/30] via 192.168.3.1, 00:01:20, Ethernet1/1

O E1    172.16.3.0 [110/30] via 192.168.3.1, 00:00:14, Ethernet1/1

O E1 192.168.1.0/24 [110/30] via 192.168.3.1, 00:01:20, Ethernet1/1

O E1 192.168.2.0/24 [110/30] via 192.168.3.1, 00:00:14, Ethernet1/1

C    192.168.3.0/24 is directly connected, Ethernet1/1

 

而分别ping也验证了确实达到了控制重分发条目的目的

R3#ping 192.168.1.2

 

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.1.1, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 12/57/100 ms

R3#ping 172.16.3.1

 

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 172.16.3.1, timeout is 2 seconds:

.....

Success rate is 0 percent (0/5)

R3#ping 172.16.1.1

 

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 172.16.1.1, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 16/45/88 ms