# Junos and Spanning Tree: Root Bridge Selection and Role

The Spanning Tree Protocol (STP) is a network protocol designed to prevent loops in a bridged Ethernet local area network (LAN). In this blog post, we will discuss the root bridge selection process and its role in a Junos environment, which is a crucial topic for the JNCIS-ENT certification.

## Root Bridge Selection

The root bridge in a spanning tree is the logical center and is responsible for traffic flow across the network. The selection process is based on the Bridge ID (BID), which consists of a configurable Bridge Priority (default is 32768) and the MAC address.

The steps for root bridge selection are as follows:

1. **Lowest Bridge Priority**: All switches start with the same default priority. If no changes have been made to the default priority, all switches will have a priority of 32768. The switch with the lowest priority becomes the root bridge.

2. **Lowest MAC Address**: If there is a tie in priority, the switch with the lowest MAC address will become the root bridge.

## Role of the Root Bridge

Once the root bridge is elected, all other switches in the network calculate the shortest path to the root bridge. The roles of the remaining switches (non-root bridges) are determined based on these calculations:

- **Root Ports**: Each non-root bridge will select one of its ports as a root port, which is the port with the shortest path to the root bridge.

- **Designated Ports**: Each network segment has one designated port, which is the port on that segment with the shortest path to the root bridge.

- **Non-Designated Ports**: These ports are neither root ports nor designated ports. They are blocked to prevent loops in the network.

## Configuring STP on Junos

To configure STP on a Junos device, use the following commands:

```bash
user@switch# set protocols stp bridge-priority <priority>

This command sets the bridge priority. Remember, a lower number means a higher priority.

user@switch# set protocols stp interface ge-0/0/0.0 cost <cost>

This command sets the path cost for the specified interface. A lower cost indicates a more preferred path.

In conclusion, understanding the root bridge selection process and its role in a Junos environment is crucial for network stability and efficiency. It's also a key topic for the JNCIS-ENT certification. Happy studying!

© Ben Jacobson.RSS