Che*_*ron 15 networking debian 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
Run Code Online (Sandbox Code Playgroud)
这个脚本有效:如果我以 root 身份运行它,我的防火墙规则就会被应用。但是在重新启动时没有防火墙规则。我究竟做错了什么?
根据要求:/etc/network/interfaces(我没有碰过这个文件)
user@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
Run Code Online (Sandbox Code Playgroud)
epp*_*uig 11
此问题可能与脚本的权限位有关。这个命令的输出是什么?它包括你的文件吗?
run-parts --test /etc/network/if-pre-up.d
Run Code Online (Sandbox Code Playgroud)
将iptables-persistent
包用于此任务。
在/etc/iptables/rules.4
和 中定义您的规则,/etc/iptables/rules.6
不要忘记激活服务(使用update-rc.d
,chkconfig
或者您最喜欢的工具。
归档时间: |
|
查看次数: |
15359 次 |
最近记录: |