ubuntu ufw Firewall Settings

Configuring Firewall Settings with ufw in Ubuntu

This article explains firewall configuration in Ubuntu. We introduce the basic usage of ufw.

Shou Arisaka
1 min read
Oct 20, 2025

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 can insert or delete rules.
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:

Share this article

Shou Arisaka Oct 20, 2025

๐Ÿ”— Copy Links