StudyToCert

All certifications / JNCIA-Junos / Lessons

Juniper Networks Certified Associate, Junos (JNCIA-Junos) JN0-106 · Domain 1: Networking fundamentals

What routers and switches do: Layer 2 frame forwarding vs Layer 3 packet forwarding

▶ Watch the overview video

Last reviewed September 25, 2026 · Leer en español

Switches and routers both move traffic, but they make decisions using different information at different layers. A switch forwards Ethernet frames within a single network using MAC (media access control) addresses, which is Layer 2 of the OSI model. A router forwards IP packets between networks using IP addresses, which is Layer 3. Understanding that split is the foundation for everything else you will configure on Junos devices.

A Layer 2 switch keeps a table that maps MAC addresses to ports, called the MAC table or, on Junos, the Ethernet switching table (show ethernet-switching table). When a frame arrives, the switch looks up the destination MAC address. If it knows the port, it forwards the frame out that port only. If not, or if the frame is a broadcast, it floods the frame to all ports in the VLAN. The frame itself is not changed: source and destination MAC stay the same from one end of the switched network to the other.

A router keeps a routing table of destination prefixes (such as 10.1.2.0/24) and the next hop or outgoing interface for each. On Junos the main IPv4 table is inet.0, viewed with show route. When a packet arrives, the router strips the incoming Layer 2 header, reads the destination IP address, finds the longest (most specific) matching prefix, decrements the TTL (time to live) and builds a new Layer 2 header for the outgoing link, with its own MAC as the source and the next hop's MAC as the destination. So at each routed hop the MAC addresses change while the source and destination IP addresses stay the same.

The two devices also treat unknown traffic differently. A switch floods frames for unknown destinations, because it assumes the device is somewhere on this network. A router drops packets for destinations it has no route to (unless it has a default route, 0.0.0.0/0), and can send an ICMP destination-unreachable message back. Routers also do not forward broadcasts, which is why they bound broadcast domains.

Many modern devices do both. Juniper EX and QFX switches can switch frames in hardware within a VLAN and route between VLANs using IRB interfaces. MX routers can also bridge. On Junos the same idea shows up in the configuration: family ethernet-switching on an interface unit means Layer 2 switching, and family inet with an address means Layer 3 routing.

For the exam, remember the keywords: frames, MAC addresses, flooding and the switching table for Layer 2; packets, IP addresses, longest match, TTL and the routing table for Layer 3.

Key terms

Frame
A Layer 2 unit of data with a header containing source and destination MAC addresses.
Packet
A Layer 3 unit of data with a header containing source and destination IP addresses and a TTL.
Ethernet switching table
The Junos table mapping learned MAC addresses to interfaces and VLANs, shown with show ethernet-switching table.
Routing table
A table of destination prefixes and next hops; on Junos the IPv4 unicast table is inet.0.
Longest-prefix match
The rule that a router uses the most specific matching route when several prefixes contain the destination.
Real-world example

A PC at 10.1.1.10 pings a server at 10.2.2.20. The PC's frame goes through an EX switch unchanged to the gateway router. The router matches 10.2.2.0/24, lowers the TTL by one, rewrites the Ethernet header with its own MAC as source and the server's MAC as destination, and sends it out. A packet capture on each side shows the same IP addresses but different MAC addresses.

Exam tip: Exam questions like to ask what changes at each hop. In routed traffic, MAC addresses change at every router while IP addresses stay the same (ignoring NAT).

Check yourself

What does a switch do with a frame whose destination MAC is not in its table?

It floods the frame out every port in the same VLAN except the one it arrived on.

What does a router do with a packet when it has no matching route and no default route?

It drops the packet and may send an ICMP destination-unreachable message to the source.

Which header fields does a router rewrite when forwarding a packet?

It builds a new Layer 2 header (new source and destination MAC) and decrements the IP TTL; the source and destination IP addresses stay the same.

Study JNCIA-Junos for free
A week-by-week plan with every lesson, quizzes, checkpoint tests, a practice exam and hands-on labs.
Open the JNCIA-Junos study plan