A few UFW tidbits

Here are some of the common UFW rule management commands that I seem to always forget...

  1. View rules in numbered format:
    sudo ufw status numbered
  2. Add an allow rule with comment:
    sudo ufw allow from <IP> to any port <#> comment "Comment goes here"
  3. Add an deny rule with comment:
    sudo ufw deny from <IP> to any port <#> comment "Comment goes here"
  4. Add an deny rule to all ports:
    sudo ufw deny from <IP> to any
  5. Insert a rule at the head of the rule chain:
    sudo ufw insert 1 deny from <IP> to any port <#>
  6. Delete a rule (usually after viewing numbered rules):
    sudo ufw delete <#>