How to solve these challenges:
Write your solution as root at the terminal or inside a shell script, make the script file executable and run it.
If your solution is not correct, then try to understand the error messages, rewrite the solution and execute the command or script again. Repeat this step until you get the correct solution.
Save the solution in a file for future reference or recap.
Challenge #1
Write the iptables commands that set the default POLICY to ACCEPT on INPUT and OUTPUT chains and DROP on FORWARD chain.
Are you stuck? Do you want to see the solution for this exercise? Click here.
Challenge #2
Write the iptables command that lists only the filter table of INPUT chain.
Are you stuck? Do you want to see the solution for this exercise? Click here.
Challenge #3
Write the iptables commands that list the nat table.
Are you stuck? Do you want to see the solution for this exercise? Click here.
Challenge #4
Write the iptables command that flushes the filter table of all chains.
Are you stuck? Do you want to see the solution for this exercise? Click here.
Challenge #5
Write an iptables rule that drops all incoming packets to port 22/tcp (ssh). This should be the first rule in the chain.
Are you stuck? Do you want to see the solution for this exercise? Click here.
Challenge #6
Write the iptables commands that flush all the tables of all chains and set the ACCEPT policy on all chains. This will delete any firewall.
Are you stuck? Do you want to see the solution for this exercise? Click here.