Add a Port
$ sudo ufw allow 33/tcp
Tips: When looking at rules, use
ufw status numbered because it gives line numbers with output that may be used later.
Block an IP address
$ sudo ufw insert 1 deny from [ip-to-block] to any
1 above shows the order of the insert.
You can insert a rule without an order numeric:
sudo ufw deny from [ip-to-block]
ufw deny from a.b.c.0/24 to any
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
First Show all rules
$ sudo ufw delete 19