Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

Example: Configuring Basic Layer 2 Switching on MX Series


This example shows how to configure Layer 2 switching with all interfaces participating in a single VLAN.


No special configuration beyond device initialization is required before configuring this example.

This example uses an MX Series device to perform Layer 2 switching.


In this example, a single MX Series device is configured to act as a basic single-VLAN switch. Three connections are in place. The connections from the MX Series device attach to Junos OS routers, but the routers are used here for testing purposes only. In place of routers, you can use any IP networking devices.


Figure 1 shows the sample network.

Figure 1: Basic Layer 2 Switching
Basic Layer 2 Switching

CLI Quick Configuration shows the configuration for all of the devices in Figure 1.

The section Step-by-Step Procedure describes the steps on Device S1.


CLI Quick Configuration

To quickly configure this example, copy the following commands, paste them into a text file, remove any line breaks, change any details necessary to match your network configuration, and then copy and paste the commands into the CLI at the [edit] hierarchy level.

Device S1

Device R1

Device R2

Device R3

Step-by-Step Procedure

The following example requires that you navigate various levels in the configuration hierarchy. For information about navigating the CLI, see Using the CLI Editor in Configuration Mode in the CLI User Guide.

To configure Device S1:

  1. Configure the device interfaces.
  2. Configure the bridge domain.


From configuration mode, confirm your configuration by entering the show interfaces and show bridge-domains commands. If the output does not display the intended configuration, repeat the instructions in this example to correct the configuration.

If you are done configuring the device, enter commit from configuration mode.


Confirm that the configuration is working properly.

Confirming the MAC Address Learning


Display Layer 2 MAC address information.


  • From Device S1, run the show bridge mac-table command.

  • From Device S1, run the show bridge mac-table extensive command.

    user@S1> show bridge mac-table extensive


The output shows that the MAC addresses have been learned.

Making Sure That the Attached Devices Can Reach Each Other


Verify connectivity.


user@R1> ping

user@R1> ping

user@R2> ping


The output shows that the attached devices have established Layer 3 connectivity, with Device S1 doing transparent Layer 2 bridging.

Checking the Bridge Domain


Display bridge domain information.


user@S1> show bridge domain extensive


The output shows that bridge domain is active.

Checking the Bridge Statistics


Display bridge statistics.



The output shows that bridge domain interfaces are sending and receiving packets.

Checking the Bridge Flooding


Display bridge flooding information.


user@S1> show bridge flood extensive


If the destination MAC address of a packet is unknown to the device (that is, the destination MAC address in the packet does not have an entry in the forwarding table), the device duplicates the packet and floods it on all interfaces in the bridge domain other than the interface on which the packet arrived. This is known as packet flooding and is the default behavior for the device to determine the outgoing interface for an unknown destination MAC address.

Checking Layer 2 Learning


Display Layer 2 learning information for all the interfaces.