I have set some rules in ufw to rate limit connections, as such:

-A ufw-user-input -p tcp --dport 25 -m state --state NEW -m recent --set
-A ufw-user-input -p tcp --dport 25 -m state --state NEW -m recent --update --seconds 6 --hitcount 12 -j ufw-user-limit
-A ufw-user-input -p tcp --dport 25 -j ufw-user-limit-accept

These are in: before.rules

I would like to white list IPs from being subject to these rules. If I run the command:

sudo ufw allow from

will this range be white-listed from my rules? Or can this be done another way?

  • 1
    The only "problem" you would have is in the order of your rules. You will need to put that rule before the others. Iptables follows rules in order.
    – Panther
    Sep 17 '14 at 19:58
  • Where does the rule: sudo ufw allow from get written to? Feel free to post in the answer, as you have answered the Q. Sep 17 '14 at 20:03

The "answer" to your question is:

sudo ufw insert 1 allow from

This will put the rule first in your rule set.

The order of rules is critical in ufw/iptables as a packet will match the first rule, subsequent rules are (for the purposes of this discussion) ignored.

To see all your rules, in order,

sudo ufw status numbered

For additional information see






Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.