Hello
I am currently in the process of writting a new firewall script. The
original script I was using was originally written for ipchains and
ported to iptables without using any of its new features. Now I wish
to take advantage of Netfilters advanced features, especially
connection tracking.
The computer iptables is running on is used as a gateway for the other
computers in the local network as well as running some services like
Cups, Samba etc. It is connected to the Internet via a DSL-Modem
running as interface ppp0. I have used this -
http://www.linuxjournal.com/article/4815 - guide as a basis for
configuring the firewall but I am still running into some problems
which so far I have not been able to solve on my own.
According to my understanding the line I marked with ">>>" should
allow the computer to accept new incoming and forwarded connection on
every interface but ppp0. Unfortunately this is not working as it
should, I have to manually add an ACCEPT-Rule for eth0 and lo in order
to access the computer. Where is the error in the script ? What I
also would like to know if the order in which I new rules are added is
important. Should I put the lines in which I set the default policies
in the beginning after flushing the tables or in the end like they are
now?
Yours sincerely
Stefan Malte Schumacher
for i in filter nat
do
iptables -t $i -F
iptables -t $i -X
done
iptables -t filter -N tcprules
iptables -t filter -A tcprules -i ppp0 -m state --state ESTABLISHED,RELATED -j ACCEPT
>>> iptables -t filter -A tcprules -i ! ppp0 -m state --state NEW -j ACCEPT
iptables -t filter -A tcprules -i ppp0 -m state --state NEW,INVALID -j DROP
iptables -t nat -A POSTROUTING -o ppp0 -s 192.168.99.0/24 -d 0/0 -j MASQUERADE
iptables -t filter -A INPUT -j tcprules
iptables -t filter -A FORWARD -j tcprules
iptables -t filter -A INPUT -i eth0 -j ACCEPT
iptables -t filter -A FORWARD -i eth0 -j ACCEPT
iptables -t filter -A INPUT -i lo -j ACCEPT
iptables -A INPUT -i ppp0 -p tcp -m multiport --dports 4662,6881,6882,9866 -j ACCEPT
iptables -A INPUT -i ppp0 -p udp -m multiport --dports 4666,9866,12478 -j ACCEPT
iptables -t filter -P INPUT DROP
iptables -t filter -P FORWARD DROP
iptables -t filter -P OUTPUT ACCEPT