[asterisk-users] How to set externip in sip.conf automatically?

Rushowr rushowr at phreaker.net
Fri Aug 25 01:40:58 MST 2006


I believe you want to use ${ENV(variable)}.. From asterisk's CLI:

*CLI>show function ENV
  -= Info about function 'ENV' =-

[Syntax]
ENV(<envname>)

[Synopsis]
Gets or sets the environment variable specified


Note that ENV is a function...you need to encase the argument inside
parentheses



>-----Original Message-----
>From: asterisk-users-bounces at lists.digium.com 
>[mailto:asterisk-users-bounces at lists.digium.com] On Behalf Of 
>Larry Alkoff
>Sent: Wednesday, August 23, 2006 9:32 AM
>To: Asterisk Users Mailing List - Non-Commercial Discussion
>Subject: Re: [asterisk-users] How to set externip in sip.conf 
>automatically?
>
>As stated in the original post, when I entter the IP with an 
>editor directly into sip.conf calls work just fine but I am 
>looking for a way to have that done _automatically_.
>
>The Asterisk - Future of Telephony book says it is possible 
>for Asterisk to access a Linux environment variable containing 
>the IP information in the form of "${ENV{variable}}.
>
>It doesn't seem to work.  I am asking how to make it work.
>
>Larry
>
>Watkins, Bradley wrote:
>> If you already have the IP in a file, why don't you set it up so the 
>> file itself says:  externip=xx.xx.xx.xx and then do a #include in 
>> sip.conf for the /etc/myip file?  I believe you'll have to do a sip 
>> reload either way (which can obviously be part of your cron job) if 
>> you're not already, but that should do what you're looking to do.
>> 
>> - Brad
>> 
>> -----Original Message-----
>> From: asterisk-users-bounces at lists.digium.com
>> [mailto:asterisk-users-bounces at lists.digium.com] On Behalf Of Larry 
>> Alkoff
>> Sent: Tuesday, August 22, 2006 9:34 PM
>> To: Asterisk-users; Austin-asterisk-users
>> Subject: [asterisk-users] How to set externip in sip.conf 
>automatically?
>> 
>>   I need to give Asterisk access to my external IP address 
>to prevent 
>> the NAT problem where caller cannot hear the callee's voice.
>> 
>> According to Asterisk - The Future of Telephony page 92 Environment
>> Variables:
>> 
>>    "Environment variables are a way of accessing Unix environment 
>> variables from within Asterisk.  They are referenced in the form of
>>    ${ENV{var}}
>> where var is the Unix environment variable you wish to reference."
>> 
>> My external IP is placed each night in a file call /etc/myip and 
>> placed in the $MYIP variable by /etc/bashrc when an shell is loaded.
>> 
>> So I have /etc/myip refreshed each night in a cron job and when a 
>> shell is opened /etc/bashrc does:
>> export MYIP=`cat /etc/myip`
>> 
>> To access the variable in sip.conf I have tried:
>> 
>>      externip=${ENV(EXTERNIP)}
>> and
>>      ${ENV($EXTERNIP)}
>> but neither seems to work.
>> Is this the correct syntax?  Did I misinterpret the book?
>> 
>> I say neither seems to work because When I hard code
>> externip=69.91.84.176
>> there are no NAT problems but when I try to access the $MYIP 
>variable 
>> either of the ways above NAT prevents me hearing the callee's voice.
>> 
>> I have tried but not found a way to directly access the contents of 
>> MYIP to the console using the CLI.  Is there a way to see or 
>set _any_ 
>> Linux enviromnent variable using the CLI?  More generally, how do I 
>> access the Linux shell from the CLI?
>> 
>> The problem with simply using
>> externip=69.91.94.176
>> is that number is subject to change and I don't know an easy way to 
>> automatically write the value into sip.conf programatically.
>> 
>> I could have just said "how do I do this" but wanted to show 
>that I've 
>> done my homework.
>> Thanks for any help.
>> 
>> Larry
>> 
>> --
>> Larry Alkoff N2LA - Austin TX
>> Using Thunderbird on Linux
>> _______________________________________________
>> --Bandwidth and Colocation provided by Easynews.com --
>> 
>> asterisk-users mailing list
>> To UNSUBSCRIBE or update options visit:
>>    http://lists.digium.com/mailman/listinfo/asterisk-users
>> 
>> The contents of this e-mail are intended for the named 
>addressee only. It contains information that may be 
>confidential. Unless you are the named addressee or an 
>authorized designee, you may not copy or use it, or disclose 
>it to anyone else. If you received it in error please notify 
>us immediately and then destroy it. 
>> _______________________________________________
>> --Bandwidth and Colocation provided by Easynews.com --
>> 
>> asterisk-users mailing list
>> To UNSUBSCRIBE or update options visit:
>>    http://lists.digium.com/mailman/listinfo/asterisk-users
>> 
>
>
>--
>Larry Alkoff N2LA - Austin TX
>Using Thunderbird on Linux
>_______________________________________________
>--Bandwidth and Colocation provided by Easynews.com --
>
>asterisk-users mailing list
>To UNSUBSCRIBE or update options visit:
>   http://lists.digium.com/mailman/listinfo/asterisk-users
>





More information about the asterisk-users mailing list