Accept and remove
Hi all.
I was wondering if there is a feature in iptables where I can add a rule that matches for example a SYN packet and jump to a target that lets it through and then removes the rule.
Basicly allowing me to add a rule to my firewall that says, "You can ssh in once, after that you need to talk to me again."
I've tried to do this using the limits and it mostly works but when any change hapens in the rules in the kernel, the counters seem to get reset and that reopenes those "spent" rules again.
If not, I was considering to take the ACCEPT target and copy it to something else (ACCEPTONCE) and making the necessary changes. Is there any way for targets to know which rule called them ?
Any help in this would be greatly appriciated. :)
Signature · 4 lines
Rikki. -- RHCE, RHCX, HP-UX Certified Administrator.
-- Solaris 7 Certified Systems and Network Administrator.
Bell Labs Unix -- Reach out and grep someone.
Those who do not understand Unix are condemned to reinvent it, poorly.Quoted 5 lines · Richard Allen
Hi all.
I was wondering if there is a feature in iptables where I can add a rule that matches for example a SYN packet and jump to a target that lets it through and then removes the rule.
rule changes (removal, ..) are not possible from within the kernel, sorry. The kernel just has code to iterate over a ruleset, not to create/modify it.
Quoted 3 lines
If not, I was considering to take the ACCEPT target and copy it to something else (ACCEPTONCE) and making the necessary changes. Is there any way for targets to know which rule called them ?
no. but you have a per-rule private data (targinfo) for your target. So you can just write a '1' to this data area when your rule was matched, and then don't match for all further packets if there is this magic '1'.
Quoted 1 line
Rikki. -- RHCE, RHCX, HP-UX Certified Administrator.
Signature · 5 lines
- Harald Welte <[email protected]> http://www.netfilter.org/ ============================================================================ "Fragmentation is like classful addressing -- an interesting early architectural error that shows how much experimentation was going on while IP was being designed." -- Paul Vixie