Solution 1
If those rules are permanent and therefore located in the /etc/iptables/rules.v4
and etc/iptables/rules/v6
files, then you can just edit both files and move the rules to fit the desired order, something like:
-A INPUT -s 6.5.5.5 -j ACCEPT
-A INPUT -s 5.5.5.5 -j DROP
Restart iptables (service iptables restart
)
Solution 2
What I would do if there were only a few rules, like in your case, will be to delete the first rule and recreate it:
iptables -nL --line-numbers
Get the number of the rule you want to reorder (in your example would be 1) delete it and create it again, this will place the newlly created rule last in the table:
iptables -D INPUT 1
iptables -A INPUT -s 5.5.5.5 -j DROP`