拓扑图
目的:让交换机端口与主机mac绑定,防止私接主机。
主机PC配置不展示,按照图中配置即可。
开始配置之前,使用PC1 ping 一遍PC2、PC3、PC4、PC5,让交换机mac地址表刷新一下记录。
LSW1查看mac地址表
LSW1配置端口安全,将1-3口与主机PC1、PC2、PC3进行绑定
[LSW1]port-group eth1to3 # 添加端口组eth1to3
[LSW1-port-group-eth1to3]group-member Ethernet 0/0/1 to Ethernet 0/0/3 # 添加组成员
[LSW1-port-group-eth1to3]port-security enable # 启动端口安全
[LSW1-port-group-eth1to3]port-security protect-action shutdown # 违反安全规定,关闭端口
[LSW1-port-group-eth1to3]port-security max-mac-num 1 # 设置最大mac数量
[LSW1-port-group-eth1to3]port-security mac-address sticky # 将现有端口与mac地址绑定
[LSW1-port-group-eth1to3]quit
配置完成后,再使用PC1 ping 一遍其他PC,使LSW1交换机刷新MAC地址表。
再次查看LSW1的mac地址表
可以看到 1 到 3 口都与主机mac地址绑定了,type 类型也指定了sticky。LSW2配置与之差不多,自信配置即可。