You can add comments to UFW firewall rules by using the ufw
command-line tool. UFW allows you to add comments to the end of a rule using the --comment
option.
To add a comment to an existing rule, you can use the ufw insert
command to insert a new rule before an existing rule, and include the --comment
option with your comment. For example, to add a comment “Allow SSH” to the rule allowing incoming SSH traffic:
ufw insert 1 comment 'Allow SSH' allow 22
You can also add comments to rules when you create them. For example, to add a comment “Allow HTTP” to the rule allowing incoming HTTP traffic:
ufw allow 80/tcp comment 'Allow HTTP'
You can also use the ufw status numbered
command to check the status of the firewall, it will show the rules with numbers and comments.
ufw status numbered
It’s important to know that comments are only used for documentation and do not affect the operation of the firewall, also the comment is limited to 256 characters and it’s not case sensitive.