配置交换机端口安全

配置交换机端口安全

image-20250527131459393

实验一、绑定MAC后,更改MAC地址,不能正常通讯

<Huawei>sys
[Huawei]port-group 1to3
[Huawei-port-group-1to3]
[Huawei-port-group-1to3]group-member Ethernet 0/0/1 to Ethernet 0/0/3
[Huawei-port-group-1to3]display this
#
port-group 1to3
 group-member Ethernet0/0/1
 group-member Ethernet0/0/2
 group-member Ethernet0/0/3
#
return

[Huawei-port-group-1to3]port-security protect-action ?
  protect   Discard packets
  restrict  Discard packets and warning
  shutdown  Shutdown 

[Huawei-port-group-1to3]port-security protect-action shutdown
[Huawei-port-group-1to3]undo port-security protect-action
[Huawei-port-group-1to3]port-security protect-action shutdown
[Huawei-port-group-1to3]quit

[Huawei]interface Ethernet 0/0/1
[Huawei-Ethernet0/0/1]port-security max-mac-num 1
[Huawei-Ethernet0/0/1]quit

[Huawei-port-group-1to3]port-security mac-address sticky
[Huawei-port-group-1to3]quit

PC1可以PING通PC5

image-20250527132605546

PC的MAC地址73改成72

image-20250527135106101

image-20250527135140588

MAC地址改回73之后,必须开启节点才能启动

image-20250527140517844

[Huawei]interface Ethernet 0/0/1
[Huawei-Ethernet0/0/1]undo shutdown
image-20250527140647571

实验二、限制主机的数量

[Huawei-GigabitEthernet0/0/1]port-security enable
[Huawei-GigabitEthernet0/0/1]port-security max-mac-num 2
[Huawei-GigabitEthernet0/0/1]port-security protect-action protect 
[Huawei-GigabitEthernet0/0/1]port-security mac-address sticky 

多加一台主机,使用PC7 PING PING1

image-20250527142034130

PC7不能主动发起通讯

image-20250527142425910

但是PC1发起的通讯却能正常运作

image-20250527142731130

但是正常绑定的却只有两台

image-20250527142859336

其他

#关闭信息中心
[Huawei]undo info-center enable 

实验三、绑定指定的MAC地址

[Huawei]interface Ethernet 0/0/3
[Huawei-Ethernet0/0/3]port-security enable 
[Huawei-Ethernet0/0/3]port-security protect-action protect 
[Huawei-Ethernet0/0/3]port-security mac-address sticky 
[Huawei-Ethernet0/0/3]port-security mac-address sticky 5489-9886-2B0C vlan 1
[Huawei-Ethernet0/0/3]display this
#
interface Ethernet0/0/3
 port-security enable
 port-security protect-action protect
 port-security mac-address sticky
#

改PC7的MAC地址

image-20250527153256337

image-20250527153405517

改回来就可以了

image-20250527153445603

#清楚交换机接口配置
[LSW2]clear configuration interface Ethernet 0/0/4

交换机配置也记得保存一下

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注