Debian'忽略'/etc/network/if-pre-up.d/iptables

我想我的iptables规则自动加载启动。 根据Debian上的wiki,这可以通过在/etc/network/if-pre-up.d/中放置一个名字为iptables的脚本来完成。所以我确实是这样的:

cat /etc/network/if-pre-up.d/iptables #!/bin/sh /sbin/iptables-restore < /etc/firewall/iptables.rules /sbin/ip6tables-restore < /etc/firewall/ip6tables.rules 

这个脚本的作品:如果我作为根运行它我的防火墙规则得到应用。 但重启时没有防火墙规则。 我究竟做错了什么?

根据要求:/ etc / network / interfaces(我没有碰到这个文件)

 jacko@DebianVPS:~$ cat /etc/network/interfaces # This file describes the network interfaces available on your system # and how to activate them. For more information, see interfaces(5). # The loopback network interface auto lo iface lo inet loopback # The primary network interface allow-hotplug eth0 iface eth0 inet dhcp 

为此任务使用iptables-persistent软件包。

/etc/iptables/rules.4/etc/iptables/rules.6定义你的规则,不要忘了激活服务(使用update-rc.dchkconfig或者你喜欢的工具。

这个问题可能与脚本的权限位有关。 这个命令的输出是什么? 它包括你的文件吗?

 run-parts --test /etc/network/if-pre-up.d 

为什么不这么简单呢?

1 – 创build你的iptables规则

2 – 运行“sudo apt-get install iptables-persistent”会询问你是否要保存规则并在启动后恢复它们。

3-你已经完成了