拓扑图:
要求:
1.开启端口安全模式
2.设置端口最大安全数
3.端口绑定MAC地址
4.违规处理
5.锁定安全端口
6.MAC地址与IP的绑定
7.端口镜像
pc机 | ip地址 | 掩码 | mac地址 | 端口 |
PC1 | 192.168.1.10 | 24 | 00-0b-4c-9e-2a-1c | E1/0/1 |
PC2 | 192.168.1.11 | 24 | 00-0b-2e-5d-62-4e | E1/0/2 |
PC3 | 192.168.1.12 | 24 | 00-0b-cd-4a-97-08 | E1/0/3 |
SWA:
am enable
!
vlan 1
!
Interface Ethernet0/0/1
switchport port-security //开启端口安全
switchport port-security maximum 10 //设置端口安全最大数为10
switchport port-security mac-address 00-0b-4c-9e-2a-1c //E0/0/1端口绑定PC1的MAC地址
switchport port-security violation shutdown //违规关闭
switchport port-security lock //锁定安全端口
!
Interface Ethernet0/0/2 //绑定MAC-IP地址
am port
am mac-ip-pool 00-0b-2e-5d-62-4e 192.168.1.11 //E0/0/2端口绑定PC2的MAC与PC2的IP地址
注:将端口E1/0/2绑定为PC2 此时PC2可通过该端口访问PC1或PC3 若更改PC2的IP地址,或将其他设备(如PC3)连接E1/0/2端口则无法进行访问
!
Interface Ethernet0/0/3 //绑定IP地址区间
注:将端口绑定一个IP地址区间 则此区间的IP地址设备可通过该端口进行访问 不在此区间的IP地址无法通过该端口访问网络
am port
am ip-pool 192.168.1.12 2 //将端口E0/0/3绑定192.168.1.12和192.168.1.13两个IP地址
!
monitor session 1 source interface Ethernet0/0/2 rx
monitor session 1 source interface Ethernet0/0/2 tx
//监听E0/0/2端口的进出流量
monitor session 1 destination interface Ethernet0/0/1
//把监听端口的流量镜像到端口E0/0/1
!
端口镜像的限制
1.目前只支持一个镜像目的端口,镜像源端口则没有使用上的限制,可以是1个也可以是多个,多个源端口可以在相同的VLAN,也可以在不同VLAN。但如果镜像目的端口要能镜像到多个镜像源端口的流量,镜像目的端口必须要同时属于这些镜像源端口的所在的VLAN
2.镜像目的端口不能是端口聚合组成员
3.镜像目的端口的吞吐量如果小于镜像源端口吞吐量的总和,则目的端口无法完全复制源端口的流量;请减少源端口的个数或复制单向的流量,或者选择吞吐量更大的端口作为目的端口