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 <n...@gmx.ch> 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
> Astlinux-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/astlinux-users
>
> Donations to support AstLinux are graciously accepted via PayPal to
> pay...@krisk.org.
>
------------------------------------------------------------------------------
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
Astlinux-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/astlinux-users

Donations to support AstLinux are graciously accepted via PayPal to 
pay...@krisk.org.

Reply via email to