一、对 iptables 作必要的修改;
二、将 iptables 规则保存到文件中:
iptables-save > /etc/firewall.conf
三、新建一个脚本 /etc/network/if-up.d/import-iptables
:
#!/bin/sh
iptables-restore < /etc/firewall.conf
加上可执行权限:
chmod +x /etc/network/if-up.d/import-iptables
该脚本会在网络接口初始化后自动运行。