[OpenSIPS-Users] How to get all listening socket IP address as variable
Bogdan-Andrei Iancu
bogdan at opensips.org
Fri Nov 19 10:35:28 EST 2021
Hi Putra,
Actually a recent fix should allow in the latest 3.2 version to use the
socket's tag when setting the outbound socket, like :
socket=udp:enp1s0:5060 TAG internal # INTERNAL_INTERFACE (192.168.1.2)
socket=udp:enp2s0:5060 TAG external # EXTERNAL_INTERFACE (DHCP)
...
....
$socket_out = "external";
But use the latest 3.2, git or nightly builds.
Regards,
Bogdan-Andrei Iancu
OpenSIPS Founder and Developer
https://www.opensips-solutions.com
OpenSIPS eBootcamp 2021
https://opensips.org/training/OpenSIPS_eBootcamp_2021/
On 11/19/21 11:31 AM, Muhamad Putra Abdullah wrote:
>
> Hi,
>
> Thank you so much for the info.
>
> Best regards,
>
> Putra
>
> *From:*Bogdan-Andrei Iancu <bogdan at opensips.org>
> *Sent:* Friday, 19 November, 2021 3:11 PM
> *To:* Muhamad Putra Abdullah <m.putra77 at outlook.com>; OpenSIPS users
> mailling list <users at lists.opensips.org>
> *Subject:* Re: [OpenSIPS-Users] How to get all listening socket IP
> address as variable
>
> Hi,
>
> I see, you start listening on an interface (enp2s0), which translates
> into the DHCP IP, but you can not use the socket/listener to do a
> force send socket ....as there is no way to reference it.
> Unfortunately something like that is not possible right now, but I see
> it as a valuable addition.
>
> For the moment, what you can do is to use some pre-processing (see
> [1]) in order to fill in your CFG the actual IP - and do an IP
> detection from the opensips init.d / startup script.
>
>
> [1] https://www.opensips.org/Documentation/Templating-Config-Files-3-0
> <https://www.opensips.org/Documentation/Templating-Config-Files-3-0>
>
> Best regards,
>
>
> Bogdan-Andrei Iancu
> OpenSIPS Founder and Developer
> https://www.opensips-solutions.com <https://www.opensips-solutions.com>
> OpenSIPS eBootcamp 2021
> https://opensips.org/training/OpenSIPS_eBootcamp_2021/ <https://opensips.org/training/OpenSIPS_eBootcamp_2021/>
>
> On 11/18/21 4:50 AM, Muhamad Putra Abdullah wrote:
>
> Hi,
>
> Ok. I’m totally in learning process.
>
> Let me explain my test deployment. I have 2 separate network that
> connected via opensips server.
>
> Internal SIP Server Opensips
> Server (2 NIC) External SIP Server
>
> (User 634) 192.168.1.1 - - - - - - - - 192.168.1.2 |
> (EXTERNAL_IP) DHCP IP - - - - - - - - 172.16.16.1 (User 605)
>
> What my intension is to relay calls between Internal and External
> SIP server via Opensips server.
>
> I use this method to achieve this:
>
> socket=udp:enp1s0:5060 # INTERNAL_INTERFACE (192.168.1.2)
>
> socket=udp:enp2s0:5060 # EXTERNAL_INTERFACE (DHCP)
>
> .
>
> .
>
> # From Internal to External
>
> # Testing one number only first 634 to 605
>
> if ($rU=~"^605") {
>
> sethostport("EXTERNAL_IP:5060");
>
> $socket_out = "udp:EXTERNAL_IP:5060";
>
> rtpproxy_engage("ier");
>
> route(relay);
>
> exit;
>
> }
>
> # From External to internal
>
> # Testing one number only first 605 to 634
>
> if ($rU=~"^634"){
>
> sethostport("192.168.1.2:5060");
>
> $socket_out = "udp:192.168.1.2:5060";
>
> rtpproxy_engage("eir");
>
> route(relay);
>
> exit;
>
> }
>
> I have no problem on call from external to internal because I know
> the IP address of internal opensips server, the problem is call
> from internal to external.
>
> Is there better solutions than this?
>
> Regards
>
> *From:*Bogdan-Andrei Iancu <bogdan at opensips.org>
> <mailto:bogdan at opensips.org>
> *Sent:* Wednesday, 17 November, 2021 8:24 PM
> *To:* Muhamad Putra Abdullah <m.putra77 at outlook.com>
> <mailto:m.putra77 at outlook.com>; OpenSIPS users mailling list
> <users at lists.opensips.org> <mailto:users at lists.opensips.org>
> *Subject:* Re: [OpenSIPS-Users] How to get all listening socket IP
> address as variable
>
> If so, when you receive a request on the external IP, the
> $socket_in(ip) should return the actual DHCP IP.
>
> Regards,
>
>
> Bogdan-Andrei Iancu
>
>
>
> OpenSIPS Founder and Developer
>
> https://www.opensips-solutions.com <https://www.opensips-solutions.com>
>
> OpenSIPS eBootcamp 2021
>
> https://opensips.org/training/OpenSIPS_eBootcamp_2021/ <https://opensips.org/training/OpenSIPS_eBootcamp_2021/>
>
> On 11/17/21 10:21 AM, Muhamad Putra Abdullah wrote:
>
> Hi,
>
> socket=udp:enp1s0:5060 tag INTERNAL_IP # CUSTOMIZE ME
>
> socket=udp:enp2s0:5060 tag EXTERNAL_IP # CUSTOMIZE ME
>
> My INTERNAL_IP is set to static and EXTERNAL_IP set to DHCP. I
> just use tag to test something.
>
> Regards
>
> *From:*Bogdan-Andrei Iancu <bogdan at opensips.org>
> <mailto:bogdan at opensips.org>
> *Sent:* Wednesday, 17 November, 2021 3:55 PM
> *To:* Muhamad Putra Abdullah <m.putra77 at outlook.com>
> <mailto:m.putra77 at outlook.com>; OpenSIPS users mailling list
> <users at lists.opensips.org> <mailto:users at lists.opensips.org>
> *Subject:* Re: [OpenSIPS-Users] How to get all listening
> socket IP address as variable
>
> Hi,
>
> How do you define the listening socket in OpenSIPs cfg ? (the
> one related to the DHCP interface)
>
> Regards,
>
>
>
> Bogdan-Andrei Iancu
>
>
>
> OpenSIPS Founder and Developer
>
> https://www.opensips-solutions.com <https://www.opensips-solutions.com>
>
> OpenSIPS eBootcamp 2021
>
> https://opensips.org/training/OpenSIPS_eBootcamp_2021/ <https://opensips.org/training/OpenSIPS_eBootcamp_2021/>
>
> On 11/17/21 2:19 AM, Muhamad Putra Abdullah wrote:
>
> Hi,
>
> Is there a way to get the IP address of DHCP interface to
> use in the script? I can get the call go through if I set
> both the interface as static.
>
> Regards
>
> Get Outlook for Android <https://aka.ms/AAb9ysg>
>
> ------------------------------------------------------------------------
>
> *From:* Bogdan-Andrei Iancu <bogdan at opensips.org>
> <mailto:bogdan at opensips.org>
> *Sent:* Tuesday, November 16, 2021, 6:45 PM
> *To:* OpenSIPS users mailling list; Muhamad Putra Abdullah
> *Subject:* Re: [OpenSIPS-Users] How to get all listening
> socket IP address as variable
>
>
> Hi,
>
> via the socket_xx() vars you can get only the sockets
> relative to/used by that call, you cannot iterate thru the
> listening sockets.
>
> Regards,
>
>
>
> Bogdan-Andrei Iancu
>
>
>
> OpenSIPS Founder and Developer
>
> https://www.opensips-solutions.com <https://www.opensips-solutions.com>
>
> OpenSIPS eBootcamp 2021
>
> https://opensips.org/training/OpenSIPS_eBootcamp_2021/ <https://opensips.org/training/OpenSIPS_eBootcamp_2021/>
>
> On 11/15/21 9:39 AM, Muhamad Putra Abdullah wrote:
>
> Hi,
>
> I have 2 listening interface for opensips 3.2. How do
> I get both IP address to be used as variable in
> opensips config file? I try to use socket_in/
> socket_out but failed to get the other interface IP
> address.
>
> Thanks
>
> Sent from Mail
> <https://go.microsoft.com/fwlink/?LinkId=550986> for
> Windows
>
>
>
>
>
> _______________________________________________
>
> Users mailing list
>
> Users at lists.opensips.org <mailto:Users at lists.opensips.org>
>
> http://lists.opensips.org/cgi-bin/mailman/listinfo/users <http://lists.opensips.org/cgi-bin/mailman/listinfo/users>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/users/attachments/20211119/0943f606/attachment-0001.html>
More information about the Users
mailing list