Dell Networking SONiC 如何配置端口安全性
Summary: 如何在 Dell Networking SONiC 中配置端口安全性。本文在 Dell Networking SONiC 4.2 Edge Standard 中进行了测试。
This article applies to
This article does not apply to
This article is not tied to any specific product.
Not all product versions are identified in this article.
Instructions
| 先决条件 我们使用标准接口命名来演示概念。请参阅文章 Dell Networking S 系列:基本接口配置 - SONiC 4.0,了解有关 接口命名的更多信息。 |
指数
什么是端口安全设置端口
中允许的最大 MAC 地址数端口安全违规
违约
配置语法
示例配置
验证
什么是端口安全
端口安全性通过限制用户指定端口上的 MAC 学习次数来保护端口。- vlan 中不支持端口安全性
- 以太网端口和配置为交换机端口的 PortChannel 支持端口安全性。
- 非交换机端口不支持端口安全性。
设置端口中允许的最大 MAC 地址数
使用 MAC 学习功能,您可以设置接口上允许的 MAC 地址的最大限制。限制 MAC 地址可提供安全性,防止 MAC 泛滥。超过允许的最大 MAC 阈值时,系统将生成警告系统日志通知,并发生端口安全违规。注意:您可以禁用 MAC 学习限制,以恢复每个端口允许的默认 MAC 地址数。
端口安全违规
当端口学习的 MAC 地址数超过配置的限制时,就会发生端口安全违规。您可以配置在违规期间应采取的操作。在 Dell SONiC 中,在发生违规时可以采取的措施是 保护。激活保护模式后,当接口上的 MAC 地址数量达到配置的限制时,它会禁用端口上的 MAC 学习。在此阶段,将丢弃端口上具有未知源地址的所有数据包。
发生端口安全违规时可以采取什么措施?
您可以采取以下任何操作
--> 找到并删除导致 mac 地址过多的设备后,我们可以清除界面中的 mac 地址表以清除违规状态。
命令语法
DELLSONiC# clear mac address-table dynamic interface Eth <slot/port> |
,增加允许的 mac 地址限制 命令语法
DELLSONiC# configure DELLSONiC(config)# interface Eth X/X DELLSONiC(config-if-EthX/X)# port-security maximum <number of mac address> |
,禁用端口安全命令语法
DELLSONiC# configure DELLSONiC(config)# interface Eth X/X DELLSONiC(config-if-EthX/X)# no port-security enable |
如何找到被端口安全阻止的 mac 地址?
我们可以从日志消息中找到被端口安全阻止的 mac 地址的详细信息。请参阅下面的 eaxmple(日期/时间和 mac 地址已屏蔽)
DELLSONiC# show logging | grep "Port Mac Security violation" XXX XX XX:XX:XX.XXXXXXXXXXXX XXXX DELLSONiC WARNING syncd#syncd: :- port_mac_sec_add_mac: Port Mac Security violation by MAC YY:YY:YY:YY:YY:YY Port Eth1/1 |
违约
| 端口上的端口安全性 | Disabled |
|---|---|
| 每个端口的最大 MAC 地址数 | 1 |
| 违规模式 | 保护 |
配置语法
| 命令 | 说明 |
|---|---|
admin@DELLSONiC:~$ sonic-cli |
进入戴尔管理命令行界面 |
DELLSONiC# configure terminal |
进入配置模式 |
DELLSONiC(config)# interface <Eth slot/port> |
配置接口 |
DELLSONiC(config)# interface range Eth <slot/port> |
(可选)您可以配置一系列接口。 |
DELLSONiC(config-if-EthX/X)# port-security violation protect |
设置在发生违规时要采取的措施。 |
DELLSONiC(config-if-EthX/X)# port-security maximum <number of mac address> |
设置此接口 上允许的最大安全 MAC 数 (1-4097) |
DELLSONiC(config-if-EthX/X)# port-security enable |
在接口级别启用端口安全性 |
DELLSONiC(config-if-EthX/X)# no port-security enable |
在接口级别禁用端口安全性 |
示例配置
假设我们在端口 Eth 1/1 中有两个 mac 地址学习。在端口以太网 1/1 上配置端口安全性之前(已屏蔽 MAC 地址)
DELLSONiC# show mac address-table interface Eth 1/1 ----------------------------------------------------------- VLAN MAC-ADDRESS TYPE INTERFACE ----------------------------------------------------------- 2500 XX:XX:XX:XX:XX:XX DYNAMIC Eth1/1 2500 YY:YY:YY:YY:YY:YY DYNAMIC Eth1/1 |
admin@DELLSONiC:~$ sonic-cli DELLSONiC# configure DELLSONiC(config)# interface Eth 1/1 DELLSONiC(config-if-Eth1/1)# port-security violation protect DELLSONiC(config-if-Eth1/1)# port-security maximum 1 DELLSONiC(config-if-Eth1/1)# port-security enable DELLSONiC(config-if-Eth1/1)# shutdown DELLSONiC(config-if-Eth1/1)# no shutdown DELLSONiC(config-if-Eth1/1)# end |
DELLSONiC# show mac address-table interface Eth 1/1 ----------------------------------------------------------- VLAN MAC-ADDRESS TYPE INTERFACE ----------------------------------------------------------- 2500 XX:XX:XX:XX:XX:XX DYNAMIC Eth1/1 |
验证
使用以下命令验证| 命令 | 说明 |
|---|---|
DELLSONiC# show port-security |
显示所有接口中的端口安全性 |
DELLSONiC# show port-security interface Eth <slot/port> |
显示特定接口中的端口安全性 |
DELLSONiC# show logging | grep "Port Mac Security violation" |
从日志中获取违规的 mac 地址的详细信息。 |
DELLSONiC# show port-security
Secure Port isEnabled MaxSecureAddr FdbCount ViolationCount SecurityAction
--------------------------------------------------------------------------------------------------
Eth1/1 Y 1 1 1 PROTECT |
DELLSONiC# show port-security interface Eth1/1 Interface : Eth1/1 Port MAC Security is Enabled : True Maximum allowed Secure MAC : 1 Action taken on Violation : PROTECT Total MAC address : 1 Security Violation Count : 1 |
DELLSONiC# show logging | grep "Port Mac Security violation" XXX XX XX:XX:XX.XXXXXXXXXXXX XXXX DELLSONiC WARNING syncd#syncd: :- port_mac_sec_add_mac: Port Mac Security violation by MAC YY:YY:YY:YY:YY:YY Port Eth1/1 |
Affected Products
Enterprise SONiC Distribution, PowerSwitch E3200-ON Series, Dell EMC Networking N3200-ON, PowerSwitch S5212F-ON, PowerSwitch S5224F-ON, PowerSwitch S5232F-ON, PowerSwitch S5248F-ON, PowerSwitch S5296F-ON, PowerSwitch Z9264F-ON, PowerSwitch Z9332F-ON
, PowerSwitch Z9432F-ON
...
Article Properties
Article Number: 000218833
Article Type: How To
Last Modified: 27 Jun 2025
Version: 3
Find answers to your questions from other Dell users
Support Services
Check if your device is covered by Support Services.