Skip to contentSkip to conversation

UDP-conntrack/nat question

DISCUSSION [email protected] 2 participants 2 messages Sep 25, 2003 – Oct 3, 2003 netfilter

lore
Share & tools
lore
#0 lore raw

Hi,

I'm trying to conntrack/nat a udp-based protocol with a server listening on port x. My problem is, that the conntrack-helper sees all incoming and
outgoing packets of the control connection, while the nat-helper is only called for outgoing packets. Due to the nature of the protocol I need IP_NAT_HELPER_F_ALWAYS to mangle the contents of both outgoing and incoming packets (even when there are no expected connections).

The scenario is the following:

PC1 -> MASQ -> server

The conntrack module gets a packet from PC1 (src port x, dst port x) and parses the protocol.
The nat_module mangles the packet content and the packet is send of to the server with the source address of MASQ (src port x, dst port x). The conntrack_module receives a packet from Server (src port: high, dst port
x) and parses the protocol.
The nat_module isn't called.

I reqister my modules with the following tuples:

nat_module:
hlpr->tuple.dst.protonum = IPPROTO_UDP;
hlpr->tuple.src.u.udp.port = port x;
hlpr->mask.src.u.udp.port = 0xFFFF;
hlpr->mask.dst.protonum = 0xFFFF;
hlpr->flags = IP_NAT_HELPER_F_ALWAYS;

conntrack_module:
hlpr->tuple.src.u.udp.port = port x;
hlpr->tuple.dst.protonum = IPPROTO_UDP;
hlpr->mask.src.u.udp.port = 0xFFFF;
hlpr->mask.dst.protonum = 0xFFFF;

/proc/net/ip_conntrack lists both connections (answer&reply) as unreplied. Can someone explain to me why the reply is seen as a new connection ? And how I can get NAT to expect answers from randomly selected high ports ?

regards

Nikolai Dahlem

Signature · 6 lines
NEU FÜR ALLE - GMX MediaCenter - für Fotos, Musik, Dateien...
Fotoalbum, File Sharing, MMS, Multimedia-Gruß, GMX FotoService

Jetzt kostenlos anmelden unter http://www.gmx.net

+++ GMX - die erste Adresse für Mail, Message, More! +++
#1 lore raw

This is a development question, please move this discussion to netfilter-devel. At least if you want to receive some reasonable answers ;)

Quoted 3 lines · On Thu, Sep 25, 2003 at 11:26:20AM +0200, [email protected] wrote:

/proc/net/ip_conntrack lists both connections (answer&reply) as unreplied. Can someone explain to me why the reply is seen as a new connection ? And how I can get NAT to expect answers from randomly selected high ports ?

this sounds like the connection is not symmetrically. The conntrack core assumes that connections are always symmetrically:

request:
(srcip x, scrport a) -> (dstip y, dstport b)

reply:
(srcip y, srcport b) -> (dstip x, dstport a)

If this is not the case, you are in serious trouble.

Quoted 3 lines

regards
Nikolai Dahlem

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