示例:在 QFX 系列交换机上配置具有辅助 VLAN 中继端口和混合接入端口的 PVLAN
此示例说明如何将辅助 VLAN 中继端口和混合接入端口配置为专用 VLAN 配置的一部分。辅助 VLAN 中继端口承载辅助 VLAN 流量。
此示例将 Junos OS 用于不支持增强型第 2 层软件 (ELS) 配置样式的交换机。有关 ELS 的详细信息,请参阅 使用增强型第 2 层软件 CLI。
对于给定的专用 VLAN,辅助 VLAN 中继端口只能传输一个辅助 VLAN 的流量。但是,只要每个辅助 VLAN 都是不同专用(主)VLAN 的成员,辅助 VLAN 中继端口就可以承载多个辅助 VLAN 的流量。例如,辅助 VLAN 中继端口可以传输属于主 VLAN pvlan100 的社区 VLAN 的流量,也可以传输属于主 VLAN pvlan400 的隔离 VLAN 的流量。
要将中继端口配置为承载辅助 VLAN 流量,请使用隔离和interface语句,如交换机 1 的步骤和13示例配置中12所示。
当流量从辅助 VLAN 中继端口出口时,它通常带有辅助端口所属的主 VLAN 的标记。如果您希望从辅助 VLAN 中继端口出口的流量保留其辅助 VLAN 标记,请使用 扩展辅助 vlan-id 语句。
混合接入端口承载未标记的流量,并且只能是一个主 VLAN 的成员。在混合接入端口上进入的流量将被转发到辅助 VLAN 的端口,这些辅助 VLAN 是混合接入端口所属的主 VLAN 的成员。如果辅助 VLAN 端口是中继端口,则此流量从辅助 VLAN 端口出口时会携带相应的辅助 VLAN 标记。
要将接入端口配置为混合端口,请使用 混合 语句,如交换机 2 的示例配置步骤所示 12 。
如果流量在辅助 VLAN 端口上入口,而在混合接入端口上出口,则流量在出口处未标记。如果标记的流量入口位于混合接入端口上,则该流量将被丢弃。
要求
此示例使用以下硬件和软件组件:
两个 QFX 设备
适用于 QFX 系列的 Junos OS 12.2 或更高版本
概述和拓扑
图 1 显示了此示例中使用的拓扑。交换机 1 包括多个主专用和辅助专用 VLAN,还包括两个辅助 VLAN 中继端口,这些端口配置为承载属于主 VLAN pvlan100 和 pvlan400 的辅助 VLAN。
交换机 2 包含相同的专用 VLAN。该图显示了交换机 2 上配置了混合接入端口或混合中继端口的 xe-0/0/0。此处包含的示例配置将此端口配置为混合访问端口。
该图还显示了流量进入交换机 1 上的辅助 VLAN 中继端口后的流动方式。

| 元件 | Description |
|---|---|
pvlan100,ID 100 |
主 VLAN |
pvlan400,ID 400 |
主 VLAN |
comm300,ID 300 |
社区 VLAN,pvlan100 成员 |
comm600, ID 600 |
社区 VLAN,pvlan400 成员 |
隔离 VLAN ID 200 |
隔离 VLAN 的 VLAN ID,pvlan100 的成员 |
隔离 – VLAN-ID 500 |
隔离 VLAN 的 VLAN ID,pvlan400 的成员 |
xe-0/0/0.0 |
用于主 VLAN pvlan100 和 pvlan400 的辅助 VLAN 中继端口 |
xe-0/0/1.0 |
用于主 VLAN 的 PVLAN 中继端口 pvlan100 和 pvlan400 |
xe-0/0/2.0 |
用于 pvlan100 的隔离接入端口 |
xe-0/0/3.0 |
comm300 的社区接入端口 |
xe-0/0/5.0 |
用于 pvlan400 的隔离接入端口 |
xe-0/0/6.0 |
用于 comm600 的社区中继端口 |
| 元件 | Description |
|---|---|
pvlan100,ID 100 |
主 VLAN |
pvlan400,ID 400 |
主 VLAN |
comm300,ID 300 |
社区 VLAN,pvlan100 成员 |
comm600, ID 600 |
社区 VLAN,pvlan400 成员 |
隔离 VLAN ID 200 |
隔离 VLAN 的 VLAN ID,pvlan100 的成员 |
隔离 – VLAN-ID 500 |
隔离 VLAN 的 VLAN ID,pvlan400 的成员 |
xe-0/0/0.0 |
主 VLAN 的混合接入端口 pvlan100 |
xe-0/0/1.0 |
用于主 VLAN 的 PVLAN 中继端口 pvlan100 和 pvlan400 |
xe-0/0/2.0 |
隔离 VLAN 的辅助中继端口,pvlan100 的成员 |
xe-0/0/3.0 |
comm300 的社区接入端口 |
xe-0/0/5.0 |
用于 pvlan400 的隔离接入端口 |
xe-0/0/6.0 |
comm600 的社区接入端口 |
在交换机 1 上配置 PVLAN
CLI 快速配置
要在交换机 1 上快速创建和配置 PVLAN,请复制以下命令并将其粘贴到交换机终端窗口中:
[edit] set interfaces xe-0/0/0 unit 0 family ethernet-switching port-mode trunk set interfaces xe-0/0/1 unit 0 family ethernet-switching port-mode trunk set interfaces xe-0/0/1 unit 0 family ethernet-switching vlan members pvlan100 set interfacesxe-0/0/1 unit 0 family ethernet-switching vlan members pvlan400 set interfaces xe-0/0/2 unit 0 family ethernet-switching port-mode access set interfaces xe-0/0/3 unit 0 family ethernet-switching port-mode access set interfaces xe-0/0/5 unit 0 family ethernet-switching port-mode access set interfaces xe-0/0/6 unit 0 family ethernet-switching port-mode trunk set vlans pvlan100 vlan-id 100 set vlans pvlan400 vlan-id 400 set vlans pvlan100 pvlan set vlans pvlan400 pvlan set vlans pvlan100 interface xe-0/0/1.0 pvlan-trunk set vlans pvlan400 interface xe-0/0/1.0 pvlan-trunk set vlans comm300 vlan-id 300 set vlans comm300 primary-vlan pvlan100 set vlans comm300 interface xe-0/0/3.0 set vlans comm600 vlan-id 600 set vlans comm600 primary-vlan pvlan400 set vlans comm600 interface xe-0/0/6.0 set vlans pvlan100 pvlan isolation-vlan-id 200 set vlans pvlan400 pvlan isolation-vlan-id 500 set vlans pvlan100 interface xe-0/0/0.0 isolated set vlans pvlan400 interface xe-0/0/0.0 isolated set vlans comm600 interface xe-0/0/0.0 set vlans pvlan100 interface xe-0/0/2.0 isolated set vlans pvlan400 interface xe-0/0/5.0 isolated
程序
分步过程
要配置专用 VLAN 和辅助 VLAN 中继端口,请执行以下操作:
配置接口和端口模式:
[edit interfaces] user@switch# set xe-0/0/0 unit 0 family ethernet-switching port-mode trunk user@switch# set xe-0/0/1 unit 0 family ethernet-switching port-mode trunk user@switch# set xe-0/0/1 unit 0 family ethernet-switching vlan members pvlan100 user@switch# set xe-0/0/1 unit 0 family ethernet-switching vlan members pvlan400 user@switch# set xe-0/0/2 unit 0 family ethernet-switching port-mode access user@switch# set xe-0/0/3 unit 0 family ethernet-switching port-mode access user@switch# set xe-0/0/5 unit 0 family ethernet-switching port-mode access user@switch# set xe-0/0/6 unit 0 family ethernet-switching port-mode access
创建主 VLAN:
[edit vlans] user@switch# set pvlan100 vlan-id 100 user@switch# set pvlan400 vlan-id 400
注:主 VLAN 必须始终是标记的 VLAN,即使它们仅存在于一台设备上也是如此。
将主 VLAN 配置为专用:
[edit vlans] user@switch# set pvlan100 pvlan user@switch# set pvlan400 pvlan
配置 PVLAN 中继端口以在交换机之间传输专用 VLAN 流量:
[edit vlans] user@switch# set pvlan100 interface xe-0/0/1.0 pvlan-trunk user@switch# set pvlan400 interface xe-0/0/1.0 pvlan-trunk
创建 VLAN ID 为 300 的辅助 VLAN 通信 300:
[edit vlans] user@switch# set comm300 vlan-id 300
为 comm300 配置主 VLAN:
[edit vlans] user@switch# set comm300 primary-vlan pvlan100
配置 comm300 的接口:
[edit vlans] user@switch# set comm300 interface xe-0/0/3.0
创建 VLAN ID 为 600 的辅助 VLAN 通信 600:
[edit vlans] user@switch# set comm600 vlan-id 600
为 comm600 配置主 VLAN:
[edit vlans] user@switch# set comm600 primary-vlan pvlan400
配置 comm600 接口:
[edit vlans] user@switch# set comm600 interface xe-0/0/6.0
配置交换机间隔离 VLAN:
[edit vlans] user@switch# set pvlan100 pvlan isolation-vlan-id 200 user@switch# set pvlan400 pvlan isolation-vlan-id 500
注:将辅助 VLAN 中继端口配置为承载隔离 VLAN 时,还必须配置 隔离 VLAN ID。即使隔离的 VLAN 仅存在于一台交换机上,也是如此。
启用中继端口 xe-0/0/0 以承载主 VLAN 的辅助 VLAN:
[edit vlans] user@switch# set pvlan100 interface xe-0/0/0.0 isolated user@switch# set pvlan400 interface xe-0/0/0.0 isolated
将中继端口 xe-0/0/0 配置为承载 comm600(pvlan400 的成员):
[edit vlans] user@switch# set comm600 interface xe-0/0/0.0
注:您无需显式配置 xe-0/0/0 来传输隔离 VLAN 流量(标记 200 和 500),因为 pvlan100 和 pvlan400 中的所有隔离端口(包括 xe-0/0/0.0)都会自动包含在您配置
isolation-vlan-id 200和isolation-vlan-id 500时创建的隔离 VLAN 中。将 xe-0/0/2 和 xe-0/0/6 配置为隔离:
[edit vlans] user@switch# set pvlan100 interface xe-0/0/2.0 isolated user@switch# set pvlan400 interface xe-0/0/5.0 isolated
结果
检查交换机 1 上的配置结果:
[edit]
user@switch# show
interfaces {
xe-0/0/0 {
unit 0 {
family ethernet-switching {
port-mode trunk;
vlan {
members pvlan100;
members pvlan400;
}
}
}
}
xe-0/0/1 {
unit 0 {
family ethernet-switching {
port-mode trunk;
vlan {
members pvlan100;
members pvlan400;
}
}
}
}
xe-0/0/2 {
unit 0 {
family ethernet-switching {
port-mode access;
}
}
}
xe-0/0/3 {
unit 0 {
family ethernet-switching {
port-mode access;
}
}
}
xe-0/0/5 {
unit 0 {
family ethernet-switching {
port-mode access;
}
}
}
xe-0/0/6 {
unit 0 {
family ethernet-switching {
port-mode trunk;
}
}
}
}
vlans {
comm300 {
vlan-id 300;
interface {
xe-0/0/3.0;
}
primary-vlan pvlan100;
}
comm600 {
vlan-id 600;
interface {
xe-0/0/6.0;
}
primary-vlan pvlan400;
}
pvlan100 {
vlan-id 100;
interface {
xe-0/0/0.0;
xe-0/0/2.0;
xe-0/0/3.0;
xe-0/0/1.0 {
pvlan-trunk;
}
}
no-local-switching;
isolation-id 200;
}
pvlan400 {
vlan-id 400;
interface {
xe-0/0/0.0;
xe-0/0/5.0;
xe-0/0/6.0;
xe-0/0/1.0 {
pvlan-trunk;
}
}
no-local-switching;
isolation-id 500;
}
}
在交换机 2 上配置 PVLAN
交换机 2 的配置与交换机 1 的配置几乎相同。最显著的区别是交换机 2 上的 xe-0/0/0 配置为混合中继端口或混合接入端口,如下所示 图 1 。在以下配置中,xe-0/0/0 配置为主 VLAN pvlan100 的混合接入端口。
如果流量在启用 VLAN 的端口上入口,出口在混合接入端口上,则 VLAN 标记将在出口处丢弃,此时流量将取消标记。例如,在交换机 1 上的 xe-0/0/0.0 上配置的辅助 VLAN 中继端口上的 comm600 入口流量,并在通过辅助 VLAN 转发时携带标记 600。当它从交换机 2 上的 xe-0/0/0.0 出口时,如果您将 xe-0/0/0.0 配置为混合接入端口(如此示例所示),则该端口将未标记。如果将 xe-0/0/0.0 配置为混合中继端口(端口模式中继),则 comm600 的流量在出口时会携带其主 VLAN 标记 (400)。
CLI 快速配置
要在交换机 2 上快速创建和配置 PVLAN,请复制以下命令并将其粘贴到交换机终端窗口中:
[edit] set interfaces xe-0/0/0 unit 0 family ethernet-switching port-mode access set interfaces xe-0/0/1 unit 0 family ethernet-switching port-mode trunk set interfaces xe-0/0/1 unit 0 family ethernet-switching vlan members pvlan100 set interfaces xe-0/0/1 unit 0 family ethernet-switching vlan members pvlan400 set interfaces xe-0/0/2 unit 0 family ethernet-switching port-mode trunk set interfaces xe-0/0/3 unit 0 family ethernet-switching port-mode access set interfaces xe-0/0/5 unit 0 family ethernet-switching port-mode access set interfaces xe-0/0/6 unit 0 family ethernet-switching port-mode access set vlans pvlan100 vlan-id 100 set vlans pvlan400 vlan-id 400 set vlans pvlan100 pvlan set vlans pvlan400 pvlan set vlans pvlan100 interface xe-0/0/1.0 pvlan-trunk set vlans pvlan400 interface xe-0/0/1.0 pvlan-trunk set vlans comm300 vlan-id 300 set vlans comm300 primary-vlan pvlan100 set vlans comm300 interface xe-0/0/3.0 set vlans comm600 vlan-id 600 set vlans comm600 primary-vlan pvlan400 set vlans comm600 interface xe-0/0/6.0 set vlans pvlan100 pvlan isolation-vlan-id 200 set vlans pvlan400 pvlan isolation-vlan-id 500 set vlans pvlan100 interface xe-0/0/0.0 promiscuous set vlans pvlan100 interface xe-0/0/2.0 isolated set vlans pvlan400 interface xe-0/0/5.0 isolated
程序
分步过程
要配置专用 VLAN 和辅助 VLAN 中继端口,请执行以下操作:
配置接口和端口模式:
[edit interfaces] user@switch# set xe-0/0/0 unit 0 family ethernet-switching port-mode access
user@switch# set xe-0/0/1 unit 0 family ethernet-switching port-mode trunk user@switch# set xe-0/0/1 unit 0 family ethernet-switching vlan members pvlan100 user@switch# set xe-0/0/1 unit 0 family ethernet-switching vlan members pvlan400 user@switch# set xe-0/0/2 unit 0 family ethernet-switching port-mode trunk user@switch# set xe-0/0/3 unit 0 family ethernet-switching port-mode access user@switch# set xe-0/0/5 unit 0 family ethernet-switching port-mode access user@switch# set xe-0/0/6 unit 0 family ethernet-switching port-mode access
创建主 VLAN:
[edit vlans] user@switch# set pvlan100 vlan-id 100 user@switch# set pvlan400 vlan-id 400
将主 VLAN 配置为专用:
[edit vlans] user@switch# set pvlan100 pvlan user@switch# set pvlan400 pvlan
配置 PVLAN 中继端口以在交换机之间传输专用 VLAN 流量:
[edit vlans] user@switch# set pvlan100 interface xe-0/0/1.0 pvlan-trunk user@switch# set pvlan400 interface xe-0/0/1.0 pvlan-trunk
创建 VLAN ID 为 300 的辅助 VLAN 通信 300:
[edit vlans] user@switch# set comm300 vlan-id 300
为 comm300 配置主 VLAN:
[edit vlans] user@switch# set comm300 primary-vlan pvlan100
配置 comm300 的接口:
[edit vlans] user@switch# set comm300 interface xe-0/0/3.0
创建 VLAN ID 为 600 的辅助 VLAN 通信 600:
[edit vlans] user@switch# set comm600 vlan-id 600
为 comm600 配置主 VLAN:
[edit vlans] user@switch# set comm600 primary-vlan pvlan400
配置 comm600 接口:
[edit vlans] user@switch# set comm600 interface xe-0/0/6.0
- 在交换机 1 上配置 PVLAN
配置交换机间隔离 VLAN:
[edit vlans] user@switch# set pvlan100 pvlan isolation-vlan-id 200 user@switch# set pvlan400 pvlan isolation-vlan-id 500
将接入端口 xe-0/0/0 配置为 pvlan100 的混合端口:
[edit vlans] user@switch# set pvlan100 interface xe-0/0/0.0 promiscuous
注:混合接入端口只能是一个主 VLAN 的成员。
将 xe-0/0/2 和 xe-0/0/6 配置为隔离:
[edit vlans] user@switch# set pvlan100 interface xe-0/0/2.0 isolated user@switch# set pvlan400 interface xe-0/0/5.0 isolated
结果
检查交换机 2 上的配置结果:
[edit]
user@switch# show
interfaces {
xe-0/0/0 {
unit 0 {
family ethernet-switching {
port-mode access;
vlan {
members pvlan100;
}
}
}
}
xe-0/0/1 {
unit 0 {
family ethernet-switching {
port-mode trunk;
vlan {
members pvlan100;
members pvlan400;
}
}
}
}
xe-0/0/2 {
unit 0 {
family ethernet-switching {
port-mode trunk;
}
}
}
xe-0/0/3 {
unit 0 {
family ethernet-switching {
port-mode access;
}
}
}
xe-0/0/5 {
unit 0 {
family ethernet-switching {
port-mode access;
}
}
}
xe-0/0/6 {
unit 0 {
family ethernet-switching {
port-mode access;
}
}
}
vlans {
comm300 {
vlan-id 300;
interface {
xe-0/0/3.0;
}
primary-vlan pvlan100;
}
comm600 {
vlan-id 600;
interface {
xe-0/0/6.0;
}
primary-vlan pvlan400;
}
pvlan100 {
vlan-id 100;
interface {
xe-0/0/0.0;
xe-0/0/2.0;
xe-0/0/3.0;
xe-0/0/1.0 {
pvlan-trunk;
}
}
no-local-switching;
isolation-id 200;
}
pvlan400 {
vlan-id 400;
interface {
xe-0/0/5.0;
xe-0/0/6.0;
xe-0/0/1.0 {
pvlan-trunk;
}
}
no-local-switching;
isolation-id 500;
}
}
验证
要确认配置工作正常,请执行以下任务:
验证是否已创建专用 VLAN 和辅助 VLAN
目的
验证是否已在交换机 1 上正确创建主 VLAN 和辅助 VLAN。
操作
show vlans使用以下命令:
user@switch> show vlans private-vlan Name Role Tag Interfaces pvlan100 Primary 100 xe-0/0/0.0, xe-0/0/1.0, xe-0/0/2.0, xe-0/0/3.0 __iso_pvlan100__ Isolated 200 xe-0/0/2.0 comm300 Community 300 xe-0/0/3.0 pvlan400 Primary 400 xe-0/0/0.0, xe-0/0/1.0, xe-0/0/5.0, xe-0/0/6.0 __iso_pvlan400__ Isolated 500 xe-0/0/5.0 comm600 Community 600 xe-0/0/6.0
意义
输出显示已创建专用 VLAN,并标识与其关联的接口和辅助 VLAN。
验证以太网交换表条目
目的
验证是否已为主 VLAN pvlan100 创建以太网交换表条目。
操作
显示 pvlan100 的以太网交换表条目。
user@switch> show ethernet-switching table vlan pvlan100 private-vlan Ethernet-switching table: 0 unicast entries pvlan100 * Flood - All-members pvlan100 00:10:94:00:00:02 Learn xe-0/0/2.0 __iso_pvlan100__ * Flood - All-members __iso_pvlan100__ 00:10:94:00:00:02 Replicated - xe-0/0/2.0