UFW Setup
UFW Setup
Section titled “UFW Setup”UFW (Uncomplicated Firewall) is a user-friendly interface for managing firewall rules on Linux systems. It simplifies the process of configuring iptables, making it easier to set up and manage firewall rules.
Installation
Section titled “Installation”To install UFW, use the following command:
sudo apt install ufwEnabling UFW
Section titled “Enabling UFW”To enable UFW, run:
sudo ufw enableAllowing Connections
Section titled “Allowing Connections”To allow connections, which is essential, use the following command:
sudo ufw allow sshsudo ufw default deny incomingsudo ufw default allow outgoingsudo ufw allow in on tailscale0sudo ufw allow httpsudo ufw allow httpsYou can also specify port numbers directly, like so:
sudo ufw allow 8080/tcpDenying Connections
Section titled “Denying Connections”To deny connections to a specific port or service, you can use the deny command. For example, to deny all incoming traffic on port 23 (Telnet), you can run:
sudo ufw deny 23Allowing Specific IP Addresses
Section titled “Allowing Specific IP Addresses”To allow traffic from a specific IP address, you can use the allow from command. For example, to allow traffic from the IP address `
Checking UFW Status
Section titled “Checking UFW Status”To check the status of UFW and see which rules are currently applied, use:
sudo ufw statusDisabling UFW
Section titled “Disabling UFW”To disable UFW, you can run:
sudo ufw disableResetting UFW
Section titled “Resetting UFW”To reset UFW to its default state, removing all rules, use:
sudo ufw resetDeleting Rules
Section titled “Deleting Rules”To delete a specific rule, you can use the delete command followed by the rule you want to remove. For example, to delete the rule allowing HTTP traffic, you can run:
sudo ufw delete allow httpYou can also delete entries using this method:
ufw status numberedCheck for the number that is related to the rule and then run:
ufw delete <nmbr>Conclusion
Section titled “Conclusion”UFW is a powerful tool for managing firewall rules on Linux systems. By following the steps outlined above, you can easily set up and configure UFW to enhance the security of your server. Remember to regularly review and update your firewall rules to ensure that only necessary services are allowed through the firewall.