Configuring a Host Firewall on Ubuntu using UFW

15 minutes
  • 5 Learning Objectives

About this Hands-on Lab

In this lab, we will install and configure a firewall on an Ubuntu host using UFW. We will create the firewall rules to permit only VNC, HTTP, and SSH traffic inbound to the host and permit all outbound traffic from the host.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Install UFW.

Run the commands sudo apt-get update and sudo apt-get install -y ufw.

Configure the default rules to deny all inbound and permit all outbound.

Run the following commands:

  • sudo ufw default deny incoming
  • sudo ufw default allow outgoing
Configure UFW to permit only VNC, HTTP, and SSH traffic to the Ubuntu host.

Run the following commands:

  • sudo ufw allow 22
  • sudo ufw allow 80
  • sudo ufw allow 5900:5901/tcp
Enable UFW.

Run the command sudo ufw enable.

Install the Lighttpd web server.

Run the following command: sudo apt-get install -y lighttpd

Additional Resources

Your supervisor has assigned you a project which includes installing the Lighttpd web server and setting up a host-based firewall using UFW on an Ubuntu server. By default, all outbound traffic should be permitted, and all inbound traffic should be denied. This server hosts some services, so you'll need to allow for the following services to be permitted inbound:

  • SSH
  • HTTP
  • VNC

Once all of these rules are configured, enable the firewall and verify SSH, HTTP, and VNC connectivity.

Connecting to the lab:

  1. Use VNC on your computer to connect to the public IP address of the instance on port 5901 (x.x.x.x:5901).
  2. Log in with the username and password generated by the lab.

What are Hands-on Labs

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!

Get Started
Who’s going to be learning?