命名访问控制列表可灵活的调整策略,前提是在标准访问列表以及扩展访问列表的基础上,可以使用no+ACL号删除策略.也可以使用ACL号+permit+ip追加ACL策略
实验环境
一台二层交换机一台三层交换机四台pc机
实验需求
允许vlan10中pc2可以访问pc1拒绝vlan10中其他访问pc1允许其他网段中的主机访问pc1
实验拓扑图
1,配置sw二层交换机
sw#conf t##全局模式sw(config)#vlan 10,20 ##创建vlan10,20sw(config-vlan)#exsw(config)#do show vlan-sw b ##查看vlansw(config)#int range fa1/1 -2##进入接口f1/1和f1/2sw(config-if-range)#sw mo acc ##创建接入链路sw(config-if-range)#sw acc vlan 10 ##将接口放到vlan10中sw(config-if-range)#exsw(config)#int f1/3 ##进入f1/3接口,创建接入链路放到vlan20中sw(config-if)#sw mo accsw(config-if)#sw acc vlan 20sw(config-if)#int f1/0 ##进入f1/0中创建trunk链路sw(config-if)#sw mo tsw(config-if)#sw t encapsulation dot1qsw(config-if)#exsw(config)#no ip routing ##关闭路由功能
2,配置sw-3三层交换机
sw3#conf t ##进入全局模式sw3(config)#int f1/1 进入f1/1接口sw3(config-if)#no switchport ##关闭二层接口sw3(config-if)#ip add 192.168.100.1 255.255.255.0 ##配置接口网关地址sw3(config-if)#no shut 开启sw3(config-if)#exsw3(config)#vlan 10,20 ##创建vlan10,20sw3(config-vlan)#exsw3(config)#int vlan 10 ##进入vlan10配置网关地址sw3(config-if)#ip add 192.168.10.1 255.255.255.0sw3(config-if)#no shutsw3(config-if)#exsw3(config)#int vlan 20 ##进入vlan20配置网关地址sw3(config-if)#ip add 192.168.20.1 255.255.255.0sw3(config-if)#no shutsw3(config-if)#exsw3(config)#do show ip int b ##查看接口ipVlan10 192.168.10.1 YES manual updown Vlan20 192.168.20.1 YES manual updown sw3(config)#int f1/0##进入f1/0接口创建trunk链路sw3(config-if)#sw mo tsw3(config-if)#sw t encapsulation dot1qsw3(config-if)#exsw3(config)#do show ip route ##查看路由表C 192.168.10.0/24 is directly connected, Vlan10C 192.168.20.0/24 is directly connected, Vlan20C 192.168.100.0/24 is directly connected, FastEthe
3,配置pc机ip地址,测试全网互通性
pc机1:192.168.100.100pc机2:192.168.10.10pc机3:192.168.10.20pc机4:192.168.20.20
测试是否全网互通
4,配置ACL命名访问控制列表
sw3(config)#ip access-list standard test ##设定模式及命名名称,standard为标准,extended为扩展sw3(config-std-nacl)#permit host 192.168.10.10 ##允许访问主机ipsw3(config-std-nacl)#deny 192.168.10.0 0.0.0.255 ##拒绝其他10段访问sw3(config-std-nacl)#permit any ##允许其他所有主机访问sw3(config-std-nacl)#exsw3(config)#do show access-list ##查看访问控制列表Standard IP access list test10 permit 192.168.10.1020 deny 192.168.10.0, wildcard bits 0.0.0.25530 permit anysw3(config)#int f1/1 ##进入f1/1,将ACL应用于接口于出口方向sw3(config-if)#ip access-group test out
5,测试ACL访问控制结果
1,vlan10中的主机2能够与主机1相通
2,vlan10中的主机3不能与主机3相通
3,其他网段的主机4可以与主机1相通