Shammer's Philosophy

My private adversaria

iptables auto configuration

Debianで宛先ごとにルートを変更する - Shammerismで作成した iptables-save のファイルは複数のインタフェースごとに設定される内容。そのため、/etc/network/interfacesで、それぞれのインタフェースごとにpre-up iptables-restore < $iptable-rule-ethX みたいな書き方をしたが、再起動してみると反映されたのは最後の一回分のみだった。
そこで、別の方法を調査。/etc/network/if-pre-up.dとか、これらのディレクトリの配下に iptables-restore を実行するようなスクリプトを定義することで対処。

# cat /etc/network/if-pre-up.d/load-default-iptables 
#!/bin/bash
/sbin/iptables-restore < /etc/iptables.up.rules
# chmod 755 /etc/network/if-pre-up.d/load-default-iptables
#