三层交换机配置ACL(访问控制列表).pdf
三层交换机配置 ACL(访问控制列表)说明:书本上讲述的 ACL 主要是应用在路由器上,但现在三层交换机在大中型企业中的应用越来越广泛,三层交换机因拥有路由器的功能而逐渐代替路由器。ACL 访问控制列表是构建安全规范的网络不可缺少的,但在三层交换机上配置ACL 却不为一些刚进企业的初级网络管理维护人员所知。在这里我介绍一下在三层交换机上配置 ACL 的试验过程.试验拓扑介绍:三层交换机上配置本地 Vlan 实现下层接入层交换机不同 Vlan 互通。PC1 192.168.20.10 VLAN 192。168。20.1PC2 192.168.30.20 VLAN 192.168。30。1PC3 192.168.40.30 VLAN 192。168。40.1PC4 192。168.50。40 VLAN 192。168.50。1F0/1 192。168.70。2(开启路由功能)路由器上配置F0/0 192。168。60。1 PC5 192。168。60。50F0/1 192.168。70.1试验步骤:1、在二层交换机上把相应的 PC 加入 VLAN查看交换机 Switch0Switch0(config)show run!interface FastEthernet0/1switchport access vlan 2!interface FastEthernet0/2switchport access vlan 3!查看交换机 Switch1Switch1#show run!interface FastEthernet0/3switchport access vlan 4!interface FastEthernet0/4switchport access vlan 5!2、在三层交换机上配置相应的本地 VALNSwitch(config)#inter vl 2Switch(configif)ip add 192。168.20.1 255。255。255。0Switch(configif)#no shutSwitch(config)#inter vl 3Switch(config-if)ip add 192。168。30.1 255。255。255。0Switch(configif)#no shutSwitch(config)inter vl 4Switch(configif)#ip add 192.168。40。1 255。255.255.0Switch(configif)#no shutSwitch(config)#inter vl 5Switch(config-if)ip add 192。168。50.1 255。255。255.0Switch(config-if)no shutSwitch(config-if)exi在接口 itnerface f0/1 上开启路由接口Switch(config)#inter f0/1Switch(config-if)#no switchport3、在二层交换机和三层交换机之间开启中继链路4、在路由器和三层交换机上配置动态路由协议 RIPRouter(config)#routerripRouter(config)network 192.168。60。0Router(config)#network 192。168.70。0三层交换机上配置Switch(config)#router ripSwitch(config-router)neSwitch(configrouter)#network 192.168。70。0Switch(configrouter)network 192。168.20。0Switch(config-router)network 192.168。30。0Switch(configrouter)#network 192。168。40。0Switch(config-router)network 192.168.50.0Switch(configrouter)5、验证各 PC 互通PCping 192。168.30。20Pinging 192.168。30。20 with 32 bytes of data:Request timed out。Reply from 192。168。30.20:bytes=32 time=110ms TTL=126Reply from 192。168。30.20:bytes=32 time=110ms TTL=126Reply from 192.168。30.20:bytes=32 time=125ms TTL=126Ping statistics for 192.168.30.20:Packets:Sent=4,Received=3,Lost=1(25%loss),Approximate round trip times in milli-seconds:Minimum=110ms,Maximum=125ms,Average=115msPCping 192。168.40.30Pinging 192.168。40.30 with 32 bytes of data:Reply from 192。168.40。30:bytes=32 time=94ms TTL=126Reply from 192。168.40。30:bytes=32 time=125ms TTL=126Reply from 192.168。40。30:bytes=32 time=125ms TTL=126Reply from 192。168.40。30:bytes=32 time=109ms TTL=126Ping statistics for 192.168。40。30:Packets:Sent=4,Received=4,Lost=0(0 loss),Approximate round trip times in milli-seconds:Minimum=94ms,Maximum=125ms,Average=113ms6、在三层交换机上配置 ACL注意如果设置不同 VALN 的 PC 之间不能互通,则应用的接口应为 VLAN 对应的本地 Llan 接口.设置 PC1 不能 ping 通 PC3 和 PC4Switch(config)#access-list 10 deny host 192。168.20。10应用于接口Switch(config)inter vl 4Switch(configif)#ip accessgroup 10 outSwitch(config-if)exiSwitch(config)inter vl 5Switch(configif)#ip accessgroup 10 outSwitch(configif)或者是Switch(config)inter vl 2Switch(config-if)#ip accessgroup 10 inSwitch(config-if)#(注上:此处 ACL 应用于接口,从 PC1 到 PC3 和 PC4,数据流走向是经过三层交换机上配置的本地 Vlan2 接口进入,再从三层交换机上配置的本地 Vlan4 出去到达 PC3,从本地 Vlan5 出去到达 PC4。所以在配置 ACL 时应注意访问控制列表应用于哪儿接口?!)7、验证:PC1 不能 ping 通 PC3 和 PC4PCping 192.168。50.40Pinging 192.168.50.40 with 32 bytes of data:Request timed out。Request timed out。Ping statistics for 192.168.50.40:Packets:Sent=3,Received=0,Lost=3(100 loss),ControlCCPCping 192.168。40。30Pinging 192。168。40.30 with 32 bytes of data:Request timed out。Request timed out。Request timed out.Request timed out。容易发生的错误分析:可能在学习的时候只是学习了如何在路由器上配置 ACL,而不知道在三层交换机上也能配置 ACL.或许有些同学在三层交换机上各接口开启路由接口模式,就把三层交换机当作路由器来配置,虽说三层交换机有路由器的功能,但是一些协议运用起来还是和路由器有差别的。就比如说这个试验在三层交换机的下连接口 f0/5 和 f0/6 上开启路由接口模式,结果是不配置 ACL 的前提下,各 Vlan 不通。所以 f0/5 和 f0/6 不能开启路由接口模式。在 Vlan 2、3、4、5 之间配置 ACL 时,要弄清楚数据流的进、出接口,在这里 Vlan2、3、4、5 之间的数据流的进、出口就是在三层交换机上配置本地Vlan 接口。其实ACL原理都一样、只要清楚三层交换机上配置ACL和路由器上配置的区别,在三层交换机上配置 ACL 就简单易行。