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
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]
E.g.
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
Delete Rule
First Show all rules
$ sudo ufw delete 19
See Also
https://kb.vander.host/web-servers/how-to-setup-ssh-nginx-ufw-and-mysql-on-a-new-ubuntu-server/
Reference
https://serverfault.com/questions/484475/ufw-firewall-rules-ordering