Skip to content

Instantly share code, notes, and snippets.

@gustavorv86
Last active July 11, 2023 08:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gustavorv86/0c500966e71a07982885037ac59e7b84 to your computer and use it in GitHub Desktop.
Save gustavorv86/0c500966e71a07982885037ac59e7b84 to your computer and use it in GitHub Desktop.
How to create a network bridge in Linux

How to create a network bridge in Linux

Requirements

Check if iproute2 is installed.

dpkg -s iproute2

Configuration

Create a bridge interface.

ip link add name bridge0 type bridge

Add interfaces to the brigde.

ip link set eth0 master bridge0
ip link set eth1 master bridge0

Show interfaces added to the bridge.

bridge link show

Internet access on the bridge

Add an IP address to the bridge interface.

ip addr add 192.168.1.254/24 dev bridge0

Add a default gateway.

ip route add default via 192.168.1.1 dev bridge0

Monitoring with tcpdump

Check if tcpdump is installed.

dpkg -s tcpdump

Monitoring traffic.

tcpdump -i bridge0 -nn "icmp"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment