FreeBSD de NAT

[ Nob's Home | FreeBSD ]

NIC2枚のCeleron機でNATを運用します。
options IPFIREWALL 
options IPDIVERT 
を付けたkernelではipfwを設定しないと、
いっさいのpacketのやり取りができないのを知らずにはまりました。
御注意のほどを。

FreeBSD 3.2では/sbin/natdなど必要なものは、defaultで揃っているようです。

Information

rc.conf

/etc/defaults/rc.confがデフォルトで変更点だけ/etc/rc.confに書きます。
(いつからこんなに便利になったの?)
# This file now contains just the overrides from /etc/defaults/rc.conf
# please make all changes to this file.
# -- sysinstall generated deltas -- #
network_interfaces="lo0 vr0 mx0"
ifconfig_vr0="inet 2xx.1xx.1xx.1xx  netmask 255.255.255.240"
ifconfig_mx0="inet 192.168.0.1 netmask 255.255.255.0"
gateway_enable="YES"
#
firewall_enable="YES"
firewall_type="open"
natd_enable="YES"
natd_interface="vr0"
natd_flags="-l"
#
defaultrouter="2xx.1xx.1xx.2xx"
nfs_server_enable="YES"
hostname="makioka-fw.y-min.or.jp"
named_enable="YES"
xntpd_enable="YES"
#
global addressをvr0に、private addressをmx0にふります。
natdのinterfaceはglobal address側のvr0です。
natdのoptionで"-l"をつけると、/var/log/alias.logがとれます。
firewall_typeは"open"にすると、すべてのpacketを素通しします。
NATだけ必要ならこれでOKです。

clientでの設定

private addressを使用するclient machineでは、
ルーターアドレスをFW hostの192.168.0.1にするだけです。


[ Nob's Home | FreeBSD ]
nob@makioka.y-min.or.jp