Ubuntu Firewall Command Line Examples

How do I see the current status of my firewall?
sudo ufw status verbose

How do I open tcp port # 22?
To allow incoming tcp packets on port 22, enter:
sudo ufw allow 22/tcp

Verify it:
sudo ufw status verbose

How do I open tcp port # 80 and 443?
The service specific syntax is as follows to open http and https service ports:

sudo ufw allow http
sudo ufw allow https

sudo ufw allow 80/tcp
sudo ufw allow 443/tcp

How do I open tcp and udp port # 53?
To allow incoming tcp and udp packet on port 53, enter:
sudo ufw allow 53

Verify it:
sudo ufw status verbose

To allow IP address 192.168.1.10 access to port 22 for all protocols
sudo ufw allow from 192.168.1.10 to any port 22

To allows subnet 192.168.1.0/24 to Samba services, enter:
ufw allow from 192.168.1.0/24 to any app Samba

You can find service info as follows:
sudo ufw app list

To get information on Squid profile/app, run:
ufw app info Squid

This entry was posted in Linux, Ubuntu. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *