Layer 2 Switching and VLANs · Topic 2 of 4
VLAN Ports, Tagging, Native VLANs and Voice VLANs
Learn Junos access and trunk ports, 802.1Q tagging, native-vlan-id, and how switch-options voip and LLDP MED place IP phones in a voice VLAN.
- 5 min
- Access ports are untagged and carry one VLAN; trunk ports carry several tagged VLANs.
- The 802.1Q tag is 4 bytes, with a 12 bit VLAN ID. Usable IDs are 1 to 4094.
- In ELS, use
interface-modeandvlan members.port-modeis the older syntax.
What it is
A VLAN splits one physical switch into several broadcast domains. Junos switches support two port modes for carrying VLANs. An access port belongs to one VLAN and sends and receives untagged frames. A trunk port carries several VLANs on one link and marks each frame with an 802.1Q tag.
The native VLAN is the VLAN that a trunk uses for untagged frames. A voice VLAN is a separate VLAN for IP phones, so voice traffic can be kept apart from the data VLAN on the same access port.
How it works
Access and trunk ports
| Access port | Trunk port | |
|---|---|---|
| Connects to | End host, printer, server | Another switch or router |
| VLANs | One | Several |
| Frames sent | Untagged | Tagged, except the native VLAN |
| ELS setting | interface-mode access | interface-mode trunk |
user@switch# set vlans SALES vlan-id 10
user@switch# set vlans ENG vlan-id 20
user@switch# set interfaces ge-0/0/1 unit 0 family ethernet-switching interface-mode access
user@switch# set interfaces ge-0/0/1 unit 0 family ethernet-switching vlan members SALES
user@switch# set interfaces ge-0/0/24 unit 0 family ethernet-switching interface-mode trunk
user@switch# set interfaces ge-0/0/24 unit 0 family ethernet-switching vlan members [ SALES ENG ]
In the ELS syntax the mode is interface-mode. Older non-ELS software used port-mode under family ethernet-switching, so an exam option using port-mode belongs to the older style.
The 802.1Q tag
The tag adds 4 bytes to the Ethernet frame, so a tagged frame can be up to 1522 bytes with the standard 1500 byte payload.
| Field | Size | Purpose |
|---|---|---|
| TPID | 16 bits | Tag protocol identifier, 0x8100 |
| PCP | 3 bits | Priority code point, used for class of service |
| DEI | 1 bit | Drop eligible indicator |
| VID | 12 bits | VLAN ID |
A 12 bit VLAN ID gives 4096 values. Values 0 and 4095 are reserved, so the usable range is 1 to 4094.
The tag sits between the source address and the type field. Because the frame changes, the switch recalculates the frame check sequence when it adds or removes a tag.
Native VLAN
A trunk can carry one VLAN untagged. In ELS you set it on the physical interface, not on the logical unit.
user@switch# set interfaces ge-0/0/24 native-vlan-id 99
user@switch# set vlans MGMT vlan-id 99
Untagged frames arriving on the trunk are placed in the native VLAN, and frames of that VLAN leave the trunk untagged. If a trunk has no native-vlan-id, untagged frames received on it are dropped.
Both ends must use the same native VLAN. If one side uses 99 and the other uses 1, untagged traffic from one VLAN lands in a different VLAN on the other switch.
native-vlan-id is a statement on the physical interface (ge-0/0/24), not under unit 0 family ethernet-switching. An option that puts it elsewhere is for another syntax.
Voice VLANs
An IP phone usually has a PC plugged into it, and both share one switch port. The phone tags its own traffic with the voice VLAN ID, and the PC sends untagged frames that go to the data VLAN of the port.
user@switch# set vlans VOICE vlan-id 30
user@switch# set switch-options voip interface ge-0/0/1.0 vlan VOICE
user@switch# set protocols lldp-med interface ge-0/0/1
The port stays an access port with the data VLAN as its member. The voip statement adds the voice VLAN to it. The switch can then tell the phone the VLAN ID using LLDP MED, the media endpoint extension of LLDP. The phone learns the voice VLAN, tags its frames and applies the right priority.
Checking VLANs and ports
user@switch> show vlans
user@switch> show ethernet-switching interface ge-0/0/1
show vlans lists each VLAN, its tag and its member interfaces. An asterisk after an interface name means the interface is up.
When the tag is the same on both ends of a link but traffic still fails, check whether the VLAN exists on both switches. A tagged frame for a VLAN that is not configured on the receiving switch is dropped.
Common mistakes
Using an access port to connect switches. An access port carries one VLAN untagged, so it cannot extend several VLANs between switches.
Native VLAN mismatch. The two ends of a trunk disagree on the untagged VLAN, and frames leak between VLANs.
Forgetting to create the VLAN. A VLAN used in vlan members must be defined under vlans with a name and an ID.
Removing the native VLAN by accident. With no native-vlan-id, untagged frames on a trunk are dropped.
What to remember for the exam
- Access ports are untagged and carry one VLAN; trunk ports carry several tagged VLANs.
- The 802.1Q tag is 4 bytes, with a 12 bit VLAN ID. Usable IDs are 1 to 4094.
- In ELS, use
interface-modeandvlan members.port-modeis the older syntax. native-vlan-idgoes on the physical interface and both trunk ends must match.- A trunk without a native VLAN drops untagged frames.
switch-options voipplaces a phone's tagged voice VLAN on an access port; LLDP MED tells the phone which VLAN to use.show vlansandshow ethernet-switching interfaceverify membership.
Check yourself
How many bytes does an 802.1Q tag add, and which VLAN IDs can you use?
It adds 4 bytes, and the usable VLAN IDs are 1 to 4094.
A trunk port has no
native-vlan-idconfigured. What happens to untagged frames it receives?They are dropped.
How does an IP phone learn the voice VLAN ID on a Junos switch?
Through LLDP MED, after the VLAN is bound to the port with
switch-options voip.
Topic 2 of 4 in Layer 2 Switching and VLANs
Test yourself on Layer 2 Switching and VLANs
The full Juniper JNCIS-ENT JN0-352 question bank has 846 questions, with timed practice exams and an explanation for every answer.
This study guide is independent and is not affiliated with, endorsed by, or sponsored by Juniper. Vendor names, certification names and exam codes are trademarks of their respective owners and are used for identification only.