<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
pre
        {mso-style-priority:99;
        mso-style-link:"HTML Preformatted Char";
        margin:0cm;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:"Courier New";}
p.msonormal0, li.msonormal0, div.msonormal0
        {mso-style-name:msonormal;
        mso-margin-top-alt:auto;
        margin-right:0cm;
        mso-margin-bottom-alt:auto;
        margin-left:0cm;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
span.HTMLPreformattedChar
        {mso-style-name:"HTML Preformatted Char";
        mso-style-priority:99;
        mso-style-link:"HTML Preformatted";
        font-family:Consolas;}
span.EmailStyle20
        {mso-style-type:personal;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
span.EmailStyle21
        {mso-style-type:personal;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
span.EmailStyle22
        {mso-style-type:personal;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
span.EmailStyle23
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><o:p> </o:p></p><div><p class=MsoNormal style='mso-margin-top-alt:0cm;margin-right:1.0pt;margin-bottom:5.0pt;margin-left:1.0pt'><span style='color:#595959'>Hello Bogdan<o:p></o:p></span></p><p class=MsoNormal style='mso-margin-top-alt:0cm;margin-right:1.0pt;margin-bottom:5.0pt;margin-left:1.0pt'><span style='color:#595959'><o:p> </o:p></span></p><p class=MsoNormal style='mso-margin-top-alt:0cm;margin-right:1.0pt;margin-bottom:5.0pt;margin-left:1.0pt'><span style='color:#595959'>I did follow the second aproach and it works fine.<o:p></o:p></span></p><p class=MsoNormal style='mso-margin-top-alt:0cm;margin-right:1.0pt;margin-bottom:5.0pt;margin-left:1.0pt'><span style='color:#595959'><o:p> </o:p></span></p><p class=MsoNormal style='mso-margin-top-alt:0cm;margin-right:1.0pt;margin-bottom:5.0pt;margin-left:1.0pt'><span style='color:#595959'>Thank you for your support once more.<o:p></o:p></span></p><p class=MsoNormal style='mso-margin-top-alt:0cm;margin-right:1.0pt;margin-bottom:5.0pt;margin-left:1.0pt'><span style='color:#595959'><o:p> </o:p></span></p><p class=MsoNormal style='mso-margin-top-alt:0cm;margin-right:1.0pt;margin-bottom:5.0pt;margin-left:1.0pt'><span style='color:#595959'>Best regards<o:p></o:p></span></p><p class=MsoNormal style='mso-margin-top-alt:0cm;margin-right:1.0pt;margin-bottom:5.0pt;margin-left:1.0pt'><span style='color:#595959'><o:p> </o:p></span></p></div><p class=MsoNormal><o:p> </o:p></p><div><div style='border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm'><p class=MsoNormal><b>From:</b> Bogdan-Andrei Iancu <bogdan@opensips.org> <br><b>Sent:</b> Δευτέρα, 7 Απριλίου 2025 12:46<br><b>To:</b> apsaras@microbase.gr; 'OpenSIPS users mailling list' <users@lists.opensips.org>; 'Johan De Clercq' <Johan@democon.be><br><b>Subject:</b> Re: [OpenSIPS-Users] mhomed OpenSIPs behind NAT - How to control NAT IP<o:p></o:p></p></div></div><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><span style='font-family:"Courier New"'>Hi Antonios,<br><br>There are 2 different approaches here. <br><br>a) you can use the set_advertised_address(), in a per message manner, but sometimes is difficult to control (you need to manually do the persistence across the call)<br>    <a href="https://www.opensips.org/Documentation/Script-CoreFunctions-3-5#set_advertised_address">https://www.opensips.org/Documentation/Script-CoreFunctions-3-5#set_advertised_address</a><br><br>b) if you have only 2 classes of sources (from public network and from private network), just use 2 different sockets with different advertising. Say 10.0.0.10:5060 no advertising, for traffic from 10.0.x.x, and 10.0.0.10:5066 with advertising of 1.2.3.4:5060 (the nat fwd should be from 1.2.3.4:5060 -> 10.0.0.10:5066 !) for the public traffic. This is much easier to deal with, as the depending on which interface the traffic goes, the advertising will automatically be done.<br><br>Best regards,<br><br></span><o:p></o:p></p><pre>Bogdan-Andrei Iancu<o:p></o:p></pre><pre><o:p> </o:p></pre><pre>OpenSIPS Founder and Developer<o:p></o:p></pre><pre>  <a href="https://www.opensips-solutions.com">https://www.opensips-solutions.com</a><o:p></o:p></pre><pre>  <a href="https://www.siphub.com">https://www.siphub.com</a><o:p></o:p></pre><div><p class=MsoNormal>On 03.04.2025 16:56, Antonios Psaras wrote:<o:p></o:p></p></div><blockquote style='margin-top:5.0pt;margin-bottom:5.0pt'><p class=MsoNormal>Hello Bogdan.<o:p></o:p></p><p class=MsoNormal> <o:p></o:p></p><p class=MsoNormal>What we need is to advertise different IP for the same interface different IP based on Client Source IP.<o:p></o:p></p><p class=MsoNormal> <o:p></o:p></p><p class=MsoNormal>For example<o:p></o:p></p><p class=MsoNormal> <o:p></o:p></p><p class=MsoNormal>OpenSIPs Interface IP is 10.0.0.10 and NAT IP is 1.2.3.4<o:p></o:p></p><p class=MsoNormal> <o:p></o:p></p><p class=MsoNormal>When Client IP is 10.0.0.100 we need to advertise 10.0.0.10<o:p></o:p></p><p class=MsoNormal> <o:p></o:p></p><p class=MsoNormal>When Client IP is 4.3.2.1 we need to advertise 1.2.3.4<o:p></o:p></p><p class=MsoNormal> <o:p></o:p></p><p class=MsoNormal>Thank you once more for your support<o:p></o:p></p><p class=MsoNormal> <o:p></o:p></p><p class=MsoNormal>Best regards<o:p></o:p></p><p class=MsoNormal> <o:p></o:p></p><p class=MsoNormal>Antonis Psaras<o:p></o:p></p><p class=MsoNormal> <o:p></o:p></p><p class=MsoNormal> <o:p></o:p></p><div><div style='border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm'><p class=MsoNormal><b>From:</b> Bogdan-Andrei Iancu <a href="mailto:bogdan@opensips.org"><bogdan@opensips.org></a> <br><b>Sent:</b> Πέμπτη, 3 Απριλίου 2025 09:57<br><b>To:</b> <a href="mailto:apsaras@microbase.gr">apsaras@microbase.gr</a>; 'OpenSIPS users mailling list' <a href="mailto:users@lists.opensips.org"><users@lists.opensips.org></a>; 'Johan De Clercq' <a href="mailto:Johan@democon.be"><Johan@democon.be></a><br><b>Subject:</b> Re: [OpenSIPS-Users] mhomed OpenSIPs behind NAT - How to control NAT IP<o:p></o:p></p></div></div><p class=MsoNormal> <o:p></o:p></p><p class=MsoNormal><span style='font-family:"Courier New"'>Hi,<br><br>You can have a socket on the private interface (behind NAT) which is advertising in the outbound SIP packages a different IP address (the public IP of the NAT , for example) than the one of the socket.<br><br>Isn't this what you were asking for?<br><br>Regards,<br><br><br></span><o:p></o:p></p><pre>Bogdan-Andrei Iancu<o:p></o:p></pre><pre> <o:p></o:p></pre><pre>OpenSIPS Founder and Developer<o:p></o:p></pre><pre>  <a href="https://www.opensips-solutions.com">https://www.opensips-solutions.com</a><o:p></o:p></pre><pre>  <a href="https://www.siphub.com">https://www.siphub.com</a><o:p></o:p></pre><div><p class=MsoNormal>On 02.04.2025 15:32, Antonios Psaras wrote:<o:p></o:p></p></div><blockquote style='margin-top:5.0pt;margin-bottom:5.0pt'><p class=MsoNormal>Thank you Bogdan.<o:p></o:p></p><p class=MsoNormal> <o:p></o:p></p><p class=MsoNormal>I can not see how advertise option will be use in that case.<o:p></o:p></p><p class=MsoNormal> <o:p></o:p></p><p class=MsoNormal>We use the socket option and my question is if I can handle that within the script.<o:p></o:p></p><p class=MsoNormal> <o:p></o:p></p><p class=MsoNormal>Ie.<o:p></o:p></p><p class=MsoNormal> <o:p></o:p></p><p class=MsoNormal>socket = udp:10.0.0.10:5060 as 1.2.3.4:5060<o:p></o:p></p><p class=MsoNormal> <o:p></o:p></p><p class=MsoNormal>if source_ip=~”^10.”<o:p></o:p></p><p class=MsoNormal>                Do not use NAT IP on header<o:p></o:p></p><p class=MsoNormal>else<o:p></o:p></p><p class=MsoNormal>                User it.<o:p></o:p></p><p class=MsoNormal> <o:p></o:p></p><p class=MsoNormal> <o:p></o:p></p><p class=MsoNormal> <o:p></o:p></p><div><div style='border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm'><p class=MsoNormal><b>From:</b> Bogdan-Andrei Iancu <a href="mailto:bogdan@opensips.org"><bogdan@opensips.org></a> <br><b>Sent:</b> Τετάρτη, 2 Απριλίου 2025 15:03<br><b>To:</b> <a href="mailto:apsaras@microbase.gr">apsaras@microbase.gr</a>; OpenSIPS users mailling list <a href="mailto:users@lists.opensips.org"><users@lists.opensips.org></a>; 'Johan De Clercq' <a href="mailto:Johan@democon.be"><Johan@democon.be></a><br><b>Subject:</b> Re: [OpenSIPS-Users] mhomed OpenSIPs behind NAT - How to control NAT IP<o:p></o:p></p></div></div><p class=MsoNormal> <o:p></o:p></p><p class=MsoNormal><span style='font-family:"Courier New"'>Hi Antonioss,<br><br>See the "advertise" option - there is a global one, or a per-socket on:<br>    <a href="https://www.opensips.org/Documentation/Script-CoreParameters-3-5#advertised_address">https://www.opensips.org/Documentation/Script-CoreParameters-3-5#advertised_address</a><br>    <a href="https://www.opensips.org/Documentation/Script-CoreParameters-3-5#socket">https://www.opensips.org/Documentation/Script-CoreParameters-3-5#socket</a>  (the AS option)<br><br>Regards,<br><br><br><br></span><o:p></o:p></p><pre>Bogdan-Andrei Iancu<o:p></o:p></pre><pre> <o:p></o:p></pre><pre>OpenSIPS Founder and Developer<o:p></o:p></pre><pre>  <a href="https://www.opensips-solutions.com">https://www.opensips-solutions.com</a><o:p></o:p></pre><pre>  <a href="https://www.siphub.com">https://www.siphub.com</a><o:p></o:p></pre><div><p class=MsoNormal>On 02.04.2025 15:00, Antonios Psaras wrote:<o:p></o:p></p></div><blockquote style='margin-top:5.0pt;margin-bottom:5.0pt'><p class=MsoNormal>Hello Johan<o:p></o:p></p><p class=MsoNormal> <o:p></o:p></p><p class=MsoNormal>Thank you for your prompt reply.<o:p></o:p></p><p class=MsoNormal> <o:p></o:p></p><p class=MsoNormal>My question is how do I force opensips not to use NAT IP which is defined on socket level?<o:p></o:p></p><p class=MsoNormal> <o:p></o:p></p><p class=MsoNormal>As you mention rtpengine as well, what flags should I pass in order not to use the NAT IP which is also defined as configuration on “external” interface.<o:p></o:p></p><p class=MsoNormal> <o:p></o:p></p><p class=MsoNormal>Thank you once more for your support.<o:p></o:p></p><p class=MsoNormal> <o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:0cm;margin-right:1.0pt;margin-bottom:5.0pt;margin-left:1.0pt'><b><span style='color:#5F5F5F'>Antonis Psaras</span></b><o:p></o:p></p><p class=MsoNormal> <o:p></o:p></p><p class=MsoNormal><b>From:</b> Johan De Clercq <a href="mailto:Johan@democon.be"><Johan@democon.be></a> <br><b>Sent:</b> Τετάρτη, 2 Απριλίου 2025 13:23<br><b>To:</b> <a href="mailto:apsaras@microbase.gr">apsaras@microbase.gr</a>; OpenSIPS users mailling list <a href="mailto:users@lists.opensips.org"><users@lists.opensips.org></a><br><b>Subject:</b> Re: [OpenSIPS-Users] mhomed OpenSIPs behind NAT - How to control NAT IP<o:p></o:p></p><p class=MsoNormal> <o:p></o:p></p><div><p class=MsoNormal>Antonias, <o:p></o:p></p><div><p class=MsoNormal>yes you can.  You need to if then else the stuff.  if $si==1.2.34 then use nat <o:p></o:p></p></div><div><p class=MsoNormal>                                                                                                    else don't use nat.<o:p></o:p></p></div><div><p class=MsoNormal> <o:p></o:p></p></div><div><p class=MsoNormal>Note, not only for opensips headers, but you will also need different flags for rtpengine. <o:p></o:p></p></div><div><p class=MsoNormal> <o:p></o:p></p></div><div><p class=MsoNormal> <o:p></o:p></p></div></div><p class=MsoNormal> <o:p></o:p></p><div><div><p class=MsoNormal>Op wo 2 apr 2025 om 11:35 schreef Antonios Psaras <<a href="mailto:apsaras@microbase.gr">apsaras@microbase.gr</a>>:<o:p></o:p></p></div><blockquote style='border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0cm;margin-bottom:5.0pt'><div><div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>Dear all.<o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'> <o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>I have the following setup.<o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'> <o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>OpenSIPs Server has two interfaces (DMZ / LAN). DMZ is behind NAT. RTP Engines is also configured.<o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'> <o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>Everything was fine until an end point with in DMZ asked for SIP Trunking. The issue here is that if DMZ Client tries to connect to OpenSIPs DMZ interface, OpenSIPs will reply with NAT IP on SIP body as well as NAT IP on SDP.<o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'> <o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>My thought is to create an other socket on DMZ interface with a different port without NAT configuration and ask the DMZ Client to connect on that interface. That will required extra configuration per peer as I will need to specify the preferred communication socket ie on load balancing configuration. Moreover I should configure a new RTPEngine Service without NAT configuration and route those calls to that one. <o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'> <o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>Most probably the above scenario will work but I am looking for any alternatives to minimize configuration and complexity. <o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'> <o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>Is there any way to control the usage of NAT IP on OpenSIPs script. Ie if source IP is with in DMZ do not send NAT IP in SIP Headers.<o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'> <o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>Regards<o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'> <o:p></o:p></p></div></div><p class=MsoNormal>_______________________________________________<br>Users mailing list<br><a href="mailto:Users@lists.opensips.org" target="_blank">Users@lists.opensips.org</a><br><a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><o:p></o:p></p></div></blockquote></div><p class=MsoNormal><br><br><br><br><o:p></o:p></p><pre>_______________________________________________<o:p></o:p></pre><pre>Users mailing list<o:p></o:p></pre><pre><a href="mailto:Users@lists.opensips.org">Users@lists.opensips.org</a><o:p></o:p></pre><pre><a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><o:p></o:p></pre></blockquote><p class=MsoNormal> <o:p></o:p></p></blockquote><p class=MsoNormal> <o:p></o:p></p></blockquote><p class=MsoNormal><o:p> </o:p></p></div></body></html>