Layer 2 Switching and VLANs · Topic 4 of 4

Inter-VLAN Routing

Learn inter-VLAN routing on Junos: irb interfaces with l3-interface, default gateways, router on a stick, and how to configure, verify and troubleshoot it.

  • 6 min
  • Includes a diagram
In a nutshell
  • Different VLANs need Layer 3 routing; the switch does it with an IRB, or an external router does it.
  • ELS IRB: set interfaces irb unit N family inet address ... and set vlans NAME l3-interface irb.N.
  • The IRB address is the hosts' default gateway.

What it is

Hosts in different VLANs are in different broadcast domains, so they can only talk through a Layer 3 device. Inter-VLAN routing is that routing step. On a Junos switch it is done by an integrated routing and bridging (IRB) interface, a virtual interface that sits inside a VLAN and has an IP address.

The IRB address is the default gateway for the hosts in the VLAN. A switch with an IRB for each VLAN can route between them itself. The alternative is an external router connected by a trunk, often called router on a stick.

Host AVLAN 10Default gatewayirb unit 10Route lookupirb unit 20Host BVLAN 20

How it works

IRB interfaces in ELS

An IRB has two parts. The interface irb with a numbered unit holds the IP address, and the VLAN is told which IRB unit to use with l3-interface.

user@switch# set vlans SALES vlan-id 10
user@switch# set vlans ENG vlan-id 20
user@switch# set interfaces irb unit 10 family inet address 10.1.10.1/24
user@switch# set interfaces irb unit 20 family inet address 10.1.20.1/24
user@switch# set vlans SALES l3-interface irb.10
user@switch# set vlans ENG l3-interface irb.20

The unit number does not have to match the VLAN ID, but using the same number makes the design easy to read. The link between the two is l3-interface. Without it, the address exists but the VLAN does not use it.

Hosts then use 10.1.10.1 and 10.1.20.1 as their gateways.

irb unit 1010.1.10.1 slash 24l3 interfaceVLAN SALESVLAN 10Access portshostsirb unit 2010.1.20.1 slash 24l3 interfaceVLAN ENGVLAN 20Access portshosts

What happens to a routed packet

Host A in VLAN 10 sends a frame to the MAC address of irb.10 on the EX switch. The switch routes the packet and sends a new frame into VLAN 20, addressed to the MAC address of Host B.

  1. Host A sends a frame to the gateway's MAC address, with the IP address of Host B inside.
  2. The switch sees its own IRB MAC address as the destination and hands the packet to the routing process.
  3. It looks up the destination in the routing table. Both IRB subnets are directly connected, so they are there already.
  4. It sends the packet out through the other IRB and into VLAN 20, with a new Layer 2 header addressed to Host B.

The IP packet keeps its source and destination addresses, but the Ethernet header changes at the routing step.

Router on a stick

An external router can route instead. The switch port to the router is a trunk, and the router has one logical interface for each VLAN.

user@router# set interfaces ge-0/0/0 vlan-tagging
user@router# set interfaces ge-0/0/0 unit 10 vlan-id 10
user@router# set interfaces ge-0/0/0 unit 10 family inet address 10.1.10.1/24
user@router# set interfaces ge-0/0/0 unit 20 vlan-id 20
user@router# set interfaces ge-0/0/0 unit 20 family inet address 10.1.20.1/24

All inter-VLAN traffic crosses that one link twice, which makes it a bottleneck. An IRB on the switch avoids it, and that is why IRBs are the normal enterprise choice.

IRB on the switchRouter on a stick
Routing done byThe switch itselfAn external router
Gateway interfaceirb.<unit>Logical unit with vlan-id on the router
Switch port to routerNot neededTrunk
Traffic pathStays in the switchGoes out and back on one link

Verifying

user@switch> show interfaces irb terse
Interface               Admin Link Proto    Local                 Remote
irb                     up    up
irb.10                  up    up   inet     10.1.10.1/24
irb.20                  up    up   inet     10.1.20.1/24

user@switch> show route 10.1.20.0/24
user@switch> show arp
user@switch> ping 10.1.20.10 source 10.1.10.1

show vlans shows the IRB linked to each VLAN. show arp lists the hosts the switch has resolved on the IRB subnets.

By default, an IRB comes up only when at least one port in its VLAN is up. If the IRB shows down, check that a port is up in that VLAN before looking at the IP configuration.

Exam tip

To test the gateway, ping the IRB address from a host in the same VLAN first. If that works but another VLAN fails, the fault is routing or the far side, not the access port.

Troubleshooting

  1. Does each VLAN have a l3-interface that points to the right irb unit?
  2. Is the IRB up up and does it have the expected address?
  3. Does the host have the right subnet mask and the IRB address as its default gateway?
  4. Is the destination subnet in show route? Directly connected IRB subnets appear automatically.
  5. Is a firewall filter on an IRB or VLAN discarding the traffic?
Watch out

A host with a wrong gateway address can reach its own VLAN but nothing else. That symptom points to the host settings, not to the switch.

Common mistakes

Missing l3-interface. The IRB has an address, but it is not bound to the VLAN.

Wrong host gateway. Hosts use the switch's management address or a neighbor's address instead of the IRB address.

Expecting an IRB to be up with no active port. With every VLAN port down, the IRB is down.

Forgetting the trunk with router on a stick. The switch port to the router must carry all the VLANs, and the router needs vlan-tagging.

What to remember for the exam

  • Different VLANs need Layer 3 routing; the switch does it with an IRB, or an external router does it.
  • ELS IRB: set interfaces irb unit N family inet address ... and set vlans NAME l3-interface irb.N.
  • The IRB address is the hosts' default gateway.
  • Router on a stick uses a trunk and one logical unit for each VLAN with vlan-tagging and vlan-id.
  • Directly connected IRB subnets appear in the routing table automatically, with route preference 0.
  • show interfaces irb terse, show vlans, show route and show arp verify the setup.
  • By default, an IRB is up only while a port in its VLAN is up.

Check yourself

  • Which two statements are needed to give VLAN SALES a gateway in ELS?

    An address on an irb unit, and l3-interface irb.N under the VLAN to bind it.

  • What is the drawback of router on a stick compared with IRBs?

    All inter-VLAN traffic crosses one trunk link to the router and back, which can become a bottleneck.

  • The IRB for a VLAN shows down although its address is correct. What is a likely cause?

    No port in that VLAN is up.

Topic 4 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.