iptables and external processes
My apologies for troubling the develop list with such a question but I received no reply from the user list.
It would solve a very difficult problem for us if we could jump a packet to a chain based upon the decision of a process external to iptables. In other words, a packet enters the FORWARD or INPUT chains, encounters a rule that queries a running process. The process extracts some information from the IP header and returns true or false. iptables then either matches the packet if true and passes the packet to the next rule if false. This sounds like the exact sort of thing a POM extension would do.
Nothing caught my eye in either POM or the iptables documentation. Is this an existing functionality and I just don't see it? If not, is it possible to write an extension that would do such a thing? We do not have the in-house expertise to do such a thing (obviously!) so we'll probably need to find someone to do it for us but would like to know if it is even possible before we pursue the matter. Thanks - John
Signature · 5 lines
John A. Sullivan III Chief Technology Officer Nexus Management +1 207-985-7880 [email protected]
Quoted 8 lines · John A. Sullivan III
It would solve a very difficult problem for us if we could jump a packet to a chain based upon the decision of a process external to iptables. In other words, a packet enters the FORWARD or INPUT chains, encounters a rule that queries a running process. The process extracts some information from the IP header and returns true or false. iptables then either matches the packet if true and passes the packet to the next rule if false. This sounds like the exact sort of thing a POM extension would do.
The QUEUE function is pretty similar to this. Only difference is that the verdict from QUEUE is final for the hook.
Implementing a function where iptables is suspended in the middle waiting for results from userspace is non-trivial and I am not sure it is at all a feasible thing to do.
Is there any reason to why QUEUE not sufficient for your application?
Regards
Henrik
I thought it was possible to actually change the packet and send the packet back in again ?
Just rule processing stops once -J QUEUE happens ?
There are also some other tools like Snort and Hogwash and probably a few more by now that have different capabilities for inspecting packets.
FYI
-AEF
Quoted 7 lines · Henrik Nordstrom
Quoted 2 lines · John A. Sullivan III
It would solve a very difficult problem for us if we could jump a packet to a chain based upon the decision of a process external to iptables.
The QUEUE function is pretty similar to this. Only difference is that the verdict from QUEUE is final for the hook.
Thank you very much for such a quick response. QUEUE may do exactly what we need. I have always approached iptables as a user and so have not paid much attention to the Hacking-How-To. That's why I'll probably need to find someone to do this :-)
We are looking to set up a light-weight user authentication service for wireless. We know the Nu-FW folks have done a good job of creating a robust user authentication service but we think that we can take some of the practices we have learned from using the excellent Qt toolkit to create a simple client service that will pre-authenticate to a Linux wireless access-point.
The pre-authentication will create some custom chains ala the ISCS paradigm. When combined with ISCS's ability to centrally managed complex security on thousands of iptables gateways
(http://iscs.sourceforge.net), we think we will have a very powerful wireless solution (and another triumph for Linux/iptables :-) ).
We already do this for users using IPSec tunnels and identified via X.509 certificates. The missing piece was being able to do this for users sending packets in the clear and identified via AD, NDS, LDAP, RADIUS and SecureID in a way that both allows NAT and prevents address spoofing.
That's where the packet processing comes in. We know what we have to do to have iptables confirm that the packet is not spoofed and to track the NAT. We just needed to find a way to pass that decision back to iptables to know whether to pass the packet on to the chains that were built in the pre-authentication or to drop the packet as a spoof. Assuming that I have the client part and logic straight, does this seem feasible? I take from the little I read about QUEUE that this is quite possible. Thanks again - John
Quoted 20 lines · Allen Francom
I thought it was possible to actually change the packet and send the packet back in again ?
Just rule processing stops once -J QUEUE happens ?
There are also some other tools like Snort and Hogwash and probably a few more by now that have different capabilities for inspecting packets.
FYI
-AEFQuoted 7 lines · Henrik Nordstrom
Quoted 2 lines · John A. Sullivan III
It would solve a very difficult problem for us if we could jump a packet to a chain based upon the decision of a process external to iptables.
The QUEUE function is pretty similar to this. Only difference is that the verdict from QUEUE is final for the hook.
Signature · 5 lines
John A. Sullivan III Chief Technology Officer Nexus Management +1 207-985-7880 [email protected]
Quoted 2 lines · Allen Francom
I thought it was possible to actually change the packet and send the packet back in again ?
Yes.
Quoted 1 line
Just rule processing stops once -J QUEUE happens ?
Yes.
And the verdict from QUEUE is final for this hook. iptables will NOT continue on the next rule.
Regards
Henrik
Quoted 8 lines · John A. Sullivan III
That's where the packet processing comes in. We know what we have to do to have iptables confirm that the packet is not spoofed and to track the NAT. We just needed to find a way to pass that decision back to iptables to know whether to pass the packet on to the chains that were built in the pre-authentication or to drop the packet as a spoof. Assuming that I have the client part and logic straight, does this seem feasible? I take from the little I read about QUEUE that this is quite possible. Thanks again - John
Nothing of what you have said indicates QUEUE can not be used from what I can tell.
The main complication is that once you have processed the QUEUE:ed packet in userspace, the verdict set by the userspace is final for this hook. But this is rarely a problem. In most cases you can duplicate the little extra rules needed if any in the userspace, or have the QUEUE called from another hook running before your firewall hook (i.e. mangle).
Also, if you need to modify NAT rules while processing the packet in userspace then you must call QUEUE from mangle PREROUTING as this is the only hook which is executed before NAT.
Regards
Henrik
Quoted 20 lines · Henrik Nordstrom
Quoted 8 lines · John A. Sullivan III
That's where the packet processing comes in. We know what we have to do to have iptables confirm that the packet is not spoofed and to track the NAT. We just needed to find a way to pass that decision back to iptables to know whether to pass the packet on to the chains that were built in the pre-authentication or to drop the packet as a spoof. Assuming that I have the client part and logic straight, does this seem feasible? I take from the little I read about QUEUE that this is quite possible. Thanks again - John
Nothing of what you have said indicates QUEUE can not be used from what I can tell.
The main complication is that once you have processed the QUEUE:ed packet in userspace, the verdict set by the userspace is final for this hook. But this is rarely a problem. In most cases you can duplicate the little extra rules needed if any in the userspace, or have the QUEUE called from another hook running before your firewall hook (i.e. mangle).
Quoted 6 lines
Also, if you need to modify NAT rules while processing the packet in userspace then you must call QUEUE from mangle PREROUTING as this is the only hook which is executed before NAT.
Regards
Henrik
Hmmm . . . that could get a little complicated. Where the packets are processed in the flow is critically important. Ideally, it should intercept them from FORWARD or INPUT in the filter table and then jump them to a user defined chain in the filter table if they are not dropped. In fact, it really should not drop them at all; it should either jump them to the dynamically created user defined chains or return them to the FORWARD or INPUT chain where they will encounter a DROP policy.
I can't merely create those dynamic chains in userspace because those chains will jump to other, pre-existing, user-defined chains.
It sounds like this would be a problem using QUEUE. Have I understood you correctly? Thanks - John
Signature · 5 lines
John A. Sullivan III Chief Technology Officer Nexus Management +1 207-985-7880 [email protected]
Quoted 2 lines · John A. Sullivan III
It sounds like this would be a problem using QUEUE. Have I understood you correctly? Thanks - John
You can not use QUEUE between rules in the same table. Only as final rule in a table. Changing this is far from trivial.
Regards
Henrik
Quoted 10 lines · Henrik Nordstrom
Quoted 2 lines · John A. Sullivan III
It sounds like this would be a problem using QUEUE. Have I understood you correctly? Thanks - John
You can not use QUEUE between rules in the same table. Only as final rule in a table. Changing this is far from trivial.
Regards
Henrik
So then what I am looking for really sounds like a new match. Something like iptables -A FORWARD -m ua --ua -j SOMECHAIN.
I would imagine it is the essence of any match to examine the contents of the layer 3 and 4 headers, pass them to a boolean function and match or not match on the return value of that function. Are there any caveats in what I have described? Again, I confess my complete ignorance of writing iptables patches and of the netfilter code -- just trying to ascertain if it is worth finding a volunteer or contractor to write the proposed patch or if we are pursuing a dead end. Thanks - John
Signature · 5 lines
John A. Sullivan III Chief Technology Officer Nexus Management +1 207-985-7880 [email protected]
Quoted 2 lines · John A. Sullivan III
So then what I am looking for really sounds like a new match. Something like iptables -A FORWARD -m ua --ua -j SOMECHAIN.
This only works if your new match can be evaluated immediately within the kernel. It is not possible to write a match which will ask userspace.
Quoted 4 lines
I would imagine it is the essence of any match to examine the contents of the layer 3 and 4 headers, pass them to a boolean function and match or not match on the return value of that function. Are there any caveats in what I have described?
Not as long as you want to stay within the kernel, and don't need to wait for anything.
Regards
Henrik
Quoted 3 lines · John A. Sullivan III
We are looking to set up a light-weight user authentication service for wireless. We know the Nu-FW folks have done a good job of creating a robust user authentication service
Thank you :-)
Quoted 4 lines
but we think that we can take some of
the practices we have learned from using the excellent Qt toolkit to create a simple client service that will pre-authenticate to a Linux wireless access-point.
Using nufw you can authenticate packets by connection and avoid any problem with spoofing. I think we've to get rid of the old association User<->IP that brings too much complexity and a lot of problems.
If you like some help on how to implement nufw protocols (to be able write a graphical client to nufw) I'm at your disposal.
BR,
Signature · 2 lines
Eric Leblond NuFW, Now User Filtering Works (http://www.nufw.org)