Configure bridge interfaces

Locked
User avatar
Mihai Romania
Posts: 60
Joined: 2023 May 03, 14:12
Location: ROMANIA
Contact:

Configure bridge interfaces

Post by Mihai »

Code: Select all

[root @ centos ~]$ brctl
commands:
addbr add bridge (1)
addif add interface to bridge (2)
delbr delete bridge (3)
delif delete interface from bridge (4)
show show a list of bridges (5)
showbr show bridge info (6)
showmacs show a list of mac addrs (7)
setageing set ageing time (8)
setbridgeprio
set bridge priority (9)
setfd set bridge forward delay (10)
setgcint set garbage collection interval (11)
sethello set hello time (12)
setmaxage set max message age (13)
setpathcost
set path cost (14)
setportprio
set port priority (15)
stp {dis,en}able stp (16)
  • Method #1
Creating a bridge interface (the interface can be named as desired. In the example below the interface is named "intbridge")

Code: Select all

[root @ mbb-1]$ brctl addbr intbridge
Output example #1

Code: Select all

[root @ mbb-1:~ $ brctl show
bridge name bridge id stp enabled
intbridge 0000.0800062815f6 yes
Output example #2

Code: Select all

[root @ centos ~]$ brctl showbr intbridge
intbridge
bridge id 0000.0800062815f6
designated root 0000.0800062815f6
root port 0 path cost 0
max age 4.00 bridge max age 4.00
hello time 1.00 bridge hello time 1.00
forward delay 4.00 bridge forward delay 4.00
ageing time 300.00 gc interval 4.00
hello timer 0.84 tcn timer 0.00
topology change timer 0.00 gc timer 1.84
flags

eth0 (1)
port id 8001 state forwarding
designated root 0000.0800062815f6 path cost 100
designated bridge 0000.0800062815f6 message age timer 0.00
designated port 8001 forward delay timer 0.00
designated cost 0 hold timer 0.84
flags

eth1 (2)
port id 8002 state forwarding
designated root 0000.0800062815f6 path cost 100
designated bridge 0000.0800062815f6 message age timer 0.00
designated port 8002 forward delay timer 0.00
designated cost 0 hold timer 0.84
flags
Output example #3

Code: Select all

[root @ centos ~]$ brctl showmacs intbridge
port no mac addr is local? ageing timer
1 00:a0:24:d0:4c:d6 yes 0.00
1 00:a0:24:f0:22:71 no 5.81
4 08:00:09:fc:d2:11 yes 0.00
1 08:00:09:fd:23:88 no 230.42
1 08:00:09:fe:0d:6f no 144.55
General configuration
Creating the interface

Code: Select all

[root @ centos ~]$ brctl addbr intbridge
Add eth0 and eth1 interface in bridge

Code: Select all

[root @ centos ~]$ brctl addif intbridge eth0
[root @ centos ~]$ brctl addif intbridge eth1
Add IP 0.0.0.0 on both interfaces added in bridge

Code: Select all

[root @ centos ~]$ ifconfig eth0 0.0.0.0
[root @ centos ~]$ ifconfig eth1 0.0.0.0
Enable the bridge interface

Code: Select all

[root @ centos ~]$ ifconfig intbridge up
Optionally, the virtual intbridge interface can be configured to participate in the network. It behaves like an interface (a normal network card). This is exactly how you configure it, replacing the previous command with the following command

Code: Select all

[root @ centos ~]$ ifconfig intbridge 192.168.100.5 netmask 255.255.255.0 up
Important: If you happen to experience a server crash during configuration, when configuring an interface with IP "0.0.0.0"

Code: Select all

[root @ centos ~]$ ifconfig ethX 0 0.0.0.0
After a restart of the operating system, before bringing up the bridge interface again, execute the following command

Code: Select all

[root @ centos ~]$ ifconfig ethX promisc up
If the same crash occurs again, it is not due to the configuration of the bridge interface, preparing the interfaces and adding them to the bridge!
It's a problem with the operating system drivers! This problem can be solved with a kernel update.

  • Method #2
This method creates the interfaces in bridge at start-up
Go to /etc/sysconfig/network-scripts

Code: Select all

[root @ centos ~]$ cd /etc/sysconfig/network-scripts/
Create the file for the bridge interface

Code: Select all

[root @ centos ~]$ touch ifcfg-bridge
Add the following configuration in the file

Code: Select all

[root @ centos ~]$ nano ifcfg-bridge
DEVICE=bridge0
TYPE=Bridge
BOOTPROTO=static
NETWORK=192.168.0.0
NETMASK=255.255.255.0
IPADDR=192.168.0.2
GATEWAY=192.168.0.1
DNS1=192.168.0.1
DNS2=8.8.8.8
ONBOOT=yesb       
DELAY=0
Configure the interface eth0 in bridge mode

Code: Select all

[root @ centos ~]$ nano ifcfg-eth0
DEVICE=eth0
BOOTPROTO=none
HWADDR=00:12:34:56:78:90
ONBOOT=yes
BRIDGE=bridge
Prepare the interface th1 in bridge mode

Code: Select all

[root @ centos ~]$ nano ifcfg-eth1
DEVICE=eth1
BOOTPROTO=none
HWADDR=01:23:45:67:89:01
ONBOOT=yes
BRIDGE=bridge
Restart the network service

Code: Select all

[root @ centos ~]$ /etc/init.d/network restart
  • Method #3
Edit the file /etc/network/interfaces with the following configuration

Code: Select all

[root @ debian ~]$ cd /etc/network/
[root @ debian ~]$ nano interfaces
# Configure interfaces eth0 , eth1 , bridge #
auto lo br0
iface lo inet loopback
iface eth0 inet manual
iface eth1 inet manual

iface br0 inet static
bridge_ports eth0 eth1
address 192.168.0.2
broadcast 192.168.0.255
netmask 255.255.255.0
gateway 192.168.0.1
Add the following commands at startup

Code: Select all

[root @ debian ~]$ cd /etc/
[root @ debian ~]$ nano rc.local
# Load Kernel variables from /etc/sysctl.d
/etc/init.d/procps restart
exit 0
I'm on LinkedIn
Locked