ufw: Uncomplicated Firewall
August 9th, 2024 2:32 PM Mr. Q Categories: Command
Description: A user-friendly frontend for managing firewall rules on Linux. ufw
is designed to make configuring a firewall easier by providing a straightforward command-line interface.
- Basic Usage:
ufw [options] [command]
- Common Commands:
enable
: Enable the firewall.disable
: Disable the firewall.status
: Show the status of the firewall and current rules.allow [port]
: Allow incoming traffic on the specified port.deny [port]
: Deny incoming traffic on the specified port.delete [rule]
: Delete a rule.reset
: Reset all rules to their default state.
Command to Enable UFW
$ sudo ufw enable
Firewall is active and enabled on system startup
Command to Check UFW Status:
$ sudo ufw status
Status: active
To Action From
-- ------ ----
22/tcp ALLOW Anywhere
80/tcp ALLOW Anywhere
22/tcp (v6) ALLOW Anywhere (v6)
80/tcp (v6) ALLOW Anywhere (v6)
Command to Allow Incoming Traffic on Port 8080:
$ sudo ufw allow 8080
Rule added
Command to Deny Incoming Traffic on Port 3306:
$ sudo ufw deny 3306
Rule added
Command to Reset UFW Rules:
$ sudo ufw reset
Resetting all rules to installed defaults. Proceed? [y/n]: y
Note: Always be careful when configuring firewall rules to avoid accidentally blocking necessary services.