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

Larry Alkoff labradley at mindspring.com
Tue Aug 22 18:33:55 MST 2006


  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



More information about the asterisk-users mailing list