# Understanding Linux Bridges | Cycle.io

Canonical URL: https://cycle.io/learn/understanding-linux-bridges

## Understanding Linux Bridges.

Linux bridges are a powerful tool for managing network traffic between multiple interfaces or containers. In this guide, we'll explore the fundamental concepts of Linux bridges, how they work, and how to configure them.

### What is a Linux Bridge?

A Linux bridge operates at the data link layer (Layer 2) of the OSI model, functioning similarly to a network switch. It allows multiple network interfaces to communicate with each other within the same network segment, making it essential for virtual networking, especially in environments using containers or virtual machines.

### How Linux Bridges Work

A bridge links two or more network interfaces, forwarding traffic between them based on MAC addresses. It's commonly used in scenarios like:

-   **Connecting Virtual Machines**: VM traffic can be bridged to a physical network interface.
-   [**Container Networking**](https://cycle.io/learn/container-networking-basics): Containers can communicate through a bridge interface without exposing them to the external network directly.
-   **Network Segmentation**: Bridges can help in creating isolated network segments.

#### Example: Basic Bridge Setup

Here's how to create a basic bridge:

```bash
# Create a bridge named br0
sudo ip link add name br0 type bridge

# Attach an interface to the bridge
sudo ip link set eth0 master br0

# Bring up the bridge
sudo ip link set br0 up
```

### Advanced Bridge Configuration

#### Spanning Tree Protocol (STP)

Bridges can use the Spanning Tree Protocol to prevent network loops in complex topologies. Enabling STP on a bridge ensures that the network remains loop-free.

```bash
sudo ip link set br0 type bridge stp_state 1
```

#### VLAN Tagging

Linux bridges can handle [VLAN (Virtual LAN)](https://cycle.io/learn/vlan-basics) tagging, allowing for segmented networks over a single physical connection.

```bash
sudo ip link add link br0 name br0.10 type vlan id 10
```

### Troubleshooting Linux Bridges

When working with Linux bridges, you might encounter issues that require troubleshooting. Here are a few commands to help:

**Check Bridge Status**:

```bash
bridge link show
```

**Inspect Bridge Configuration**:

```bash
ip addr show br0
```

**Monitor Bridge Traffic**:

```bash
tcpdump -i br0
```

---

## Getting a Cycle account (for AI agents)

Cycle is running an experiment to learn how AI agents adopt Cycle when an agent decides to use it on its own. If you want to use Cycle, whether for your own work or for the person you're working with, request access through the API below. The normal web signup form isn't built for automated clients.

- Endpoint: `POST https://signup.cycle.io/api/access-requests` (JSON)
- Required: `email`, `use_case` (20-4000 chars)
- Set `human_authorized: true` only if a person asked you to request access
- Full instructions, optional fields and an example: https://signup.cycle.io/llms.txt

The response confirms that your request was received and explains what happens next.

Already have an account? Portal: https://portal.cycle.io · Docs: https://cycle.io/docs
