问题原文
原帖链接 · Leandro Garcia · CC BY-SA 3.0
I have this iptable rules:
-P INPUT ACCEPT
-P FORWARD ACCEPT
-P OUTPUT ACCEPT
-N fail2ban-ssh
-A INPUT -p tcp -m multiport --dports 22 -j fail2ban-ssh
-A INPUT -p tcp -m multiport --dports 22 -j fail2ban-ssh
-A INPUT -i lo -j ACCEPT
-A INPUT -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p tcp -m tcp --dport 22 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
-A INPUT -j DROP
-A fail2ban-ssh -s xx.xxx.xx.xx/32 -j REJECT --reject-with icmp-port-unreachable
-A fail2ban-ssh -j RETURN
-A fail2ban-ssh -j RETURN
The lines
-A INPUT -p tcp -m multiport --dports 22 -j fail2ban-ssh
and
-A fail2ban-ssh -j RETURN
seems to be duplicated or written twice. How can I remove the duplicate?
社区高分解答
原帖链接 · rubo77 · CC BY-SA 3.0
If you only want to delete double lines that are directly one after another you can export, unify and reimport it with
mkdir ~/tmp
iptables-save > ~/tmp/iptables.conf
uniq /tmp/iptables.conf > ~/tmp/iptables_new.conf
iptables-restore < ~/tmp/iptables_new.conf
If you want to delete other lines use an editor on ~/tmp/iptables.conf before you reimport it the same way.
Check your new rules with
iptables-save
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
