What is UFW ?
It is called as
How to check if UFW is enabled or not ?
You can use below command to check if UFW is enabled or not:
$ sudo ufw status
If it is not enabled then status will be shown as inactive. If it is active then status will be shown as active.
To enable UFW use below command:
$ sudo ufw enable
How to add rules in UFW configuration?
Its easy to add rules in UFW configuration, please read below steps to see how you can up different rules in configuration as per your usecase.
To allow all incoming http:
$ sudo ufw allow http
$ sudo ufw allow 80
To allow all incoming https:
$ sudo ufw allow https
$ sudo ufw allow 443
To allow all incoming ssh:
$ sudo ufw allow ssh
$ sudo ufw allow 22
To allow incoming ssh from a fixed ip range:
$ sudo ufw allow from 10.11.12.0/24 to any port 22
To allow incoming on mysql port 3306 from a fixed ip range:
$ sudo ufw allow from 10.11.12.0/24 to any port 3306
To block all connections from a particular ip:
$ sudo ufw deny from 18.104.22.168
To block outbound connections on port 25:
$ sudo ufw deny out 25
How to check rules you have added?
For checking rules you added, you can check them using below command in a serial order.
$ sudo ufw status numbered
How to delete any rule?
For deleting any rule check its number through above command, and simply use below command:
$ sudo ufw delete 2
This will delete rule number 2, if you have to delete any other rule, please check