To create a network bridge between two Ethernet interfaces (eth0 and lan0) on a Linux system, you can use the following steps:
-
Open a terminal window.
-
Edit the
/etc/network/interfaces
file using a text editor with administrative privileges. For example, you can usesudo
andnano
:sudo nano /etc/network/interfaces
-
Add the following configuration lines to the end of the file:
auto br0 iface br0 inet static address 192.168.1.200 netmask 255.255.255.0 gateway 192.168.1.1 bridge_ports eth0 lan0 bridge_stp off bridge_fd 0 bridge_maxwait 0 up /etc/init.d/ssh restart
auto br0
: This line ensures that the bridge interface (br0) is brought up automatically during system boot.iface br0 inet static
: This indicates that the bridge interface will have a static IP configuration.address 192.168.1.200
: Assigns the IP address 192.168.1.200 to the bridge interface.netmask 255.255.255.0
: Sets the subnet mask to 255.255.255.0.gateway 192.168.1.1
: Specifies the default gateway IP address.bridge_ports eth0 lan0
: Indicates that the bridge interface will bridge traffic from the eth0 and lan0 interfaces.bridge_stp off
: Disables the Spanning Tree Protocol to prevent network loops.bridge_fd 0
: Sets the bridge forwarding delay to 0 seconds for immediate forwarding.bridge_maxwait 0
: Sets the maximum wait time for the bridge to become operational to 0 seconds.up /etc/init.d/ssh restart
: Restarts the SSH service when the bridge interface is brought up.
-
Save the changes and exit the text editor.
-
Restart the networking service to apply the changes:
sudo service networking restart
Note: The exact command to restart the networking service might vary based on your Linux distribution.
-
Your bridge configuration should now be active. You can verify its status using tools like
ip
orifconfig
.
That's it! You have successfully set up a network bridge between the eth0 and lan0 Ethernet interfaces.