|
Description :
Bridge Mode 是穿透 FreeBSD 上的兩片網路卡,讓 Firewall 後端可以直接使用真實 IP ,如果想在一個網路的節點環境,加入防火牆過慮封包及頻寬管理,而又不想使用 NAT 破壞原有的網路架構,即可以使用 FeeBSD + Firewall + Bridge + DUMMYNET 來達成這樣的需求, 我想使用 FreBSD 架設的防火牆,應該是最經濟的防火牆+頻寬管理器。
Environment :
Router ﹝真實 IP:88.88.88.0/24﹞<=> fxp0 * FreeBSD Bridge Mode * fxp1 <=> Switch Hub <=> PC Group ﹝真實 IP:88.88.88.0/24﹞
硬體:i386 PC Intel Pentium 200 記憶體網卡:64M RAM + 二片網卡 作業系統:FreeBSD 4.8 Release
Setp 1.
#cd /usr/src/sys/i386/conf #cp GENNRIC /etc/NEWKERNEL #ln -s /etc/NEWKERNEL #vi NEWKERNEL
在新的 kernel 裡加入新的設定,接著 Compiler 新的 kernel:
options BRIDGE options IPFIREWALL options IPFIREWALL_VERBOSE options IPFIREWALL_FORWARD
#config NEWKERNEL #cd ../../compiler/NEWKERNEL #make depend all install
Setp 2.
編輯 sysctl.conf #vi /etc/sysctl.conf 加入:
net.link.ether.bridge=1 net.link.ether.bridge_ipfw=1 net.link.ether.bridge_cfg=fxp0,fxp1 # 將 fxp0 和 fxp1開啟 bridge mode
編輯 rc.conf #vi /etc/rc.conf 加入:
firewall_enable="YES" firewall_type="OPEN"
編輯 rc.firewall #vi /etc/rc.firewall 設定 firewall 的規則:
#!/bin/sh /sbin/ipfw -f flush # 刪除所有的 rules # /sbin/ipfw pipe 1 config bw 32Kbytes/s # 設定頻寬 rules /sbin/ipfw pipe 2 config bw 512Kbytes/s # /sbin/ipfw add 2000 pipe 1 ip from 88.88.88.0/24 to any # 限制某個ip的頻寬 /sbin/ipfw add 2001 pipe 2 ip from any to 88.88.88.0/24 # /sbin/ipfw deny 3000 ip from 192.168.1.100 to any MAC any 00:50:ba:04:58:e9 # 限制某個 Mac Address # /sbin/ipfw add 65000 allow ip from any to any # 讓所有 ip 通訊協定通行 any to any
參考資料:
http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/bridging.html http://www.eldemonio.org/docs/bsd/bridge.html
|