Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linux iptables:删除索引太大BASH_Linux_Bash_Iptables - Fatal编程技术网

Linux iptables:删除索引太大BASH

Linux iptables:删除索引太大BASH,linux,bash,iptables,Linux,Bash,Iptables,我在设置默认iptables脚本时遇到一些困难,因为它无法运行。它显示错误:iptables:删除的索引太大 我尝试重新排序规则,尝试在添加之前先删除所有规则,等等,但似乎没有帮助。我做错了什么 以下是脚本: #!/bin/bash iptables -P FORWARD DROP iptables -D FORWARD 1 iptables -P INPUT DROP iptables -D INPUT 5 iptables -D INPUT 4 iptables -I INPUT -p t

我在设置默认iptables脚本时遇到一些困难,因为它无法运行。它显示错误:iptables:删除的索引太大 我尝试重新排序规则,尝试在添加之前先删除所有规则,等等,但似乎没有帮助。我做错了什么

以下是脚本:

#!/bin/bash

iptables -P FORWARD DROP
iptables -D FORWARD 1
iptables -P INPUT DROP
iptables -D INPUT 5
iptables -D INPUT 4
iptables -I INPUT -p tcp --dport 22 -j ACCEPT
iptables -D INPUT 3
iptables -I INPUT -p icmp -j ACCEPT
原始IP表如下所示:

Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination         
  119 13723 ACCEPT     all  --  any    any     anywhere             anywhere             state RELATED,ESTABLISHED
    0     0 ACCEPT     icmp --  any    any     anywhere             anywhere            
    0     0 ACCEPT     all  --  lo     any     anywhere             anywhere            
    1    60 ACCEPT     tcp  --  any    any     anywhere             anywhere             state NEW tcp dpt:ssh
    0     0 REJECT     all  --  any    any     anywhere             anywhere             reject-with icmp-host-prohibited

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination         
    0     0 REJECT     all  --  any    any     anywhere             anywhere             reject-with icmp-host-prohibited

此脚本没有设置输入表条目5,因此您希望如何可靠地删除它?要了解其工作原理,我们需要在脚本运行之前查看表的存在状态,并且任何分析仅在该启动状态下有效。此外,这完全不是bash特有的。如果从Python、Java、C等运行相同的iptables命令,将内容格式化为代码,选择它并单击{}按钮,则会出现完全相同的问题。顺便说一句,如果这有助于理解文化的话——实际上,回到网站最初的创建阶段,目标是建立一个良好的问答知识库;帮助人们提出问题与其说是公开的目标,不如说是这一过程的副作用。理想情况下,我们最终会到达一个几乎所有人都能发现自己的问题已经被提出和回答的地方,而不需要再问一个新的问题……因此,我们非常关心问题是否能被广泛化,从而对其他人有所帮助;有好的标题、准确的标签等。