<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Destination uri (for $dd) is set after lookup("location"). If you
use default config, route[NAT] is executed before.<br>
<br>
Cheers,<br>
Daniel<br>
<br>
On 12/20/10 2:48 PM, Deon Vermeulen wrote:
<blockquote
cite="mid:299B9B9C-ECAF-40E1-8869-FC7F5311F48E@gmail.com"
type="cite">Thanks again.
<div><br>
</div>
<div>So then my config should look something like:</div>
<div><br>
</div>
<div><br>
</div>
<div>
<div># Caller NAT detection route<br>
route[NAT] {<br>
#!ifdef WITH_NAT<br>
force_rport();<br>
if (nat_uac_test("19")) {<br>
if (method=="REGISTER") {<br>
fix_nated_register();<br>
} else {<br>
fix_nated_contact();<br>
}<br>
setflag(FLT_NATS);</div>
<div><br>
</div>
<div>
<div style="margin: 0px; font: 12px Courier;"><font
class="Apple-style-span" face="Helvetica"> #
If both clients are behind nat we can check to see if they
are behind the same</font></div>
<div style="margin: 0px; font: 12px Courier;"><font
class="Apple-style-span" face="Helvetica"> #
external IP and optimize the media path to go directly
between them</font></div>
<div style="margin: 0px; font: 12px Courier;"><font
class="Apple-style-span" face="Helvetica">
else if ( $si==$dd || $si==rd) </font><span
class="Apple-style-span" style="font-family: Helvetica;">{</span></div>
<div style="margin: 0px; font: 12px Courier;"><font
class="Apple-style-span" face="Helvetica">
xlog("L_INFO", "Detected Two Clients Behind
the Same NAT - Disabling RTPproxy");</font></div>
<div style="margin: 0px; font: 12px Courier; min-height:
14px;"><font class="Apple-style-span" face="Helvetica">
<br class="webkit-block-placeholder">
</font></div>
<div style="margin: 0px; font: 12px Courier;"><font
class="Apple-style-span" face="Helvetica">
# Do not use rtpproxy as the clients seem
to be behind the same NAT</font></div>
<div style="margin: 0px; font: 12px Courier;"><font
class="Apple-style-span" face="Helvetica">
resetflag(<span class="Apple-style-span"
style="font-size: medium;">FLT_NATS</span>);</font></div>
<div style="margin: 0px; font: 12px Courier;"><font
class="Apple-style-span" face="Helvetica">
resetflag(<span class="Apple-style-span"
style="font-size: medium;">FLT_NATB</span>);</font></div>
<div style="margin: 0px; font: 12px Courier;"><font
class="Apple-style-span" face="Helvetica">
}</font></div>
<div style="margin: 0px; font: 12px Courier;"><font
class="Apple-style-span" face="Helvetica">
}</font></div>
</div>
<div> }</div>
<div>#!endif<br>
return;<br>
}<br>
<br>
# RTPProxy control<br>
route[RTPPROXY] {<br>
#!ifdef WITH_NAT<br>
if (is_method("BYE")) {<br>
unforce_rtp_proxy();<br>
} else if (is_method("INVITE")){<br>
force_rtp_proxy();<br>
}<br>
if (!has_totag()) add_rr_param(";nat=yes");<br>
#!endif<br>
return;<br>
}<br>
</div>
<div><br>
</div>
<div><br>
</div>
<div>Rgds</div>
<div>Deon</div>
</div>
<div><br>
</div>
<div><br>
</div>
<div><br>
<div>
<div>On Dec 20, 2010, at 3:37 PM, Daniel-Constantin Mierla
wrote:</div>
<br class="Apple-interchange-newline">
<blockquote type="cite">
<div bgcolor="#ffffff" text="#000000"> Hello,<br>
<br>
that's a hint for a very old version, where cfg file
language didn't had support for variables and avpops
module was used for comparison (as you could see, $dd is
stored in an avp and them compared with src ip -- no
longer need for such workaround, just do if($si==$dd)
...).<br>
<br>
You have to plug the when you force usage of rtp proxy, so
you skip it in such cases.<br>
<br>
Cheers,<br>
Daniel<br>
<br>
On 12/20/10 2:32 PM, Deon Vermeulen wrote:
<blockquote
cite="mid:2886DC79-37E8-4F26-BFA1-CF5B796993C0@gmail.com"
type="cite">Hi Daniel
<div><br>
</div>
<div>Thank you so much for your feedback.</div>
<div><br>
</div>
<div>I came upon the below post, but I'm unable to find
the example Norman posted.</div>
<div><a moz-do-not-send="true"
href="http://www.mail-archive.com/users@openser.org/msg01932.html">http://www.mail-archive.com/users@openser.org/msg01932.html</a></div>
<div><br>
</div>
<div>In short the end solution is:</div>
<div><br>
</div>
<div>
<div style="margin: 0px; font: 12px Courier;"><font
class="Apple-style-span" face="Helvetica"> # If
both clients are behind nat we can check to see if
they are behind the same</font></div>
<div style="margin: 0px; font: 12px Courier;"><font
class="Apple-style-span" face="Helvetica"> #
external IP and optimize the media path to go
directly between them</font></div>
<div style="margin: 0px; font: 12px Courier;"><font
class="Apple-style-span" face="Helvetica">else if
( isflagset(2) and isflagset(3) )</font></div>
<div style="margin: 0px; font: 12px Courier;"><font
class="Apple-style-span" face="Helvetica">
{</font></div>
<div style="margin: 0px; font: 12px Courier;"><font
class="Apple-style-span" face="Helvetica">
log(1, "Both Clients are behind NAT");</font></div>
<div style="margin: 0px; font: 12px Courier;
min-height: 14px;"><font class="Apple-style-span"
face="Helvetica"><br>
</font></div>
<div style="margin: 0px; font: 12px Courier;"><font
class="Apple-style-span" face="Helvetica">
# Store the destination domain into an AVP</font></div>
<div style="margin: 0px; font: 12px Courier;"><font
class="Apple-style-span" face="Helvetica">
avp_printf("i:450", "$dd");</font></div>
<div style="margin: 0px; font: 12px Courier;
min-height: 14px;"><font class="Apple-style-span"
face="Helvetica"> <br
class="webkit-block-placeholder">
</font></div>
<div style="margin: 0px; font: 12px Courier;"><font
class="Apple-style-span" face="Helvetica">
if ( avp_check("i:450", "eq/$src_ip/g") )</font></div>
<div style="margin: 0px; font: 12px Courier;"><font
class="Apple-style-span" face="Helvetica">
{</font></div>
<div style="margin: 0px; font: 12px Courier;"><font
class="Apple-style-span" face="Helvetica">
xlog("L_INFO", "Detected Two Clients
Behind the Same NAT - Disabling Mediaproxy");</font></div>
<div style="margin: 0px; font: 12px Courier;
min-height: 14px;"><font class="Apple-style-span"
face="Helvetica"> <br
class="webkit-block-placeholder">
</font></div>
<div style="margin: 0px; font: 12px Courier;"><font
class="Apple-style-span" face="Helvetica">
# Do not use mediaproxy as the clients
seem to be behind the same NAT</font></div>
<div style="margin: 0px; font: 12px Courier;"><font
class="Apple-style-span" face="Helvetica">
resetflag(2);</font></div>
<div style="margin: 0px; font: 12px Courier;"><font
class="Apple-style-span" face="Helvetica">
resetflag(3);</font></div>
<div style="margin: 0px; font: 12px Courier;"><font
class="Apple-style-span" face="Helvetica">
} </font></div>
<div style="margin: 0px; font: 12px Courier;
min-height: 14px;"><font class="Apple-style-span"
face="Helvetica"> <br
class="webkit-block-placeholder">
</font></div>
<div style="margin: 0px; font: 12px Courier;"><font
class="Apple-style-span" face="Helvetica">
}</font></div>
</div>
<div><br>
</div>
<div><br>
</div>
<div><br>
</div>
<div>I haven't tested yet, but would I be right in
saying my config should look something like:</div>
<div><br>
</div>
<div><br>
</div>
<div>####### Routing Logic ########<br>
<br>
<br>
# Main SIP request routing logic<br>
# - processing of any incoming SIP request starts with
this route<br>
route {<br>
<br>
# per request initial checks<br>
route(REQINIT);<br>
<br>
# NAT detection<br>
route(NAT);<br>
<br>
<br>
<br>
<br>
# Caller NAT detection route<br>
route[NAT] {<br>
#!ifdef WITH_NAT<br>
force_rport();<br>
if (nat_uac_test("19")) {<br>
if (method=="REGISTER") {<br>
fix_nated_register();<br>
} else {<br>
fix_nated_contact();<br>
}<br>
setflag(FLT_NATS);<br>
<br>
</div>
<div>
<div style="margin: 0px; font: 12px Courier;"><font
class="Apple-style-span" face="Helvetica">
# If both clients are behind nat we can
check to see if they are behind the same</font></div>
<div style="margin: 0px; font: 12px Courier;"><font
class="Apple-style-span" face="Helvetica">
# external IP and optimize the media path
to go directly between them</font></div>
<div style="margin: 0px; font: 12px Courier;"><font
class="Apple-style-span" face="Helvetica">
else if ( isflagset(<span
class="Apple-style-span" style="font-size:
medium;">FLT_NATS</span>) and isflagset(<span
class="Apple-style-span" style="font-size:
medium;">FLT_NATB</span>) ) </font><span
class="Apple-style-span" style="font-family:
Helvetica;">{</span></div>
<div style="margin: 0px; font: 12px Courier;"><font
class="Apple-style-span" face="Helvetica">
log(1, "Both Clients are
behind NAT");</font></div>
<div style="margin: 0px; font: 12px Courier;
min-height: 14px;"><font class="Apple-style-span"
face="Helvetica"><br>
</font></div>
<div style="margin: 0px; font: 12px Courier;"><font
class="Apple-style-span" face="Helvetica">
# Store the destination domain into an AVP</font></div>
<div style="margin: 0px; font: 12px Courier;"><font
class="Apple-style-span" face="Helvetica">
avp_printf("i:450",
"$dd");</font></div>
<div style="margin: 0px; font: 12px Courier;
min-height: 14px;"><font class="Apple-style-span"
face="Helvetica"> <br
class="webkit-block-placeholder">
</font></div>
<div style="margin: 0px; font: 12px Courier;"><font
class="Apple-style-span" face="Helvetica">
if ( avp_check("i:450",
"eq/$src_ip/g") ) </font><span
class="Apple-style-span" style="font-family:
Helvetica;">{</span></div>
<div style="margin: 0px; font: 12px Courier;"><font
class="Apple-style-span" face="Helvetica">
xlog("L_INFO", "Detected Two Clients Behind the
Same NAT - Disabling RTPproxy");</font></div>
<div style="margin: 0px; font: 12px Courier;
min-height: 14px;"><font class="Apple-style-span"
face="Helvetica"> <br
class="webkit-block-placeholder">
</font></div>
<div style="margin: 0px; font: 12px Courier;"><font
class="Apple-style-span" face="Helvetica">
# Do not use rtpproxy as
the clients seem to be behind the same NAT</font></div>
<div style="margin: 0px; font: 12px Courier;"><font
class="Apple-style-span" face="Helvetica">
resetflag(<span class="Apple-style-span"
style="font-size: medium;">FLT_NATS</span>);</font></div>
<div style="margin: 0px; font: 12px Courier;"><font
class="Apple-style-span" face="Helvetica">
resetflag(<span class="Apple-style-span"
style="font-size: medium;">FLT_NATB</span>);</font></div>
<div style="margin: 0px; font: 12px Courier;"><font
class="Apple-style-span" face="Helvetica">
}</font></div>
<div style="margin: 0px; font: 12px Courier;"><font
class="Apple-style-span" face="Helvetica">
}</font></div>
</div>
<div> }</div>
<div>#!endif<br>
return;<br>
}<br>
<br>
# RTPProxy control<br>
route[RTPPROXY] {<br>
#!ifdef WITH_NAT<br>
if (is_method("BYE")) {<br>
unforce_rtp_proxy();<br>
} else if (is_method("INVITE")){<br>
force_rtp_proxy();<br>
}<br>
if (!has_totag()) add_rr_param(";nat=yes");<br>
#!endif<br>
return;<br>
}<br>
</div>
<div><br>
</div>
<div><br>
</div>
<div>Rgds</div>
<div>Deon</div>
<div><br>
</div>
<div><br>
<div>
<div>On Dec 20, 2010, at 2:41 PM, Daniel-Constantin
Mierla wrote:</div>
<br class="Apple-interchange-newline">
<blockquote type="cite">
<div>Hello,<br>
<br>
On 12/20/10 11:25 AM, Deon Vermeulen wrote:<br>
<blockquote type="cite">Hi List<br>
</blockquote>
<blockquote type="cite"><br>
</blockquote>
<blockquote type="cite">Can someone please help
me?<br>
</blockquote>
<blockquote type="cite"><br>
</blockquote>
<blockquote type="cite">I need to implement PBX
Services for a customer that has 10 IP Phones
at his Main site and then 20 IP Phones located
over 5 Branches.<br>
</blockquote>
<blockquote type="cite"><br>
</blockquote>
<blockquote type="cite">My goal is to have RTP
go end to end and not proxied.<br>
</blockquote>
<blockquote type="cite"><br>
</blockquote>
<blockquote type="cite">I had a look at the
below link and tried it, but with no luck.<br>
</blockquote>
<blockquote type="cite"><br>
</blockquote>
<blockquote type="cite"><a
moz-do-not-send="true"
href="http://kamailio.org/dokuwiki/doku.php/examples:caller-callee-behind-same-nat">http://kamailio.org/dokuwiki/doku.php/examples:caller-callee-behind-same-nat</a><br>
</blockquote>
<blockquote type="cite"><br>
</blockquote>
<blockquote type="cite">Here is a partial output
of my kamailio.cfg file if someone would be so
kind to help me.<br>
</blockquote>
<blockquote type="cite"><br>
</blockquote>
<blockquote type="cite"><br>
</blockquote>
<blockquote type="cite">#!ifdef WITH_NAT<br>
</blockquote>
<blockquote type="cite"># ----- rtpproxy params
-----<br>
</blockquote>
<blockquote type="cite">modparam("rtpproxy",
"rtpproxy_sock", "udp:localhost:7722")<br>
</blockquote>
<blockquote type="cite"><br>
</blockquote>
<blockquote type="cite"># ----- nathelper params
-----<br>
</blockquote>
<blockquote type="cite">modparam("nathelper",
"natping_interval", 30)<br>
</blockquote>
<blockquote type="cite">modparam("nathelper",
"ping_nated_only", 1)<br>
</blockquote>
<blockquote type="cite">modparam("nathelper",
"sipping_bflag", FLB_NATSIPPING)<br>
</blockquote>
<blockquote type="cite">modparam("nathelper",
"sipping_from", "<a moz-do-not-send="true"
href="sip:pinger@x.x.x.x">sip:pinger@x.x.x.x</a>")<br>
</blockquote>
<blockquote type="cite"><br>
</blockquote>
<blockquote type="cite"># params needed for NAT
traversal in other modules<br>
</blockquote>
<blockquote type="cite">modparam("nathelper|registrar",
"received_avp", "$avp(RECEIVED)")<br>
</blockquote>
<blockquote type="cite">modparam("usrloc",
"nat_bflag", FLB_NATB)<br>
</blockquote>
<blockquote type="cite">#!endif<br>
</blockquote>
<blockquote type="cite"><br>
</blockquote>
<blockquote type="cite"><br>
</blockquote>
<blockquote type="cite"><br>
</blockquote>
<blockquote type="cite">####### Routing Logic
########<br>
</blockquote>
<blockquote type="cite"><br>
</blockquote>
<blockquote type="cite"><br>
</blockquote>
<blockquote type="cite"># Main SIP request
routing logic<br>
</blockquote>
<blockquote type="cite"># - processing of any
incoming SIP request starts with this route<br>
</blockquote>
<blockquote type="cite">route {<br>
</blockquote>
<blockquote type="cite"><br>
</blockquote>
<blockquote type="cite"> # per request
initial checks<br>
</blockquote>
<blockquote type="cite"> route(REQINIT);<br>
</blockquote>
<blockquote type="cite"><br>
</blockquote>
<blockquote type="cite"> # NAT detection<br>
</blockquote>
<blockquote type="cite"> route(NAT);<br>
</blockquote>
<blockquote type="cite"><br>
</blockquote>
<blockquote type="cite"><br>
</blockquote>
<blockquote type="cite"><br>
</blockquote>
<blockquote type="cite"><br>
</blockquote>
<blockquote type="cite"># Caller NAT detection
route<br>
</blockquote>
<blockquote type="cite">route[NAT] {<br>
</blockquote>
<blockquote type="cite">#!ifdef WITH_NAT<br>
</blockquote>
<blockquote type="cite"> force_rport();<br>
</blockquote>
<blockquote type="cite"> if
(nat_uac_test("19")) {<br>
</blockquote>
<blockquote type="cite"> if
(method=="REGISTER") {<br>
</blockquote>
<blockquote type="cite">
fix_nated_register();<br>
</blockquote>
<blockquote type="cite"> } else
{<br>
</blockquote>
<blockquote type="cite">
fix_nated_contact();<br>
</blockquote>
<blockquote type="cite"> }<br>
</blockquote>
<blockquote type="cite">
setflag(FLT_NATS);<br>
</blockquote>
</div>
</blockquote>
<div><br>
</div>
<br>
<blockquote type="cite">
<div>
<blockquote type="cite"> }<br>
</blockquote>
<blockquote type="cite">#!endif<br>
</blockquote>
<blockquote type="cite"> return;<br>
</blockquote>
<blockquote type="cite">}<br>
</blockquote>
<blockquote type="cite"><br>
</blockquote>
<blockquote type="cite"># RTPProxy control<br>
</blockquote>
<blockquote type="cite">route[RTPPROXY] {<br>
</blockquote>
<blockquote type="cite">#!ifdef WITH_NAT<br>
</blockquote>
<blockquote type="cite"> if
(is_method("BYE")) {<br>
</blockquote>
<blockquote type="cite">
unforce_rtp_proxy();<br>
</blockquote>
<blockquote type="cite"> } else if
(is_method("INVITE")){<br>
</blockquote>
<blockquote type="cite">
force_rtp_proxy();<br>
</blockquote>
<blockquote type="cite"> }<br>
</blockquote>
<blockquote type="cite"> if
(!has_totag()) add_rr_param(";nat=yes");<br>
</blockquote>
<blockquote type="cite">#!endif<br>
</blockquote>
<blockquote type="cite"> return;<br>
</blockquote>
<blockquote type="cite">}<br>
</blockquote>
<blockquote type="cite"><br>
</blockquote>
<blockquote type="cite"><br>
</blockquote>
what you have to do is to check if the source is
natted and $si==$dd, then callee and caller are
behind same nat (if there is one level of nat),
so you don't force rtpproxy usage.<br>
<br>
Cheers,<br>
Daniel<br>
<br>
-- <br>
Daniel-Constantin Mierla<br>
Kamailio (OpenSER) Advanced Training<br>
Jan 24-26, 2011, Irvine, CA, USA<br>
<a moz-do-not-send="true"
href="http://www.asipto.com/">http://www.asipto.com</a><br>
<br>
</div>
</blockquote>
</div>
<br>
</div>
</blockquote>
<br>
<pre class="moz-signature" cols="72">--
Daniel-Constantin Mierla
Kamailio (OpenSER) Advanced Training
Jan 24-26, 2011, Irvine, CA, USA
<a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://www.asipto.com/">http://www.asipto.com</a></pre>
</div>
</blockquote>
</div>
<br>
</div>
<pre wrap="">
<fieldset class="mimeAttachmentHeader"></fieldset>
_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:sr-users@lists.sip-router.org">sr-users@lists.sip-router.org</a>
<a class="moz-txt-link-freetext" href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users</a>
</pre>
</blockquote>
<br>
<pre class="moz-signature" cols="72">--
Daniel-Constantin Mierla
Kamailio (OpenSER) Advanced Training
Jan 24-26, 2011, Irvine, CA, USA
<a class="moz-txt-link-freetext" href="http://www.asipto.com">http://www.asipto.com</a></pre>
</body>
</html>