NetFilter
[Top] [All Lists]

Re: stateful UDP with unknown source port on INPUT?

To: netfilter@lists.netfilter.org
Subject: Re: stateful UDP with unknown source port on INPUT?
From: Robert Nichols <rnicholsNOSPAM@comcast.net>
Date: Mon, 02 Apr 2007 00:28:58 -0500
Delivered-to: sp-com-lists@consult.net
Delivered-to: netfilter-list1@securepoint.com
In-reply-to: <BAY121-F1848947AF48B36B0E9D801A9610@phx.gbl>
List-archive: </pipermail/netfilter>
List-help: <mailto:netfilter-request@lists.netfilter.org?subject=help>
List-id: General discussion and user questions <netfilter.lists.netfilter.org>
List-post: <mailto:netfilter@lists.netfilter.org>
List-subscribe: <https://lists.netfilter.org/mailman/listinfo/netfilter>, <mailto:netfilter-request@lists.netfilter.org?subject=subscribe>
List-unsubscribe: <https://lists.netfilter.org/mailman/listinfo/netfilter>, <mailto:netfilter-request@lists.netfilter.org?subject=unsubscribe>
References: <460C4667.1090406@rtij.nl> <BAY121-F1848947AF48B36B0E9D801A9610@phx.gbl>
Sender: netfilter-bounces@lists.netfilter.org
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.13) Gecko/20060508 Fedora/1.7.13-1.3.1.legacy
noa levy wrote:
Thanks!
I forgot to mention, though, that my source port for the SNMP informs is also random, so I can't match against the destination port for the incoming packet - does the recent target also maintain a port list or is it IP addresses only?

How about something like this:

iptables -t nat -A POSTROUTING -p udp --dport 162 -j SNAT --to-source :29999
iptables -t mangle -A PREROUTING -p udp --dport 29999 -j MARK --set-mark 99
iptables -A input -p udp -dport ! 29999 -m mark --mark 99 -j ACCEPT

That 29999 source port is an arbitrary number outside the bounds set in
/proc/sys/net/ipv4/ip_local_port_range.  The mark number is also arbitrary.
The overall effect is that your SNMP inform packets will all appear to
come from port 29999.  Replies to that port will be marked prior to being
de-SNAT-ed.  Now, in the filter table you can ACCEPT marked packets that
have been recognized by de-SNAT and thus no longer have a destination
port of 29999.  Any bogus packets sent to port 29999 will still contain
that port number when they hit the filter rule, and thus will not be
accepted.

I have no way to test any of the above, so view it all with appropriate
suspicion.

--
Bob Nichols         Yes, "NOSPAM" is really part of my email address.



<Prev in Thread] Current Thread [Next in Thread>