关键字:华为ACL配置、Cisco ACL配置、Vlan ACL配置
1. 应用到交换机物理端口上的ACL
-
拓扑:PC连接在交换机Gig0/0/1端口
-
实现:在PC上不能访问IP的80和443端口
-
理解:
- 站在PC侧(站在哪里很重要),看交换机,PC的数据包是要进入交换机端口,就应用到Gig/0/1的inbound方向上。
- PC访问百度的443,即数据包的destination-port 443 。
- 站在PC侧(站在哪里很重要),看交换机,PC的数据包是要进入交换机端口,就应用到Gig/0/1的inbound方向上。
-
代码如下:
```
acl name test
rule 5 deny tcp destination-port eq 443
rule 10 deny tcp destination-porteq www
interface GigabitEthernet0/0/1
traffic-filter inbound acl name test
```
2. 应用到vlan上的ACL
-
实现:在vlan182的in方向上,只允许vlan182与主机10.10.10.89通讯,
-
理解:
- 把vlan的网关看作交换机的门。
- 交换机内部,报文在Vlan间由交换机L3转发引擎转发,不受ACL控制。所以,对于vlan182访问vlan221,只能控制vlan182的in方向
Permit ip destination 10.10.10.89 0
Deny ip destination 10.0.0.0 0.255.255.255
Deny ip destination 172.16.0.0 0.25.255.255
Deny ip destination 192.168.0.0 0.0.255.255
Permit ip destination any
-
另一种写法:
应用到vlan的out方向,这里控制的是已经进入交换机的流量,因为正常通信的建立需要对方回包(小偷已经进到客厅了,但不让它从后门出去)。
使用标准acl即可:
Permit source10.10.10.89 0
Deny source 10.0.0.0 0.255.255.255
Deny source172.16.0.0 0.25.255.255
Deny source 192.168.0.0 0.0.255.255
Permit any