This article explains firewall configuration in Ubuntu. We introduce the basic usage of ufw.
-
General commands status, enable, disable, reload, delete, allow, deny, default (allow|deny)
-
First enable it
sudo ufw enable
- Disable it when not needed as itโs dangerous.
sudo ufw disable
- Based on the list displayed by
status, you caninsertordeleterules.
sudo ufw delete 2
- Delete all
sudo ufw reset
- When there are many rules, numbering is convenient
sudo ufw status numbered
- Example of allowing access to 22/tcp
sudo ufw allow 22/tcp
- Example of allowing access to 22/tcp from 192.168.3.9
sudo ufw allow from 192.168.3.9 to any port 22 proto tcp
- It seems you can also specify Ubuntu services like servers
sudo ufw app list
ufw allow from 192.168.1.0/24 to any app Samba
References:
- (https://www.cyberciti.biz/faq/how-to-open-firewall-port-on-ubuntu-linux-12-04-14-04-lts/)[https://www.cyberciti.biz/faq/how-to-open-firewall-port-on-ubuntu-linux-12-04-14-04-lts/]
- (https://help.ubuntu.com/community/UFW#Delete_Existing_Rule)[https://help.ubuntu.com/community/UFW#Delete_Existing_Rule]