基于distribute-list的路由过滤

实验拓扑图

 

实验过程

1.R1的预配置

Router#config t

Enter configuration commands, one per line.  End with CNTL/Z.

Router(config)#no ip domain-lookup

Router(config)#line console 0

Router(config-line)#no exec-timeout

Router(config-line)#loggin syn

Router(config-line)#exit

Router(config)#host R1

R1(config)#int s1/0

R1(config-if)#no shut

R1(config-if)#ip add 172.16.255.1 255.255.255.252

R1(config-if)#exit

R1(config)#int lo0

R1(config-if)#ip add 172.16.0.1 255.255.255.0

R1(config-if)#exit

R1(config)#int lo1

R1(config-if)#ip add 172.16.1.1 255.255.255.0

R1(config-if)#exit

R1(config)#int lo2

R1(config-if)#ip add 172.16.2.1 255.255.255.0

R1(config-if)#exit

R1(config)#int lo3

R1(config-if)#ip add 172.16.3.1 255.255.255.0

R1(config-if)#exit

2.R2的预配置

Router>en

Router#config t

Enter configuration commands, one per line.  End with CNTL/Z.

Router(config)#no ip domain-lookup

Router(config)#line console 0

Router(config-line)#no exec-timeout

Router(config-line)#loggin syn

Router(config-line)#exit

Router(config)#host R2

R2(config)#int s1/0

R2(config-if)#no shut

R2(config-if)#ip add 172.16.255.2 255.255.255.252

R2(config-if)#exit

R2(config)#int s1/1

R2(config-if)#no shut

R2(config-if)#ip add 192.168.255.2 255.255.255.0

R2(config-if)#exit

3.R3的预配置

Router>en

Router#config t

Enter configuration commands, one per line.  End with CNTL/Z.

Router(config)#no ip domain-lookup

Router(config)#line console 0

Router(config-line)#no exec-timeout

Router(config-line)#loggin syn

Router(config-line)#exit

Router(config)#host R3

R3(config)#int s1/1

R3(config-if)#no shut

R3(config-if)#ip add 192.168.255.1 255.255.255.0

R3(config-if)#exit

R3(config)#int lo0

R3(config-if)#ip add 192.168.0.1 255.255.255.0

R3(config-if)#exit

R3(config)#int lo1

R3(config-if)#ip add 192.168.1.1 255.255.255.0

R3(config-if)#exit

R3(config)#int lo2

R3(config-if)#ip add 192.168.2.1 255.255.255.0

R3(config-if)#exit

R3(config)#int lo3

R3(config-if)#ip add 192.168.3.1 255.255.255.0

R3(config-if)#exit

4.R1ospf配置

R1(config)#router ospf 1

R1(config-router)#net 172.16.0.1 0.0.0.0 area 0

R1(config-router)#net 172.16.1.1 0.0.0.0 area 0

R1(config-router)#net 172.16.2.1 0.0.0.0 area 0

R1(config-router)#net 172.16.3.1 0.0.0.0 area 0

R1(config-router)#net 172.16.255.1 0.0.0.0 area 0

R1(config-router)#end

5.R2ospfrip的配置

R2(config)#router ospf 1

R2(config-router)#net 172.16.255.2 0.0.0.0 area 0

R2(config-router)#exit

R2(config)#router rip

R2(config-router)#version 2

R2(config-router)#no auto

R2(config-router)#net 192.168.255.0

R2(config-router)#end

6.R3rip的配置

R3(config)#router rip

R3(config-router)#version 2

R3(config-router)#no auto

R3(config-router)#net 192.168.255.0

R3(config-router)#net 192.168.0.0

R3(config-router)#net 192.168.1.0

R3(config-router)#net 192.168.2.0

R3(config-router)#net 192.168.3.0

R3(config-router)#end

7.R2上的路由重发布

R2(config)#router ospf 1

R2(config-router)#redistribute rip metric 100 subnet //rip重发布进OSPF

R2(config-router)#exit

R2(config)#router rip

R2(config-router)#redistribute ospf 1 metric 10  //OSPF重发布进rip

R2(config-router)#end

8.查看R1R3的路由表

R1#show ip route             

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/16 is variably subnetted, 5 subnets, 2 masks

C       172.16.255.0/30 is directly connected, Serial1/0

C       172.16.0.0/24 is directly connected, Loopback0

C       172.16.1.0/24 is directly connected, Loopback1

C       172.16.2.0/24 is directly connected, Loopback2

C       172.16.3.0/24 is directly connected, Loopback3

O E2 192.168.255.0/24 [110/100] via 172.16.255.2, 00:06:26, Serial1/0

O E2 192.168.0.0/24 [110/100] via 172.16.255.2, 00:06:26, Serial1/0

O E2 192.168.1.0/24 [110/100] via 172.16.255.2, 00:06:26, Serial1/0

O E2 192.168.2.0/24 [110/100] via 172.16.255.2, 00:06:26, Serial1/0

O E2 192.168.3.0/24 [110/100] via 172.16.255.2, 00:06:26, Serial1/0

R3#show ip route

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/16 is variably subnetted, 5 subnets, 2 masks

R       172.16.255.0/30 [120/10] via 192.168.255.2, 00:00:09, Serial1/1

R       172.16.1.1/32 [120/10] via 192.168.255.2, 00:00:09, Serial1/1

R       172.16.0.1/32 [120/10] via 192.168.255.2, 00:00:09, Serial1/1

R       172.16.3.1/32 [120/10] via 192.168.255.2, 00:00:09, Serial1/1

R       172.16.2.1/32 [120/10] via 192.168.255.2, 00:00:09, Serial1/1

C    192.168.255.0/24 is directly connected, Serial1/1

C    192.168.0.0/24 is directly connected, Loopback0

C    192.168.1.0/24 is directly connected, Loopback1

C    192.168.2.0/24 is directly connected, Loopback2

C    192.168.3.0/24 is directly connected, Loopback3

9.根据拓扑的需要,在R2上配置过滤ospf的路由

R2(config)#access-list 1 deny 172.16.0.0 0.0.0.255  //配置ACL抓取流量

R2(config)#access-list 1 deny 172.16.1.0 0.0.0.255

R2(config)#access-list 1 permit any

R2(config)#router rip

R2(config-router)#distribute-list 1 out ospf 1  //抓取的流量应用在distribute-list

R2(config-router)#exit

10.查看R3的路由表

R3#show ip route

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/16 is variably subnetted, 3 subnets, 2 masks

R       172.16.255.0/30 [120/10] via 192.168.255.2, 00:00:23, Serial1/1

R       172.16.3.1/32 [120/10] via 192.168.255.2, 00:00:23, Serial1/1

R       172.16.2.1/32 [120/10] via 192.168.255.2, 00:00:23, Serial1/1

C    192.168.255.0/24 is directly connected, Serial1/1

C    192.168.0.0/24 is directly connected, Loopback0

C    192.168.1.0/24 is directly connected, Loopback1

C    192.168.2.0/24 is directly connected, Loopback2

C    192.168.3.0/24 is directly connected, Loopback3

说明:172.16.0.0172.16.1.0网段的路由更新被过滤掉了,R3无法访问这两个网段。

 

10.R2上配置过滤rip的路由

R2(config)#access-list 2 deny 192.168.2.0 0.0.0.255

R2(config)#access-list 2 deny 192.168.3.0 0.0.0.255

R2(config)#access-list 2 permit any

R2(config)#router ospf 1

R2(config-router)#distribute-list 2 out rip

R2(config-router)#end

11.查看R1的路由表

R1#show ip route

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/16 is variably subnetted, 5 subnets, 2 masks

C       172.16.255.0/30 is directly connected, Serial1/0

C       172.16.0.0/24 is directly connected, Loopback0

C       172.16.1.0/24 is directly connected, Loopback1

C       172.16.2.0/24 is directly connected, Loopback2

C       172.16.3.0/24 is directly connected, Loopback3

O E2 192.168.255.0/24 [110/100] via 172.16.255.2, 00:02:14, Serial1/0

O E2 192.168.0.0/24 [110/100] via 172.16.255.2, 00:02:14, Serial1/0

O E2 192.168.1.0/24 [110/100] via 172.16.255.2, 00:02:14, Serial1/0

说明:R2已经过滤掉了来自rip192.168.2.0192.168.3.0网段的路由。

 

 

你可能感兴趣的:(职场,休闲,路由过滤,distribute-list)