i have 2 rules of iptables
iptables -A INPUT -s 5.5.5.5 -j DROP
iptables -A INPUT -s 6.5.5.5 -j ACCEPT
is there a function or a command that will swap the rules to be like this:
iptables -A INPUT -s 6.5.5.5 -j ACCEPT
iptables -A INPUT -s 5.5.5.5 -j DROP
First check the line number:
iptables -nL --line-numbers
Delete based on line:
iptables -D INPUT {line}
Insert where you would like it to be:
iptables -I INPUT {line} -i lo -p tcp --dport {port} -j ACCEPT -m comment --comment "This rule is here for this reason"
Found at these sources: