FreeBSD + IPFW 當 NAT 供內部電腦上網

測試環境
client pc
ip: 10.2.3.100/255.255.255.0
gate way: 10.2.3.254

freebsd host:
os: FreeBSD 9.3-RELEASE x64
em0: x.x.x.x/255.255.255.0 (internet ip)
em1: 10.2.3.254/255.255.255.0

step1:
# cd /usr/src/sys/amd64/conf
將以下幾行加入 kernel , 並重新compile
options IPFIREWALL
options IPFIREWALL_VERBOSE
options IPFIREWALL_VERBOSE_LIMIT=5
options IPFIREWALL_DEFAULT_TO_ACCEPT
options IPDIVERT

step2:
編輯/etc/rc.conf
firewall_enable="YES"
firewall_type="OPEN"
natd_interface="em0" ##這裡是外部ip網卡的代號
natd_enable="YES"
gateway_enable="YES"

step3:
重開機,如果設定正常的話,在內部網路的client應該都可以透過freebsd上網了~

step4: (可省略)
# ipfw show
檢查是否有這一行
00050 34679 4765350 divert 8668 ip4 from any to any via em0

arrow
arrow
    文章標籤
    freebsd firewall nat ipfw
    全站熱搜
    創作者介紹
    創作者 helloworld 的頭像
    helloworld

    Hello World

    helloworld 發表在 痞客邦 留言(0) 人氣()