How To Setup a Firewall with UFW on an Ubuntu Print

  • 12

UFW - Uncomplicated Firewall
The default firewall configuration tool for Ubuntu is ufw. Developed to ease IP-tables firewall configuration, ufw provides a user-friendly way to create an IPv4 or IPv6 host-based firewall. By default UFW is disabled.

Step 1: Enabling / Disabling ufw

To enable it, you just need to type the following command at the terminal.

[root@localhost]# sudo ufw enable

Firewall is active and enabled on system startup

To disable it, just type.

[root@localhost]# sudo ufw disable

Step 2: List the current ufw rules

After the firewall is activated you can add your rules into it. If you want to see what are the default rules, you can type.

[root@localhost]# sudo ufw status verbose

sample output:

        Status: active
        Logging: on (low)
        Default: deny (incoming), allow (outgoing)
        New profiles: skip
    

Step 3: Adding specific rules to ufw

You can specify or add the port range which you want to setup with ufw.

[root@localhost]# sudo ufw allow /

Example: To allow incoming tcp and udp packet on port 22

[root@localhost]# sudo ufw allow 22

Example: To allow incoming tcp packets on port 22

[root@localhost]# sudo ufw allow 22/tcp

Example: To allow incoming udp packets on port 22

[root@localhost]# sudo ufw allow 22/udp

Thats it!!


Was this answer helpful?

« Back