Junos VLAN Configuration: Access, Trunk and IRB with Examples - 夜莺博客

Junos VLAN Configuration: Access, Trunk and IRB with Examples

Junos VLAN configuration on modern EX/QFX switches follows the Enhanced Layer 2 Software (ELS) style: you define the VLAN at the vlans hierarchy, assign interfaces with family ethernet-switching, and create Layer 3 gateways with IRB interfaces. This guide walks through a complete lab setup — two switches, two VLANs, access and trunk ports, and IRB routing — with every set command plus the verification commands that prove it works.

Basic VLAN Configuration

Define the VLAN

set vlans <VLAN Name> vlan-id <VLAN Number>
set vlans <VLAN Name> description <VLAN Description>

Configure an Access Port

set interfaces <Interface> unit 0 family ethernet-switching interface-mode access
set interfaces <Interface> unit 0 family ethernet-switching vlan members <VLAN Name or ID>

An interface with family ethernet-switching defaults to access mode if no interface-mode is set — adding it explicitly is clearer.

Configure a Trunk Port

set interfaces <Interface> unit 0 family ethernet-switching interface-mode trunk
set interfaces <Interface> unit 0 family ethernet-switching vlan members [ <VLAN1> <VLAN2> ]

Trunk members can be added one at a time, as a range, or as a space-separated list in square brackets.

Configure the IRB (Layer 3) Interface

Create the IRB unit (making the unit number match the VLAN ID helps), then bind it to the VLAN with l3-interface:

set interfaces irb unit <Unit Number> family inet address <IP Address/Netmask>
set vlans <VLAN Name> l3-interface irb.<Unit Number>

Verification Commands

show vlans brief
show ethernet-switching interface
show ethernet-switching interface <Interface>

show vlans brief confirms the VLAN exists and shows member interfaces; show ethernet-switching interface shows each logical interface's mode and VLAN membership.

Lab Example

In the reference lab (a vEX running Junos 23.1R1 and a vQFX running 21.3R3), VLAN 10 uses subnet 192.168.10.0/24 and VLAN 20 uses 192.168.20.0/24, each with two clients. The IRB interfaces act as the default gateways for each VLAN, and inter-VLAN routing happens on the switch itself — the same role as an SVI on Cisco or a VLAN interface on Huawei.

Related Junos Content on This Site

Start with Juniper EX initial setup commands, troubleshoot Layer 2 with Junos SRX LAN troubleshooting (IRB/ARP), or compare with Huawei S5700 VLAN partitioning.

原文链接:https://www.networkcuriosity.com/junos-vlan-configuration