Debian Linux: Configure Network Interfaces As A Bridge / Network Switch

Debian Linux: Configure Network Interfaces As A Bridge / Network Switch

To configure a network interface as a bridge in Debian, you will need to install the bridge-utils package, which provides the brctl command for managing Linux bridges.

Here's an example of how you can set up a bridge interface called br0 that includes two physical interfaces, eth0 and eth1:

  1. Install the bridge-utils package:
refer to‮ruttual:‬i.com
sudo apt-get update
sudo apt-get install bridge-utils
  1. Edit the /etc/network/interfaces file to add the following lines:
auto br0
iface br0 inet dhcp
    bridge_ports eth0 eth1
    bridge_stp off
    bridge_fd 0
    bridge_maxwait 0

This will configure the br0 interface to use DHCP to obtain an IP address and to include the eth0 and eth1 interfaces in the bridge. The bridge_stp option disables the Spanning Tree Protocol, which is used to prevent loops in the network. The bridge_fd and bridge_maxwait options set the forward delay and maximum wait time, respectively, to zero.

  1. Bring up the br0 interface:
sudo ifup br0

You can verify that the bridge is working by checking the output of the brctl show command, which should show the br0 bridge and the eth0 and eth1 interfaces as part of it.

Note: If you want to use the br0 interface as a network switch, you will need to configure the other devices on the network to use it as their default gateway. You can do this by setting the IP address of the br0 interface as the default gateway on the other devices, or by using a router to forward traffic to the br0 interface.

Created Time:2017-10-28 14:02:25  Author:lautturi