Hi Dominic,
Thanks for sharing your solution.
That got me thinking, your solution has some similarities to how the dynamic
DNS client "ddclient" works.
It seems ddclient has a "postscript" option where an external script can be
called on an IP update, and additionally the script is called with "$1" set to
the new IP address.
So, if anyone is interested I'll throw out this *untested* alternative...
--
# copy the default general ddclient.conf to an editable place
cp /stat/etc/ddclient.conf /mnt/kd/ddclient.conf
#
# edit /mnt/kd/ddclient.conf and add this line at the top
postscript=/mnt/kd/bin/ddclient-action
#
# create the script "/mnt/kd/bin/ddclient-action"
====
#!/bin/sh
if [ -n "$1" ]; then
sed -i -e "s/^externip *=.*/externip=$1/" /etc/asterisk/sip.conf
asterisk -rx "sip reload"
logger -t ddclient-action -p kern.info "Asterisk SIP reload on ddclient
update to: $1"
fi
====
# make it executable
chmod 755 /mnt/kd/bin/ddclient-action
#
# Using the Network tab -> Dynamic DNS Update: [ ddclient ] - configure for
your provider
# { Reboot/Restart } - [ Restart Dynamic DNS ] - x Confirm
--
Again, this is untested.
Lonnie
On Jan 14, 2016, at 7:02 PM, Dominic Ouellette <[email protected]> wrote:
> This is the script i’m using to overcome this problem. It check the external
> IP and update the sip.conf with the new IP . Run this script as cronjob every
> 5 minutes
>
> #!/bin/bash
> # checksetexternip.sh
> # Author: John Cahill email at johncahill.net
> # Licence: GPL v3
> # Description: script that queries checkip.dyndns.com to find the server's
> external IP address. Updates asterisk's externip value and does a sip reload
> if necessary.
> # Last modified 06/02/2012
>
> is_ip(){
>
> input=$1
> octet1=$(echo $input | cut -d "." -f1)
> octet2=$(echo $input | cut -d "." -f2)
> octet3=$(echo $input | cut -d "." -f3)
> octet4=$(echo $input | cut -d "." -f4)
> stat=1
>
> if [[ $input =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]] && [
> $octet1 -le 255 ] && [ $octet2 -le 255 ] && [ $octet3 -le 255 ] && [ $octet4
> -le 255 ];
> then
> stat=0
> fi
>
> return $stat
>
> }
>
> EXTERNIP=`wget -qO- http://checkip.dyndns.com | awk '{print $6}'| cut -d"<"
> -f1`
> is_ip $EXTERNIP
> if [ $? -ne 0 ]
> then
> logger -s "checksetexternip.sh: External IP address invalid
> or unavailable, exiting."
> exit 1
> fi
>
> OLDEXTERNIP=`grep externip /etc/asterisk/sip.conf | cut -d"=" -f2`
> if [ "$EXTERNIP" = "$OLDEXTERNIP" ]
> then
> logger -s "checksetexternip.sh: External IP address is the
> same, nothing to do exiting."
> exit 0
> else
> logger -s "checksetexternip.sh: External IP address has
> changed, changing /etc/asterisk/sip.conf"
> #grep -v "externip" /etc/asterisk/sip.conf >
> /etc/asterisk/sip.conf.tmp
> #echo "externip=$EXTERNIP" >> /etc/asterisk/sip.conf.tmp
> #cp /etc/asterisk/sip.conf.tmp /etc/asterisk/sip.conf
> #rm /etc/asterisk/sip.conf.tmp
> sed -i -e "s/^externip
> *=.*/externip=$EXTERNIP/" /etc/asterisk/sip.conf
> logger -s "Doing asterisk -rx "sip reload""
> asterisk -rx "sip reload"
>
>
> On Thu, Jan 14, 2016 at 6:19 PM, nedi <[email protected]> wrote:
> Hi all,
> i have some astlinux installations and one big problem every time wan ip
> changed ... astlinux accounts can't register to provider.
>
> Reboot of Astlinux (alix board) can't solve this problem
> sip reload or asterisk reload can't fix that problem.
> shutdown and wait for some time and after that boot again can't solve this
> problem.
> I tryd to put the DNS Server form Provider and I tryed to put the IP adress
> instead of sip server name.
>
>
> I found my provider sipcall.ch have some other sip server if I change the
> server and connect to other server all number are registered after that I can
> change again to the old server and all works.
>
>
> The Provider Sipcall told me astlinux trying to register and use old IP
> adress not the new one.
>
>
> in 2010 wrote dominko how to fix i think the same problem but i can't find
> that script for /etc/ppp/ip-up and /etc/ppp/ip-down.
>
> Has anyone the same problem and is there a way to fix that ?
>
> best regards
>
>
> Nedi
>
> ------------------------------------------------------------------------------
> Site24x7 APM Insight: Get Deep Visibility into Application Performance
> APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
> Monitor end-to-end web transactions and take corrective actions now
> Troubleshoot faster and improve end-user experience. Signup Now!
> http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140
> _______________________________________________
> Astlinux-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/astlinux-users
>
> Donations to support AstLinux are graciously accepted via PayPal to
> [email protected].
>
> ------------------------------------------------------------------------------
> Site24x7 APM Insight: Get Deep Visibility into Application Performance
> APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
> Monitor end-to-end web transactions and take corrective actions now
> Troubleshoot faster and improve end-user experience. Signup Now!
> http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140_______________________________________________
> Astlinux-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/astlinux-users
>
> Donations to support AstLinux are graciously accepted via PayPal to
> [email protected].
------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140
_______________________________________________
Astlinux-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/astlinux-users
Donations to support AstLinux are graciously accepted via PayPal to
[email protected].