Hi Klaus<div><br></div><div>Thanks for posting the  working solution.</div><div><br></div><div>You are right that mhomed=1 won&#39;t help if the sockets both have same IP address. Though I think if you used it with two different IPs and the correct routing tables on the OS then it would work. </div>
<div><br></div><div>In any case your solution is a good one. </div><div><br></div><div>Richard</div><div><br><div class="gmail_quote">On 7 January 2013 15:45, Klaus Darilion <span dir="ltr">&lt;<a href="mailto:klaus.mailinglists@pernau.at" target="_blank">klaus.mailinglists@pernau.at</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi all!<div class="im"><br>
<br>
On 04.01.2013 18:57, Ovidiu Sas wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hello Klauss,<br>
<br>
I use record_route_preset for this kind of scenarios:<br>
<a href="http://kamailio.org/docs/modules/3.3.x/modules_k/rr.html#id2550086" target="_blank">http://kamailio.org/docs/<u></u>modules/3.3.x/modules_k/rr.<u></u>html#id2550086</a><br>
That was the main reason that I enhanced record_route_preset with the<br>
second parameter (see the Note on string2).<br>
<br>
I haven&#39;t tried your idea with two sockets.  Let us know if it&#39;s working.<br>
If you need to use the same port on the internal and external<br>
interface, you could add a new IP to the host and listen on two<br>
sockets on the same port and force the socket when sending a request<br>
out.<br>
listen=udp:10.10.0.2<br>
listen=udp:10.10.0.3 advertise pu.bl.ic.ip<br>
</blockquote>
<br></div>
I did some basic tests (incoming, outgoing, on/off-hold). The service provider&#39;s SIP trunk was an Asterisk with NAT traversal disabled. Kamailio was NATed 1:1 to the public IP address (exclusively, without port translation). I tested Kamailio only doing near-end NAT-traversal (taking care of its own NAT).<br>

<br>
I used two IP addresses for the two sockets, but I must works also with a single IP address and different ports.<br>
<br>
Conclusion: works :-)<br>
<br>
Following is the setup how I tested it (if you need to add far-end NAT traversal (SIP clients behind another NAT) then it will more complex).<br>
<br>
regards<br>
Klaus<br>
<br>
<br>
# Service Provider for SIP Trunk:         5.5.5.5<br>
# public IP address of Kamailio/rtpproxy: 3.3.3.3<br>
# rtpproxy binds to 10.10.0.3<br>
listen=udp:10.10.0.2<br>
listen=udp:10.10.0.3 advertise <a href="http://3.3.3.3:5060" target="_blank">3.3.3.3:5060</a><br>
mhomed=0<br>
<br>
route[RELAY] {<br>
        if (src_ip == 5.5.5.5) {<br>
                force_send_socket(&quot;10.10.0.2&quot;)<u></u>;<br>
                rtpproxy_manage(&quot;&quot;,&quot;10.10.0.3&quot;<u></u>);<br>
        } else {<br>
                force_send_socket(&quot;10.10.0.3&quot;)<u></u>;<br>
                rtpproxy_manage(&quot;&quot;,&quot;3.3.3.3&quot;);<br>
        }<br>
        ...<br>
        t_relay();<br>
}<br>
<br>
<br>
onreply_route {<br>
        if (src_ip == 5.5.5.5) {<br>
                force_send_socket(&quot;10.10.0.2&quot;)<u></u>;<br>
                rtpproxy_manage(&quot;&quot;,&quot;10.10.0.3&quot;<u></u>);<br>
        } else {<br>
                force_send_socket(&quot;10.10.0.3&quot;)<u></u>;<br>
                rtpproxy_manage(&quot;&quot;,&quot;3.3.3.3&quot;);<div class="HOEnZb"><div class="h5"><br>
        }<br>
}<br>
<br>
<br>
______________________________<u></u>_________________<br>
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list<br>
<a href="mailto:sr-users@lists.sip-router.org" target="_blank">sr-users@lists.sip-router.org</a><br>
<a href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users" target="_blank">http://lists.sip-router.org/<u></u>cgi-bin/mailman/listinfo/sr-<u></u>users</a><br>
</div></div></blockquote></div><br></div>