#!/bin/bash
iptables -F
iptables -t nat -F
iptables -X
iptables -t nat -X
iptables -P INPUT DROP
iptables -P OUTPUT DROP
iptables -P FORWARD DROP
iptables -A INPUT -i lo -j ACCEPT
iptables -A INPUT -i eth1 -p tcp -s 192.168.167.0/24 --dport 22 \
-m state --state NEW -j ACCEPT
iptables -A INPUT -i eth1 -p tcp -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A OUTPUT -o lo -j ACCEPT
iptables -A OUTPUT -o eth1 -p tcp -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -t nat -A PREROUTING -i eth0 -p tcp -d 133.172.114.17 --dport 25 \
-j DNAT --to-destination 192.168.167.23:25
iptables -t nat -A POSTROUTING -o eth0 -p tcp -s 192.168.167.0/24 \
-j SNAT --to-source 133.172.114.17
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -A FORWARD -i eth1 -p tcp -s 192.168.167.0/24 --dport 80 \
-m state --state NEW -j ACCEPT
iptables -A FORWARD -i eth1 -p tcp -s 192.168.167.0/24 --dport 443 \
-m state --state NEW -j ACCEPT
iptables -A FORWARD -i eth0 -p tcp -d 192.168.167.23 --dport 25 \
-m state --state NEW -j ACCEPT
iptables -A FORWARD -p tcp -m state --state RELATED,ESTABLISHED -j ACCEPT
With this firewall script, I'm needing to answer this question:
For the following four groups of iptables commands, explain:
• the overall effect of each group of commands, and
• the purpose of each command within the group.
- lines 12 and 18,
- lines 13 and 19.
- lines 21, 32 and 34.
- lines 23, 28, 30 and 34.