A Quick Guide Through UFW: Uncomplicated Firewall
UFW, short for Uncomplicated Firewall, is basically a simplified firewall mechanism that is implemented upon IPtables itself, making it much easier to configure UFW.
Join the DZone community and get the full member experience.Join For Free
UFW, short for Uncomplicated Firewall, is basically a simplified firewall mechanism that is implemented upon IPtables itself, making it much easier to configure UFW than to configure IPtables. Therefore, it can be said that UFW is technically a program for managing a netfilter firewall which aims to provide an easy to use interface for the user.
The Need for UFW: Uncomplicated Firewall
Consider a situation where protocols like ssh, ftp, etc., which if left open for everyone and anyone to connect, might result in a massive security breach by the attackers or malicious users. Hence, this originated the need for a firewall. Firewall is useful to us in a way, that it allows us the remote access to the system but in a limited fashion. A simple example would be, firewall can allow certain ports to be left open to only a few IP addresses to limit security breach and also allowing connections to only a trusted device.
Thus, if we do not lock down ssh or ftp or for that matter, any other protocol, we are creating a massive vulnerability to our system by letting ssh or other protocol’s designated port open for everyone to access. But with the help of firewalls, we provide remote access along with security lock down to avoid malicious users or hackers to gain access to the system. UFW aims to provide an easy to use interface for people who are unfamiliar with firewall’s basic concepts.
Also, at the same time, UFW simplifies complicated IPtables commands and thus help an administrator perform at better efficiency.
Basic Commands to Understand the Functioning of UFW
Before starting with practicing a few commands, first of all make sure that you have UFW installed on your system. By default, UFW is already installed in Ubuntu, but if in any case, UFW is not present, you can try installation by running the following commands:
sudo apt install ufw
sudo apt-get install ufw
Let’s Start With Basic Commands:
- To enable ufw,
sudo ufw enable
- To disable ufw,
sudo ufw disable
- To check the status of the ufw rules,
sudo ufw status verbose
– The status is inactive if UFW is disabled.
– If ufw is enabled, it’s status is active.
Here, the default includes:
- deny (incoming): This will make sure that no outside system can connect to your machine.
- allow (outgoing): This means that all outgoing request are enabled.
- disabled (routed): This means that all routing is disabled and forwarding is blocked.
- To add a rule,
sudo ufw allow port_number
- To allow a specific IP,
sudo ufw allow from ip_addressto any port
- To allow an IP range,
sudo ufw allow from ip_address/24to any port
- To allow a specific protocol,
sudo ufw allow protocol_name
- To check for status along a serial number with it,
sudo ufw status numbered
- To remove a connection,
sudo ufw delete serial_number
- To deny a rule,
sudo ufw deny protocol_name
- To reset connections,
sudo ufw reset
The reset command is an alternative to deleting each rule one by one.
This is just an overview of the concept and few commands of UFW to practice.
Hope it helps.
Opinions expressed by DZone contributors are their own.