Slackware Linuxにおけるiptablesの設定
概要
Slackware Linuxにおけるiptablesの設定を行う方法。
テスト環境
Slackware Linux 14.0
方法
/etc/rc.d/下にあるrc.inet1が実行されてからネットワークが確立した後にrc.inet2が実行される。
rc.inet2の中でiptablesを設定するスクリプト/etc/rc.d/rc.firewallが実行可能であれば実行し、その後に/etc/rc.d/rc.ip_forwardが実行可能であれば実行してIPフォーワードを有効にするようになっている。
# If there is a firewall script, run it before enabling packet forwarding. # See the HOWTOs on http://www.netfilter.org/ for documentation on # setting up a firewall or NAT on Linux. In some cases this might need to # be moved past the section below dealing with IP packet forwarding. if [ -x /etc/rc.d/rc.firewall ]; then /etc/rc.d/rc.firewall start fi # Turn on IPv4 packet forwarding support. if [ -x /etc/rc.d/rc.ip_forward ]; then . /etc/rc.d/rc.ip_forward start fi
/etc/rc.d/rc.firewallは自分で作らない限り存在しないので、iptablesを設定したい場合は作成する。
IPフォーワードを有効にするにはrc.ip_forwardを実行可能にしておく。
chmod 755 /etc/rc.d/rc.ip_forward
逆にIPフォーワードを無効にするにはrc.ip_forwardの実行権限をないようにしておく。
chmod 644 /etc/rc.d/rc.ip_forward