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
In a nutshell
  • 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-mode and vlan members. port-mode is 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.

PCuntaggedAccess portVLAN 10Trunk porttag 10 addedNeighbor switchVLAN 10

How it works

Access and trunk ports

Access portTrunk port
Connects toEnd host, printer, serverAnother switch or router
VLANsOneSeveral
Frames sentUntaggedTagged, except the native VLAN
ELS settinginterface-mode accessinterface-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.

FieldSizePurpose
TPID16 bitsTag protocol identifier, 0x8100
PCP3 bitsPriority code point, used for class of service
DEI1 bitDrop eligible indicator
VID12 bitsVLAN ID

A 12 bit VLAN ID gives 4096 values. Values 0 and 4095 are reserved, so the usable range is 1 to 4094.

Destination MACSource MAC802.1Q tag4 bytesTypePayloadFCS

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.

Watch out

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.

Phonetagged VLAN 30Access portdata VLAN 10 plus voice VLAN 30SwitchPC behind phoneuntaggedAccess portdata VLAN 10 plus voice VLAN 30Switch

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.

Exam tip

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-mode and vlan members. port-mode is the older syntax.
  • native-vlan-id goes on the physical interface and both trunk ends must match.
  • A trunk without a native VLAN drops untagged frames.
  • switch-options voip places a phone's tagged voice VLAN on an access port; LLDP MED tells the phone which VLAN to use.
  • show vlans and show ethernet-switching interface verify 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-id configured. 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.