How to Use UFW (Uncomplicated Firewall)

Published: (January 6, 2026 at 11:10 PM EST)
1 min read
Source: Dev.to

Source: Dev.to

Basic Penggunaan UFW di Ubuntu Server 24.04

UFW (Uncomplicated Firewall) adalah firewall bawaan Ubuntu/Debian yang berfungsi untuk mengatur lalu lintas jaringan (port dan IP) agar server menjadi lebih aman.

Status

ufw status

Enable / Disable

ufw enable   # mengaktifkan UFW
ufw disable  # menonaktifkan UFW

Membuka Port

Contoh: membuka port SSH (port 22).

ufw allow 22/tcp

Membatasi Akses dari IP Tertentu

Misalnya hanya mengizinkan IP 10.10.10.5 untuk mengakses port 22.

ufw allow from 10.10.10.5 to any port 22 proto tcp

Membatasi Akses dari Subnet

Misalnya mengizinkan seluruh subnet 10.10.10.0/24 untuk mengakses port 22.

ufw allow from 10.10.10.0/24 to any port 22 proto tcp

Melihat Semua Rule

ufw status

Untuk menampilkan urutan rule:

ufw status numbered

Menghapus Rule

Gunakan nomor urutan yang ditampilkan oleh ufw status numbered.
Contoh: menghapus rule pada urutan ke‑2.

ufw delete 2

Semoga bermanfaat!

Back to Blog

Related posts

Read more »

Hello, Newbie Here.

Hi! I'm falling back into the realm of S.T.E.M. I enjoy learning about energy systems, science, technology, engineering, and math as well. One of the projects I...