RTP stream before DNAT rule
I have a probably common SIP NAT/NAPT problem and I want to see how others have solved this issue:
I want to dynamically create DNAT rules for RTP streams (port-mapping for a SIP proxy).
This works fine when I add a rule before the first packet of the RTP stream hits the port. But, if the RTP stream begins before the rule is in place, it never matches.
I can insert the DNAT rule only after I have the SDP part of the 200 OK (or any other 1xx with a SDP body).
Rgds
Jimmy
Hello,
Quoted 3 lines · Jimbo
I want to dynamically create DNAT rules for RTP streams (port-mapping for a SIP proxy).
Why don't you use the netfilter NAT helper module for SIP instead ? It is designed to handle SIP-related mappings and is available in kernel versions 2.6.18 and above. Its name is ip_nat_sip or nf_nat_sip.
Quoted 3 lines
This works fine when I add a rule before the first packet of the RTP stream hits the port. But, if the RTP stream begins before the rule is in place, it never matches.
Because DNAT rules have no effect on already existing "connections".
You could use the 'conntrack' tool (available at the netfilter site) to delete an existing matching connection entry from the conntrack table, so the DNAT rule would match the next packet.