Apr 27, 2009
[Linux] iptables -F に気をつけよう
iptables -F はルールのクリアを行うが、ポリシーのクリアは行わない。 例えば
という設定の時に iptables -F を実行しようものならChain INPUT (policy DROP) target prot opt source destination ACCEPT tcp -- anywhere anywhere tcp dpt:http state NEW ACCEPT tcp -- anywhere anywhere tcp dpt:ssh state NEW Chain FORWARD (policy DROP) target prot opt source destination Chain OUTPUT (policy DROP) target prot opt source destination
という状態になってしまい、全てのパケットが DROP されて頭を抱えることに。 必ず iptables -F の前にポリシーを確認しよう、という教訓。Chain INPUT (policy DROP) target prot opt source destination Chain FORWARD (policy DROP) target prot opt source destination Chain OUTPUT (policy DROP) target prot opt source destination
iptables の設定を大きく変更するときに少しでも不安があったら
を予め仕込んでおくことを忘れない様にしたい。(sleep 60; /etc/init.d/iptables restart) &



