Gentoo Archives: gentoo-user

From: Alan McKinnon <alan.mckinnon@×××××.com>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] IPTables - Going Stateless
Date: Tue, 21 May 2013 16:14:07
Message-Id: 519B9D1F.3050802@gmail.com
In Reply to: [gentoo-user] IPTables - Going Stateless by Nick Khamis
1 On 21/05/2013 17:07, Nick Khamis wrote:
2 > Hello Everyone,
3 >
4 > We recently moved our stateful firewall inside, and would like to
5 > strip down the firewall at our router connected to the outside world.
6 > The problem I am experiencing is getting things to work properly
7 > without connection tracking.
8
9 Now why, oh why, do you want to do that? A world of pain awaits you.
10
11 Stateless firewalls are a colossal mindfuck that will drive you crazy.
12 So unless you have a very very good reason for doing this I recommedn
13 you seriously revisit your choice. iptables really does not consume that
14 much resources (and if you truly are low on resources then you need to
15 get a bigger router, because after all it is a router and I assume in
16 production)
17
18
19 I hope I am not in breach of mailing list
20 > rules however, a stripped down configuration is as follows:
21 >
22 > #!/bin/bash
23 > IPTABLES='/sbin/iptables'
24 >
25 > #Set interface values
26 > INTIF1='eth0'
27 >
28 > #flush rules and delete chains
29 > $IPTABLES -F
30 > $IPTABLES -X
31 >
32 > #echo -e " - Accepting input lo traffic"
33 > $IPTABLES -A INPUT -i lo -j ACCEPT
34 >
35 > #echo -e " - Accepting output lo traffic"
36 > $IPTABLES -A OUTPUT -o lo -j ACCEPT
37 >
38 > #echo -e " - Defined Chains"
39 > $IPTABLES -N TCP
40 > $IPTABLES -N UDP
41 >
42 > #echo -e " - Accepting SSH Traffic"
43 > $IPTABLES -A TCP -p tcp -m tcp -s 192.168.2.0/24 -d 192.168.2.5
44 > --dport 22 -j ACCEPT
45 > $IPTABLES -A TCP -p tcp -m tcp -s 0.0.0.0/0 -d 192.168.2.5 --dport 22 -j DROP
46 >
47 > #echo -e " - Accepting input TCP and UDP traffic to open ports"
48 > $IPTABLES -A INPUT -i $INTIF1 -p tcp --syn -j TCP
49 > $IPTABLES -A INPUT -i $INTIF1 -p udp -j UDP
50 >
51 > #echo -e " - Accepting output TCP and UDP traffic to open ports"
52 > $IPTABLES -A OUTPUT -o $INTIF1 -p tcp --syn -j TCP
53 > $IPTABLES -A OUTPUT -o $INTIF1 -p udp -j UDP
54 >
55 > #echo -e " - Dropping input TCP and UDP traffic to closed ports"
56 > # $IPTABLES -A INPUT -i $INTIF1 -p tcp -j REJECT --reject-with tcp-rst
57 > # $IPTABLES -A INPUT -i $INTIF1 -p udp -j REJECT --reject-with
58 > icmp-port-unreachable
59 >
60 > #echo -e " - Dropping output TCP and UDP traffic to closed ports"
61 > # $IPTABLES -A OUTPUT -o $INTIF1 -p tcp -j REJECT --reject-with tcp-rst
62 > # $IPTABLES -A OUTPUT -o $INTIF1 -p udp -j REJECT --reject-with
63 > icmp-port-unreachable
64 >
65 > #echo -e " - Dropping input traffic to remaining protocols sent
66 > to closed ports"
67 > # $IPTABLES -A INPUT -i $INTIF1 -j REJECT --reject-with icmp-proto-unreachable
68 >
69 > #echo -e " - Dropping output traffic to remaining protocols sent
70 > to closed ports"
71 > # $IPTABLES -A OUTPUT -o $INTIF1 -j REJECT --reject-with icmp-proto-unreachable
72 >
73 >
74 > Everything works fine with the REJECT rules commented out, but when
75 > included SSH access is blocked out. Not sure why, isn't the sequence
76 > correct (i.e., the ACCPET entries before the DROP and REJECT)?
77 >
78 > Also, any pointers or heads up when going stateless would be greatly
79 > appreciated.
80 >
81 > Kind Regards,
82 >
83 > Nick
84 >
85
86
87 --
88 Alan McKinnon
89 alan.mckinnon@×××××.com