Enable and Setup UFW on Ubuntu

UFW or Uncomplicated FireWall, comes with Ubuntu and some other Linux distributions. This video shows how to install and configure it on your system.

Video

The Script

#!/bin/bash

###############################################################################
# Video Title: Enable and setup UFW on Ubuntu
# Author: Kenny Robinson, @almostengr
# Video: https://youtu.be/sgMuFbtOPWU
###############################################################################

if [ "$(id -u)" == "0" ]; then
    ufw status
    ufw enable
    ufw status
    ufw allow 22
    ufw status
    ufw allow 80
    ufw allow 443
    ufw status
    ufw status numbered
    ufw delete 6
    ufw status
else
    echo "ERROR: Must be root to run script. Re-run script using"
    echo "sudo bash <scriptname>"
fi
Updated: 2023-02-14 | Posted: 2017-11-14
Author: Kenny Robinson