这是非常令人费解的。
在VPS上的Centos 6.4。
iptables -L工作,我可以使用iptables命令根据需要input规则和删除规则。 我甚至可以在sysconfig /中看到保存的规则,它们是正确的。
但是,iptables-restore </etc/iptables.firewall.rules总是失败:
FATAL: Module ip_tables not found. 'ptables-restore v1.4.7: iptables-restore: unable to initialize table 'filter Error occurred at line: 1
我的规则如下(逐字)。 他们是在教程中linodebuild议的副本。
*filter # Allow all loopback (lo0) traffic and drop all traffic to 127/8 that doesn't use lo0 -A INPUT -i lo -j ACCEPT -A INPUT -d 127.0.0.0/8 -j REJECT # Accept all established inbound connections -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT # Allow all outbound traffic - you can modify this to only allow certain traffic -A OUTPUT -j ACCEPT # Allow HTTP and HTTPS connections from anywhere (the normal ports for websites and SSL). -A INPUT -p tcp --dport 80 -j ACCEPT -A INPUT -p tcp --dport 443 -j ACCEPT # Allow SSH connections but block (slow) brute force attempts # The -dport number should be the same port number you set in sshd_config # -A INPUT -p tcp -m state --state NEW --dport 22 -j ACCEPT -I INPUT -p tcp --dport 22 -m state --state NEW -m recent --set -I INPUT -p tcp --dport 22 -m state --state NEW -m recent --update --seconds 600 --hitcount 10 -j DROP # Allow ping -A INPUT -p icmp -j ACCEPT # Drop all other inbound - default deny unless explicitly allowed policy -A INPUT -j DROP -A FORWARD -j DROP COMMIT
应该遵循单词filter的单引号的方式已经迁移回到行的开头,这使得我非常怀疑规则文件在行的末尾包含虚假的^M字符,并且iptables实际上是抱怨它can't initialise table 'filter^M' – 它肯定不能,没有这样的表。
这个非打印(因此很难看) ^M将来自上面引用的文件的第一行,如果它实际上是*filter^M
最简单的方法是用二进制模式vi -b /etc/sysconfig/iptables打开文件, vi -b /etc/sysconfig/iptables (我假设这是上面引用的文件),然后查找非打印字符不在那里。
这样的angular色怎么可能到达那里我不能肯定地说,但是我经常发现在附近有一个Windows箱子的恶劣的存在与伪装回车的外观相关。
编辑 :由于这似乎是问题,我可以做一个小小的,认真的build议“可以从这一集中学到的东西”? 即:在debugging免费软件时,详细的exception情况非常重要。
商业软件由于非技术原因做事情,所以很多时候都不能从明显的exception情况中推断出来。 但自由软件往往不这样做; 如果在一个通常没有的行的开头出现单引号,通常会有一个技术原因 – 这对debugging有很大的帮助。