Dell Networking SONiC:如何创建 VLAN 并将其分配给中继和接入交换机端口

Summary: 本文介绍如何创建 VLAN 并将其分配给中继和接入交换机端口。本文使用的是运行 Dell SONiC 4.1 的交换机。

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 ,了解有关接口命名的更多信息


目录

  1. 简介
  2. 创建 VLAN
  3. 创建 VLAN 范围
  4. 将接口配置为访问端口
  5. 将接口配置为中继端口
  6. 从接口中删除 VLAN
  7. 配置 IP 地址和 MTU


 

简介

虚拟局域网 (VLAN) 是逻辑接口。它允许一组设备进行通信,就好像它们位于同一网络中一样,与物理位置无关。
物理接口和 PortChannel 可以是 VLAN 的成员。VLAN 范围为 1-4094。

需要记住的要点

  • 保留 VLAN

Dell Enterprise SONiC 保留 128 个 VLAN 以用于各种协议。这是从 4.0 及更高版本实现的。默认情况下,SONiC 4.0 的保留 VLAN 范围为 3967 - 4094。您可以更改保留的 vlan 范围。

有关保留 VLAN 的更多信息,请参阅文章 Dell Networking Enterprise SONiC 保留 VLAN

  • 交换机配置文件
    • Dell SONiC 中的默认交换机配置文件是 L3,没有任何 VLAN。我们必须先创建 VLAN,然后再将端口分配给 VLAN。
    • L2 配置文件具有默认 VLAN 1,并且所有端口默认分配给此 VLAN 1。

有关 L2 和 L3 交换机配置文件的更多信息,请参阅文章 Dell Networking SONiC作系统 L2 和 L3 交换机配置文件

 

创建 VLAN

配置语法

配置

说明

admin@DELLSONiC:~$ sonic-cli

进入戴尔管理框架 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。


示例配置

Lets Create range of Vlans 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 添加到接口中的现有 VLAN。
 
switchport trunk allowed VLAN add <Vlan id/Range of vlan>
 

注意:命令 switchport trunk allowed 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)(可选)。


示例配置
让我们在以太网 1/1 接口上将已标记的 VLAN 10 和 VLAN 20 分配为接入端口(未标记的本机 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 地址。我们可以手动为 VLAN 分配 IPv4 或 IPv6 地址。

需要记住的要点

  • 在配置 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

Affected Products

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
Article Properties
Article Number: 000217901
Article Type: How To
Last Modified: 29 Sep 2023
Version:  6
Find answers to your questions from other Dell users
Support Services
Check if your device is covered by Support Services.