カーネルの再構築が済んだら、再起動する前に、設定ファイル(/etc/rc.conf)を 編集しておきます。カーネルの 設定はデフォルトでは立ち上がった際に、安全のため全てのパケットの受け入れを拒否 するようになっています。今の場合には、最初はフィルタリングは 素通しの設定にします。 ここでは素通しの設定は /etc/ipf.rules に次のように書いておきます。
pass in all pass out all |
次に、これらの設定に従って、フィルタリング を起動時に動くように /etc/rc.conf に設定をします。
ipfilter_enable="YES" # Set to YES to enable ipfilter functionality ipnat_enable="NO" # Set to YES for ipnat; needs ipfilter, too! ipmon_enable="YES" # Set to YES for ipmon; needs ipfilter, too! tcp_drop_synfin="YES" # Set to YES to drop TCP packets with SYN+FIN icmp_drop_redirect="YES" # Set to YES to ignore ICMP REDIRECT packets icmp_log_redirect="YES" # Set to YES to log ICMP REDIRECT packets |
なお、タイプミスが心配な方は、/etc/default/rc.conf から該当行を
コピーしてきて、必要な箇所のみを編集すれば良いでしょう。
また、今回は NAT は使いませんので、ipnat_enable="NO" にして
おきます。
オプションや、設定ファイルはデフォルトが /etc/defaults/rc.conf で 決められており、
# 参考 /etc/defaults/rc.conf におけるデフォルト設定
ipfilter_program="/sbin/ipf -Fa -f"
# program and how to specify the rules file,
# see /etc/rc.network (pass1) for details
ipfilter_rules="/etc/ipf.rules" # rules definition file for ipfilter, see
# /usr/src/contrib/ipfilter/rules for examples
ipfilter_flags="-E" # should be *empty* when ipf is _not_ a module
# (i.e. compiled into the kernel) to
# avoid a warning about "already initialized"
|
手動で動かす際には、FreeBSD では /etc/rc.conf に設定があれば、
# /etc/rc.d/ipfilter start
|
で動作します。ルールセットを書き換えて、それを既に動作している ipfilter に反映させたい場合には、
# /etc/rc.d/ipfilter reload
|
とします。
もし、他のOSなどで、こうしたスクリプトが用意されていない場合には、 以下のように行えば手動で起動できます。
# ipf -Fa -f /etc/ipf.rules
|
設定が終ったら、再起動して、テスト して見てください。基本的には、 グローバル側に出て行き、コネクションが成立すれば大丈夫でしょう (例えば telnet で試す)。詳しくは、tcpdump や ethereal などで、 パケットを監視して見てください。