HOW TO: Set Up a Firewall with UFW on Ubuntu 18.04
Posted by Asilah A. on 02 February 2021 11:08 AM
|
|
The Uncomplicated Firewall (UFW) is a frontend for iptables and is particularly well-suited for host-based firewalls. UFW provides a framework for managing net filter, as well as a command-line interface for manipulating the firewall. UFW aims to provide an easy to use interface for people unfamiliar with firewall concepts, while at the same time simplifies complicated iptables commands to help an administrator who knows what he or she is doing. UFW is an upstream for other distributions and graphical frontends. Step 1 — Setting up default policies # sudo ufw default deny incoming Note: These commands set the defaults to deny incoming and allow outgoing connections. These firewall defaults alone might suffice for a personal computer, but servers typically need to respond to incoming requests from outside users. Step 2 — Allowing SSH connections # sudo ufw allow ssh Equivalent rule by specifying the port instead of the service name: Step 3 — Enabling UFW # sudo ufw enable Step 4 — Allowing Other Connections 1) HTTP on port 80, which is what unencrypted web servers use, using # sudo ufw allow http or # sudo ufw allow 80 There are several others ways to allow other connections, aside from specifying a port or known service. ---Specific Port Ranges--- # sudo ufw allow 6000:6007/tcp ---Specific IP Addresses--- # sudo ufw allow from 111.111.1111.111 Step 5 — Denying Connections # sudo ufw deny http Step 6 — Deleting Rules # sudo ufw status numbered If you decide that you want to delete rule 1, the one that allows port 80 (HTTP) connections, you can specify it in a UFW delete command like this: # sudo ufw delete 1 Step 7 — Checking UFW Status and Rules # sudo ufw status verbose Step 8 — Disabling or Resetting UFW (optional)
If you face any difficulties on the setup, please feel free to contact our support team by submitting a ticket on https://247livesupport.biz or emailing out support team at support@247livesupport.biz | |
|