OPS335 Firewall Lab

From CDOT Wiki
Revision as of 14:59, 5 September 2011 by Paul.W (talk | contribs) (Instructions)
Jump to: navigation, search


Basic IP Tables

In this lab you will learn how to use iptables to build a simple Linux firewall.


Instructions

Building a Simple Firewall

  1. Login as joker to your Fedora 13 PC. NOTE: It's not necessary to use a VM for this lab. Just use your original Fedora system created in lab #0.
  2. Open a terminal window and "su -" to root.
  3. Disable your current firewall. i.e. flush all rules in all chains in all tables.

Building a Custom Firewall=

Build a custom firewall by performing the following steps:

  1. Add appropriate rule(s) to allow all traffic to/from the loopback 'lo' interface.
  2. Add a rule to the INPUT chain of the filter table to allow all UDP traffic coming from port 53. i.e. source port is 53.
  3. Add a rule to the INPUT chain of the filter table to allow all ESTABLISHED or RELATED incoming connections.
  4. Create a new chain named MYSSH in the filter table.
  5. Add a rule to the INPUT chain of your filter table that sends all tcp packets with destination port 22 to your MYSSH chain.
  6. Add a rule to your MYSSH chain to deny all traffic from 142.204.141.XXX (XXX is the PC beside you). Also log these denied packets with log level 'info'.
  7. Add a rule to the INPUT chain of the filter table that allows all new tcp ssh connections.
  8. Make a new chain named MYICMP in the filter table.
  9. Add a rule to your MYICMP chain that denies ICMP pings from 142.204.141.XXX (the PC beside you).
  10. Add a rule to your MYICMP chain that denies ICMP pings originating with MAC address of 11:22:33:44:55:66 (NOTE: to test this you'll have to change the MAC address of the PC beside you with the ifconfig command).
  11. Add a rule to your MYICMP chain that allows ICMP pings from anywhere.
  12. Add a rule to the INPUT chain of the filter table to send ICMP ping packets to your MYICMP chain.
  13. Change the default policy on the INPUT chain in the filter table to DROP.
  14. Use nmap to scan your firewall from 142.204.141.XXX. If you don't have nmap on your system then install it.
  15. Use ping and ssh from 142.204.141.XXX (and elsewhere) to verify your firewall is working properly. Be sure to check the log file for your unsuccessful ssh attempts.
  16. Use iptables-save command to save your firewall rules.

Completing the Lab

Answer the following questions

  1. What is your full name and Seneca student ID?
  2. Show your firewall rules using the output of the iptables-save command.
  3. Show the results of your nmap scans from part A. Be sure to also show the exact nmap command you used.
  4. Show the log records generated by your invalid ssh attempts in part A.
  5. What iptables rule would you need to add to your firewall to allow a maximum of 3 concurrent ssh connections from 142.204.141.XXX to your host?