[SR-Users] environmental variables in kamailio

Daniel-Constantin Mierla miconda at gmail.com
Thu Oct 24 11:16:18 CEST 2019


Hello,

indeed there is a pseudo-variable that gives the environment variables.
Moreover, iirc, Luis Azedo added a while ago (it may be only from 5.3)
support to resolve variables inside substdef (and maybe define) -- so
eventually you should be able to do this with 5.3.0:

#!substdef "/PUBLICIP/$env(KAMPUBLICIP)/"

 listen=udp:$(local_ip):5060 advertise  "PUBLICIP":5060

It might not work for this specific case, because listen value is a
little bit complex definition, not just string values. But with 5.3
there is a command line parameter (-l -- lower case L) to specify listen
socket with advertise address. So just remove listen from kamailio.cfg
and the start kamailio like:

kamailio -l proto:localaddr:lcoalport/publicaddr:publicport

Like:

kamailio -l udp:10.0.0.1:5080/1.2.3.4:5060

See kamailio -h for more details.

Cheers,
Daniel

On 24.10.19 09:28, Rick Barenthin wrote:
> I've never used it but wiki says:
>
>
>     $env(NAME) - environment variables
>
> *$env(NAME)* - value of the environment variable named NAME
>
> So it should be possible.
>
> Alex Balashov <abalashov at evaristesys.com
> <mailto:abalashov at evaristesys.com>> schrieb am Do., 24. Okt. 2019, 08:16:
>
>     It is not. But you can do this via any template system such as
>     Jinja2, or a hand-rolled substitution script.
>
>>     Sent from mobile, with due apologies for brevity and errors.
>
>>     On Oct 24, 2019, at 2:02 AM, Gaurav Bmotra
>>     <saigauravmehra91 at gmail.com <mailto:saigauravmehra91 at gmail.com>>
>>     wrote:
>>
>>     
>>     hi 
>>     i using kamailio 5.2 
>>     is it possible to use environmental variables value in kamailio.cfg 
>>     like i want to use local ip and public ip in config file 
>>
>>      listen=udp:$(local_ip):5060 advertise  $(public_ip):5060
>>     if iti is possible then how i can use this 
>>
>>
>>     thank you 
>>     -- 
>>
>>
>>
>>
>>
>>
>>
>>
>>     *Regards:*
>>     Gaurav Kumar
>>
>>     _______________________________________________
>>     Kamailio (SER) - Users Mailing List
>>     sr-users at lists.kamailio.org <mailto:sr-users at lists.kamailio.org>
>>     https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
>     _______________________________________________
>     Kamailio (SER) - Users Mailing List
>     sr-users at lists.kamailio.org <mailto:sr-users at lists.kamailio.org>
>     https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
>
>
> _______________________________________________
> Kamailio (SER) - Users Mailing List
> sr-users at lists.kamailio.org
> https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users

-- 
Daniel-Constantin Mierla -- www.asipto.com
www.twitter.com/miconda -- www.linkedin.com/in/miconda
Kamailio Advanced Training, Oct 21-23, 2019, Berlin, Germany -- https://asipto.com/u/kat

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-users/attachments/20191024/9791ca88/attachment.html>


More information about the sr-users mailing list