QNAP Asterisk SIP IP Tracking
trunk_ip_check.sh- #!/bin/sh
- PEER="sz-gw"
- ASTCMD="/opt/sbin/asterisk -rx"
- NSLCMD="ping -c 1"
- OLD_IP=`$ASTCMD "sip show peer $PEER" | grep "Addr->IP" | cut -c 16- | cut -f2 -d\ `
- PEER_HOST=`$ASTCMD "sip show peer $PEER" | grep "ToHost" | cut -c 16- | cut -f2 -d\ `
- NEW_IP=`$NSLCMD $PEER_HOST | head -1 | cut -f3 -d\ | sed s/:// | sed s/\(// | sed s/\)//`
- if [ $NEW_IP != $OLD_IP ]
- then
- $ASTCMD "sip reload"
- echo "$PEER `date` IP changed from $OLD_IP to $NEW_IP then sip reload" >> /opt/etc/asterisk/trunk_ip_change.dat
- fi
複製代碼 In the file /mnt/HDA_ROOT/.config/crontab add the following cron job- */5 * * * * /bin/sh /opt/etc/asterisk/trunk_ip_check.sh
複製代碼 Restart the cron routine- /etc/init.d/crond.sh restart
複製代碼 YH |