Blocking and Allowing Traffic with a Firewall

1 hour
  • 2 Learning Objectives

About this Hands-on Lab

For the Security+ Exam, it is important to understand how firewall rules work. In this hands-on lab, we will configure a couple of firewall rules on iptables, which is built into CentOS. After completing this lab, you will understand how firewall rules work in a hierarchical manner to allow and block traffic.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Create a Bash Script

Add four iptables rules that modify Chain INPUT in your Bash script:

  1. Flush the current iptables rules.
  2. Create a rule that accepts already established connections and any related packets.
  3. Create a rule that accepts all SSH traffic.
  4. Change the policy of Chain INPUT to drop all incoming traffic.
Run the Bash Script
  1. After running your Bash script, run sudo iptables -L again.
  2. Compare and contrast the default rules to those you put into place with your Bash script. (You should get a feel for how the policy works to block any traffic not specifically allowed as well as how firewall rules look.)

Additional Resources

You have been tasked with ensuring that the firewall rules allow SSH traffic and any other traffic that is already established, as well as ensuring that the INPUT chain is changed to a DROP policy. Iptables is already installed and a service is running. Start by running the sudo iptables -L command to get a full list of all current rules.

Note: Please wait an extra 2-3 minutes before connecting via SSH to allow the lab to fully finish provisioning. Please read all of the tasks prior to running any other commands, as creating the rules out of order will terminate your current session.

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?