Monday, October 5, 2009

Ethernet Bridge on FreeBSD

The basic operation of a bridge is to join two or more network segments together. There are many reasons to use a host based bridge over plain networking equipment such as cabling constraints, firewalling or connecting pseudo networks such as a Virtual Machine interface. A bridge can also connect a wireless interface to a wired network and act as an access point.

Requirements:
Two Physical (Real) Network Card (NIC) (minimum)

Enabling the Bridge:
The bridge is created using interface cloning.

To create a bridge use ifconfig

# ifconfig bridge create
bridge0

# ifconfig bridge0
bridge0: flags=8802<BROADCAST,SIMPLEX,MULTICAST> metric 0 mtu 1500
        ether 96:3d:4b:f1:79:7a
        id 00:00:00:00:00:00 priority 32768 hellotime 2 fwddelay 15
        maxage 20 holdcnt 6 proto rstp maxaddr 100 timeout 1200
        root id 00:00:00:00:00:00 priority 0 ifcost 0 port 0

Add the member network interfaces to the bridge.

# ifconfig bridge0 addm re0 addm re1 up
# ifconfig re0 up
# ifconfig re1 up

To remove a BRIDGE interface, enter:
# ifconfig bridge0 destroy

To make configuration persistence, open /etc/rc.conf, Append / modify as follows:
# vi /etc/rc.conf
cloned_interfaces="bridge0"
ifconfig_bridge0="addm re0 addm re1 up"
ifconfig_re0="up"
ifconfig_re1="up"

bridge interface can be configured to take part in network.
# ifconfig bridge0 inet 192.168.200.1/24

No comments:

Post a Comment