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 中不支援連接埠安全性
  • 設定為交換埠的乙太網路連接埠和連接埠通道支援連接埠安全性。
  • 非交換器連接埠不支援連接埠安全性。  

設定連接埠中允許的最大 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

預設值

連接埠上的連接埠安全性 已停用
每個連接埠的最大 MAC 位址數 1
違規模式 保護

組態語法

命令 說明
admin@DELLSONiC:~$ sonic-cli
進入 Dell 管理命令行介面
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
讓我們將埠 Eth 1/1 配置為不允許超過一個 MAC 位址。
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
配置埠安全性后,我們可以看到只學習了一個 mac 位址。學習第一個接收的幀 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             

確認

使用下列命令進行驗證 
命令 說明
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
記錄訊息 (日期/時間和 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

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.