Skip to content

Firewall UFW

UFW : uncomplicated Firewall.

  • Get status

sudo ufw status verbose
* Enable or disable Firewall

sudo ufw Enable
sudo ufw disable
* Open port 502 for TCP packets
sudo ufw allow 502/tcp
  • Default port for SSH

sudo allow ssh
sudo deny ssh
* Open port 3389 to a subnet

sudo ufw allow from 153.109.5.0/24 to any port 3389
* View the rules with their number

sudo ufw status numbered
* Remove a rule with its number

sudo ufw delete <rule number>
* Open a port range to TCP traffic
sudo ufw allow 58000:60999/tcp

!!! note With port range, the protocol part (tcp, udp, ...) is mandatory.