help with setting up iptables for use with snort_inline (QUEUE target)
Hi all,
I have a question about setting up iptables so I can send selected traffic to snort_inline using the QUEUE target.
I'm writing a soon to be released (GPL) frontend to iptables. I'm adapting it now to support the QUEUE target for use with snort_inline. I want to give users the possibility to for example send only http traffic to snort_inline and let iptables handle the other traffic.
So normal my rules are like this (simplified):
iptables -A OUTPUT -m state --state ESTABLISHED,RELATED -j ACCEPT iptables -A OUTPUT -p tcp --dport 80 -m state --state NEW -j ACCEPT
So a connection is accepted by the second rule and after that handled by the first.
Well now the problem. When i want to send packets to the QUEUE target the above setup does not work. Because i don't want all traffic to go to snort_inline, i cant change the target of the established,related rule to QUEUE.
I found a solution which works not entirely as i want. The following example will send http to snort, pop3 will be handled by iptables itself.
iptables -t mangle -A OUTPUT -p tcp --dport 80 -j MARK --set-mark 0x1
iptables -A OUTPUT -m state --state ESTABLISHED,RELATED -m mark --mark 0x1 -j QUEUE
iptables -A OUTPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A OUTPUT -p tcp --dport 80 -m state --state NEW -j QUEUE iptables -A OUTPUT -p tcp --dport 110 -m state --state NEW -j ACCEPT
Well this works... but not for ftp. Iptables has as you know a special helper module for ftp. I don't know how i can make ftp play well in this setup. Because the ftp connection opens other ports i can't use the mark ftp connections like this.
So... any ideas, suggestions?
BTW if in any way possible i want my application to work with an unpatched Debian Woody kernel...
Regards,
Victor
Quoted 16 lines · Victor Julien
Hi all,
I have a question about setting up iptables so I can send selected traffic to
snort_inlineusing the QUEUE target.I'm writing a soon to be released (GPL) frontend to iptables. I'm adapting
iptables -t mangle -A OUTPUT -p tcp --dport 80 -j MARK --set-mark
0x1iptables -A OUTPUT -m state --state ESTABLISHED,RELATED -m mark --mark
0x1-j QUEUE
iptables -A OUTPUT -m state --state ESTABLISHED,RELATED -j ACCEPTiptables -A OUTPUT -p tcp --dport 80 -m state --state NEW -j QUEUE iptables -A OUTPUT -p tcp --dport 110 -m state --state NEW -j ACCEPT
Quoted 6 lines
Well this works... but not for ftp. Iptables has as you know a special helper module for ftp. I don't know how i can make ftp play well in this setup. Because the ftp connection opens other ports i can't use the mark ftp connections like this.
So... any ideas, suggestions?
You might find the new "helper" match does what you need? I'm not certain
because I haven't played with it, but it seems like a likely bet...
By the way, why are you doing all this in the OUTPUT chain?
I'm not quite sure that I see the purpose of running snort-inline on a single
machine. A router for a network, yes, but why on a standalone system?
Regards,
Antony.
Signature · 5 lines
Never automate fully anything that does not have a manual override capability.
Never design anything that cannot work under degraded conditions in emergency.
Please reply to the list;
please don't CC me.On Thursday 01 July 2004 17:09, Antony Stone wrote:
<snip>
Quoted 2 lines
You might find the new "helper" match does what you need? I'm not certain
because I haven't played with it, but it seems like a likely bet...
You seem to be right!
I added this rule:
iptables -t mangle -A OUTPUT -m helper --helper "ftp" -j MARK --set-mark 0x1
and ftp now seems to work!
Quoted 1 line
By the way, why are you doing all this in the OUTPUT chain?
Just for testing. I'm particularly interested in using snort_inline to protect Internet Explorer. So i'm trying to QUEUE http, ftp etc, to snort_inline and try to visit sites with example exploits and see if snort_inline catches it... (i'm not running ie on my linux machine of course ;-)
Quoted 3 lines
I'm not quite sure that I see the purpose of running snort-inline on a
single machine. A router for a network, yes, but why on a standalone
system?
I agree, allthough it does work. The recent troubles with IE show that it cant hurt protecting a client against a webserver. And my system is a lot faster (2.2 ghz) than my firewall (200 mhz), so it makes _some_ sense!
Too bad the helper module is not in the stock Debian Stable kernel. It is in the 2.4.26 kernel at www.backports.org however, so i'm happy.
Thanx Antony!
Regards,
Victor
Quoted 4 lines
Regards,
Antony.