How to block an IP address with UFW (uncomplicated firewall)


$ sudo ufw insert 1 deny from [ip-to-block] to any

The 1 above shows the order of the insert.

You can insert a rule without an order numeric:
$ sudo ufw deny from [ip-to-block]

If you’ve already inserted a rule and it doesn’t work, check the order as per the sequence below:

Show all rules

$ sudo ufw status numbered

Delete Rule

First Show all rules

$ sudo ufw delete 19


Share this article

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to Top