Home arrow Guides arrow FreeBSD Bridge Quick Tutorial
FreeBSD Bridge Quick Tutorial PDF
Sunday, 12 June 2011
This tutorial is about how to configure a network bridge in FreeBSD so you could join two separate local networks together.

Configure a Bridge in FreeBSD
------------------------------------

Let's say our FreeBSD machine has two network cards em0 and em1.

We will add IP on the bridge device (bridge0): 10.0.0.2 and not on em0 or em1 (as FreeBSD Handbook recomends).

Here is our /etc/rc.conf:

/etc/rc.conf
defaulltrouter="10.0.0.1"
hostname="bridge"
sshd_enable="YES"

cloned_interfaces="bridge0"
ifconfig_bridge0="addm em0 addm em1 up"
ifconfig_bridge0_alias0="inet 10.0.0.2 netmask 255.255.255.0"
ifconfig_em0="up"
ifconfig_em1="up"


Configure a Filtering Bridge
--------------------------------
We will enable filtering on bridge with ipfw:

  sysctl -w net.link.bridge.ipfw=1


We will add in /etc/rc.conf a section to enable our IPFW firewall:

/etc/rc.conf
firewall_enable="YES"
firewall_quiet="NO"
firewall_script="/etc/firewall.sh"
firewall_logging="YES"


The following config limit download to 512Kbits/s on layer2 on bridge:

/etc/firewall.rc
#!/bin/sh
cmd="/sbin/ipfw -q"

# flush rules
$cmd flush
$cmd pipe flush

$cmd 10 add pipe 1 ip from any to any bridged
$cmd pipe 1 config bw 512Kbit/s

# permit all
$cmd add 100 allow ip from any to any



Tips
-----
tcpdump -ni fxp0 -f arp
- see arp traffic on fxp0
ifconfig bridge0 addr  - see arp table, vlan, network card

If you want to add support for bridge in the kernel, recompile the kernel with the following option:
device if_bridge

Last Updated ( Thursday, 16 February 2012 )
 
< Prev   Next >

Other BSD Systems

OpenBSD

Misc

Solaris

Polls

Best BSD firewall?