Introductio for UFW Essentials
UFW (uncomplicated firewall) is a firewall configuration tool that runs on top of iptables, included by default within Ubuntu distributions. It provides a streamlined interface for configuring common firewall use cases via the command line.
This cheat sheet-style guide provides a quick reference to common UFW use cases and commands, including examples of how to allow and block services by port, network interface, and source IP address.
Matching infrastructure at centron
Ubuntu servers without your own hardware: ccloud³ VMs with full root access from €3.12 per month, billed by the hour and ready in seconds. Rent a cloud server →
How To Use This Guide for UFW Essentials
- This guide is in cheat sheet format with self-contained command-line snippets.
- Jump to any section that is relevant to the task you are trying to complete.
- Highlighted text in commands should refer to IP addresses from your network.
- Check your current UFW ruleset with
sudo ufw statusorsudo ufw status verbose.
Verify UFW Status
To check if UFW is enabled, run:
sudo ufw statusOutput:
Status: inactiveEnable UFW
If the firewall is inactive, enable it using:
sudo ufw enableOutput:
Firewall is active and enabled on system startupUse sudo ufw status verbose to see what is blocked or allowed:
Status: active
Logging: on (low)
Default: deny (incoming), allow (outgoing), deny (routed)
New profiles: skipDisable UFW
To disable the firewall service, run:
sudo ufw disableNote: This will fully disable the firewall service on your system.
UFW Essentials: Block an IP Address
To block all network connections from a specific IP address:
sudo ufw deny from 203.0.113.100Output:
Rule addedAllow an IP Address
To allow all network connections from a specific IP address:
sudo ufw allow from 203.0.113.101Output:
Rule addedDelete UFW Rule
To delete a rule, use:
sudo ufw delete allow from 203.0.113.101Alternatively, use rule ID:
sudo ufw delete 1Allow HTTP and HTTPS Traffic
To allow both HTTP and HTTPS traffic:
sudo ufw allow proto tcp from any to any port 80,443Output:
Rule addedConclusion for UFW Essentials
UFW is a powerful tool that enhances server security when configured correctly. It simplifies managing firewall rules efficiently. Use this guide as a quick reference for common firewall rules. With UFW, you can easily allow or block specific ports and IP addresses. Customize your server’s traffic to meet unique needs securely. Proper configuration ensures reliable protection against unauthorized access attempts.
Testen Sie Ihr Setup auf ccloud³
Registrieren Sie sich in der ccloud³ und erhalten Sie 200 € Startguthaben für Ihr Projekt – z. B. für eine PostgreSQL-VM mit automatischen Backups.