Managing firewall on Ubuntu

Following are the useful commands to manage the firewall on ubuntu using UFW

sudo ufw enable
sudo ufw disable

Default Policies

sudo ufw default deny incoming
sudo ufw default allow outgoing

Allow and deny IPs Ports and Services

sudo ufw allow ssh
sudo ufw allow 80
sudo ufw allow 1024:1050/tcp
sudo ufw allow from 2103.107.43.255
sudo ufw allow from 2103.107.43.255 to any port 22
sudo ufw allow from 2103.107.43.255/24 to any port 22

sudo ufw deny http
sudo ufw deny from 2103.107.43.255

Check the rules and delete a specific rule

sudo ufw status numbered
sudo ufw delete 2
sudo ufw delete allow https
sudo ufw delete allow 443

sudo ufw status verbose
sudo ufw reset

Leave a Reply

18 + 11 =