Skip to main content

Permitting and Blocking Traffic with the Firewall

Hands-On Lab

 

Photo of Michael Christian

Michael Christian

Course Development Director in Content

Length

00:30:00

Difficulty

Intermediate

In this hands-on lab, you will need to configure Server1 (10.0.1.10) so that it only permits HTTP connections (port 80) from Client1 (10.0.1.11).

What are Hands-On Labs?

Hands-On Labs are scenario-based learning environments where learners can practice without consequences. Don't compromise a system or waste money on expensive downloads. Practice real-world skills without the real-world risk, no assembly required.

Permitting and Blocking Traffic with the Firewall

Introduction

In this hands-on lab, you will need to configure Server1 (10.0.1.10) so that it only permits HTTP connections (port 80) from Client1 (10.0.1.11).

Solution

  1. Begin by logging in to the lab server using the credentials provided on the hands-on lab page:

    ssh cloud_user@PUBLIC_IP_ADDRESS

  2. Become the root user:

    sudo su -

Verify that a firewall is running

  1. You should already have iptables started and running. You can verify this with:

    systemctl status iptables

Verify that the host listening on port 80

  1. You'll want to verify that the host has a service listening on port 80. You can do so using the following command:

    ss -lntp | grep :80

You should see that port 80 is listening for the httpd process.

Verify that port 80 is blocked, and add a rule to permit traffic coming from 10.0.1.11

  1. From Client1 (10.0.1.11), try to curl 10.0.1.10:

    curl 10.0.1.10

  2. You'll need to add a rule to permit the traffic:

    Note: This command should be run on Server1 (10.0.1.10).

    iptables -I INPUT -p tcp -s 10.0.1.11 --dport 80 -j ACCEPT

  3. Test from Client1 again, and also with Client2. If Client1 is successful and Client2 isn't, save your existing chain with:

    service iptables save

Conclusion

Congratulations — you've completed this hands-on lab!