Dell Networking SONiC:如何建立 VLAN 並將其指派至中繼和存取交換器連接埠

摘要: 本文說明如何建立 VLAN 並將其指派至中繼和存取交換器連接埠。本文使用執行 Dell SONiC 4.1 的交換器。

本文章適用於 本文章不適用於 本文無關於任何特定產品。 本文未識別所有產品版本。

說明

我們使用標準介面命名來演示概念。請參閱文章 Dell Networking S 系列:基本介面組態 - SONiC 4.0 ,以取得有關介面命名的詳細資訊


目錄

  1. 簡介
  2. 建立 VLAN
  3. 建立一系列 VLAN
  4. 將介面設定為存取連接埠
  5. 將介面設定為中繼連接埠
  6. 從介面移除 VLAN
  7. 設定 IP 位址和 MTU


 

簡介

虛擬區域網路 (VLAN) 是邏輯介面。它允許一組設備進行通信,就像它們處於同一網路中一樣,獨立於物理位置。
實體介面和連接埠通道可為 Vlan 的成員。VLAN 範圍為 1 至 4094。

記憶要點

  • 保留的 VLAN

Dell Enterprise SONiC 會保留 128 個 VLAN 以供各種通訊協定使用。這是從 4.0 及更高版本中實現的。根據預設,SONiC 4.0 的保留 VLAN 範圍為 3967 - 4094。您可以變更保留的 vlan 範圍。

請參閱文章 Dell Networking Enterprise SONiC 保留 VLAN,以取得保留 VLAN 的詳細資訊。

  • 交換器設定檔
    • Dell SONiC 中的預設交換器設定檔為 L3,且沒有任何 VLAN。指派連接埠至 VLAN 之前,我們必須先建立 VLAN。
    • L2 設定檔具有預設 VLAN 1,所有連接埠預設都指派給此 VLAN 1。

如需 L2 和 L3 交換器設定檔的詳細資訊,請參閱文章 Dell Networking SONiC 作業系統 L2 與 L3 交換器設定檔

 

建立 VLAN

組態語法

組態

說明

admin@DELLSONiC:~$ sonic-cli

進入 Dell 管理框架 CLI

DELLSONiC# configure terminal

進入組態模式

DELLSONiC(config)# interface Vlan <Vlan ID>

建立 VLAN

DELLSONiC(config)# no interface Vlan <Vlan ID> 

移除 VLAN。


建立一系列 VLAN
 

組態

說明

DELLSONiC# configure terminal

進入組態模式

DELLSONiC(config)# interface range create Vlan <Vlan ID-Vlan ID>

建立 VLAN 範圍

DELLSONiC(config)# no interface Vlan <Vlan ID-Vlan ID>

移除一系列 VLAN。



範例組態
我們會在交換器上設定 VLAN 10
 

admin@DELLSONiC:~$ sonic-cli 
DELLSONiC# configure terminal 
DELLSONiC(config)# interface Vlan 10 
DELLSONiC(config-if-Vlan10)# end


使用以下命令來確認 VLAN 是否已建立。

show Vlan 


範例輸出

DELLSONiC# show Vlan
Q: A - Access (Untagged), T - Tagged
NUM        Status      Q Ports            Autostate   Dynamic
10         Inactive                       Enable


 

建立一系列 VLAN

組態

說明

DELLSONiC# configure terminal

進入組態模式

DELLSONiC(config)# interface range create Vlan <Vlan ID-Vlan ID>

建立 VLAN 範圍

DELLSONiC(config)# no interface Vlan <Vlan ID-Vlan ID>

移除一系列 VLAN。


範例組態

建立 Vlan 30-40 的範圍

admin@sonic:~$ sonic-cli
DELLSONiC# configure
DELLSONiC(config)# interface range create Vlan 30-40
DELLSONiC(config-if-range-vl**)# exit
DELLSONiC(config)# exit
DELLSONiC# show Vlan
Q: A - Access (Untagged), T - Tagged
NUM        Status      Q Ports            Autostate   Dynamic
30         Inactive                        Enable
31         Inactive                        Enable
32         Inactive                        Enable
33         Inactive                        Enable
34         Inactive                        Enable
35         Inactive                        Enable
36         Inactive                        Enable
37         Inactive                        Enable
38         Inactive                        Enable
39         Inactive                        Enable
40         Inactive                        Enable
DELLSONiC#

 
來卸下 VLAN 30-40

DELLSONiC# configure
DELLSONiC(config)# no interface Vlan 30-40
DELLSONiC(config)# end


 

將介面配置為接入埠。

存取連接埠僅允許單一 VLAN。對 VLAN 流量的訪問未標識。

組態語法

組態

說明

DELLSONiC# configure

進入組態模式

DELLSONiC(config)# interface Ethernet <Number>

設定介面

DELLSONiC(conf-if-Ethernet/PoX)# switchport access Vlan X

指派連接埠作為 VLAN 的存取連接埠。

DELLSONiC(conf-if-Ethernet/PoX)# no switchport access vlan

從連接埠移除存取 VLAN。


範例組態
假設我們必須將埠乙太網 1/1 指定為 VLAN 10 的存取埠。下面是範例配置。

 

DELLSONiC# configure
DELLSONiC(config)# interface Eth 1/1
DELLSONiC(config-if-Eth1/1)# switchport access Vlan 10
DELLSONiC(config-if-Eth1/1)# end
DELLSONiC#


使用以下命令驗證組態。

show Vlan 

And 

show run interface <interface number>


範例輸出
 

DELLSONiC# show Vlan
Q: A - Access (Untagged), T - Tagged
NUM        Status      Q Ports            Autostate   Dynamic
10         Inactive    A  Eth1/1           Enable      No
DELLSONiC# show running-configuration interface Eth 1/1
!
interface Eth1/1
mtu 9100
no shutdown
switchport access Vlan 10


 

將介面設定為中繼連接埠。

中繼連接埠可以有多個已標記 VLAN 和一個未標記 VLAN (原生 VLAN)。

記憶要點

  • 必須先建立 VLAN,才能指派至介面
  • 無法在一個介面中標記和取消標記相同的 VLAN
  • 介面中只能指派一個存取或未標記的 VLAN (原生 VLAN)。 
  • 您可以使用以下命令將 VLAN 新增至介面中的現有 VLAN。
 
switchport trunk allowed VLAN add <Vlan id/Range of vlan>
 

警示:交換器連接埠中繼允許 VLAN <Vlan id/vlan> 範圍命令會使用指定的 VLAN 重寫介面中現有的所有 VLAN。請謹慎使用此命令。

組態語法

組態

說明

DELLSONiC# configure

進入組態模式

DELLSONiC(config)# interface Ethernet/Portchannel <number>

設定介面

DELLSONiC(conf-if-Ethernet/PoX)# switchport trunk allowed VLAN add <Vlan id/Range of vlan> 

允許 VLAN 或一系列 VLAN 至中繼連接埠。若要指定 VLAN 範圍,請使用 <1..4094> (-) 或 (,) 分隔的個別 VLAN ID 和 VLAN ID 範圍;例如 20,70-100,142

DELLSONiC(conf-if-Ethernet/PoX)#switchport trunk allowed Vlan all

允許所有 VLAN (選用)。

DELLSONiC(conf-if-Ethernet/PoX)#switchport trunk allowed Vlan <Vlan id/Range of vlan>

(選用。請小心使用) 重寫介面中所有現有的 VLAN 組態,並允許指定的 VLAN/範圍的 VLAN。 

DELLSONiC(conf-if-Ethernet/PoX)# switchport access Vlan <Vlan id>

指派未標記的 VLAN 至連接埠 (原生 VLAN) (選用)。


範例組態
我們會將已標記的 VLAN 10 和 VLAN 20 指派為乙太網路 1/1 介面上的存取連接埠 (未標記的原生 VLAN)。下面是範例配置。

DELLSONiC# configure
DELLSONiC(config)# interface Eth 1/1
DELLSONiC(config-if-Eth1/1)# switchport trunk allowed Vlan add 10
DELLSONiC(config-if-Eth1/1)# switchport access Vlan 20
DELLSONiC(config-if-Eth1/1)# end


使用以下命令驗證配置。
 

show vlan and show run interface <interface id>


範例輸出

DELLSONiC# show Vlan
Q: A - Access (Untagged), T - Tagged
NUM        Status      Q Ports            Autostate   Dynamic
10         Inactive    T  Eth1/1           Enable      No
20         Inactive    A  Eth1/1           Enable      No​​
DELLSONiC# show running-configuration interface Eth 1/1
!
interface Eth1/1
mtu 9100
no shutdown
switchport access Vlan 20
switchport trunk allowed Vlan 10
DELLSONiC#


 

從介面移除 VLAN。

組態語法

組態

說明

DELLSONiC# configure

進入組態模式

DELLSONiC(config)# interface Ethernet/Portchannel <number>

設定介面

DELLSONiC(conf-if-Ethernet/PoX)# switchport trunk allowed Vlan remove <Vlan id/range> 

從中繼連接埠移除 VLAN 或 VLAN 範圍。若要指定 VLAN 範圍,請使用 <1..4094> (-) 或 (,) 分隔的個別 VLAN ID 和 VLAN ID 範圍;例如 20,70-100,142

DELLSONiC(conf-if-Ethernet/PoX)# no switchport access Vlan

從中繼連接埠移除未標記 (存取)。


範例組態

DELLSONiC# configure
DELLSONiC(config)# interface Eth 1/1
DELLSONiC(config-if-Eth1/1)# switchport trunk allowed Vlan remove 10
DELLSONiC(config-if-Eth1/1)# no switchport access Vlan
DELLSONiC(config-if-Eth1/1)# end


 

設定 IP 位址和 MTU。

根據預設,VLAN 位於第二層或更多層。它沒有 IPv4 和 IPv6 位址。我們可以手動將 IPv4 或 IPv6 位址指派給 VLAN。

記憶要點

  • 請先在 VLAN 成員上設定 MTU,再設定 VLAN MTU。VLAN 的所有成員都必須具有相同的 MTU 值。標記成員的連結 MTU 必須比未標記成員高 4 位元組才能用於數據包標記。
  • 您可以在一個介面上設定多個 IPv6 位址。
  • 您可以在 VLAN 中設定次要 IP 位址


組態語法

組態

說明

DELLSONiC# configure

進入組態模式

DELLSONiC(config)# interface Vlan <ID>

設定介面

DELLSONiC(conf-if-VlanX)#ip address <IP address/mask>

新增 IP 位址。

DELLSONiC(conf-if-VlanX)#no ip address

移除 IP 位址。

DELLSONiC(conf-if-VlanX)#ipv6 address <ipv6–address/prefix-length>

新增 IPv6 位址

DELLSONiC(conf-if-VlanX)#no ipv6 address

移除 IPv6 位址。

DELLSONiC(conf-if-VlanX)#mtu <MTU ID>

變更 MTU (1312 至 9216)。預設值:9100


範例組態
 

DELLDELLSONiC# configure
DELLSONiC(config)# interface Vlan 10
DELLSONiC(conf-if-Vlan10)# mtu 1500
DELLSONiC(conf-if-Vlan10)# ip address 10.0.0.1/24
DELLSONiC(conf-if-Vlan10)# ipv6 address a::b/64
DELLSONiC(conf-if-Vlan10)# end


使用以下命令驗證配置。

show interface vlan <vlan id>


範例輸出

DELLSONiC# show interface Vlan 10
Vlan10 is up, line protocol is down
Hardware is Vlan, address is 0c:6e:4a:87:00:0a
IPV4 address is 10.0.0.2/24
Mode of IPV4 address assignment: MANUAL
IPV6 address is a::b/64,fe80::e6e:4aff:fe87:a/64
Mode of IPV6 address assignment: MANUAL
IP MTU 1500 bytes
Time since last interface status change: 01:28:39

受影響的產品

Enterprise SONiC Distribution, PowerSwitch S6000 ON, PowerSwitch E3200-ON Series, Dell EMC Networking N3200-ON, PowerSwitch S5224F-ON, PowerSwitch S5232F-ON, PowerSwitch S6100-ON, PowerSwitch Z9100-ON, PowerSwitch Z9264F-ON, PowerSwitch Z9332F-ON
文章屬性
文章編號: 000217901
文章類型: How To
上次修改時間: 29 9月 2023
版本:  6
向其他 Dell 使用者尋求您問題的答案
支援服務
檢查您的裝置是否在支援服務的涵蓋範圍內。