I have done this before with the help of a friend but I cannot remember the exact details on how to do it. I'm not that type of guy who takes down notes for every new procedures/configurations I have done. So I spent some time googling around and finally found this link. I am going to summarize the procedures by posting a simple shell script that will create a bridge interface in FreeBSD.
#!/bin/sh
# Filename: createbridge.sh
# load the kernel loadable module
/sbin/kldload /boot/kernel/if_bridge.ko
# create a bridge interface
/sbin/ifconfig bridge0 create
# add the network interfaces you want as member of the bridge
/sbin/ifconfig bridge0 addm em0 addm em1 addm em2
# bring these interfaces up
/sbin/ifconfig em0 up
/sbin/ifconfig em1 up
/sbin/ifconfig em2 up
# then you can assign an ip address to your bridge interface if you want
/sbin/ifconfig bridge0 inet 192.168.1.1/24
Save this script at /usr/local/etc/rc.d so that it will get executed during boot-up process. Then make the script executable and execute it:
# chmod 755 /usr/local/etc/rc.d/createbridge.sh
# /usr/local/etc/rc.d/createbridge.sh
Just as there are many ways to kill a cat, there are also other ways to create a bridge interface in FreeBSD. One of which is to do it using rc.conf. But I think you still need to add "device if_bridge" into your kernel configuration /usr/src/sys/{arch}/conf/GENERIC so that it will be dynamically loaded by the kernel everytime you create a bridge interface.
No comments:
Post a Comment