Get the DDNS of IP and update into /etc/hosts.allow
Save as below shell script as name: check_ddns_ip.sh
And Don’t forget to apply the LINE NOTIFY of API for script.
#!/bin/bash
# name: check_ddns_ip.sh
# Writey By Maruku Lin
# purpose: Check DDNS's IP and update into /etc/hosts.allow
# Date:12/23/2019
# Version:0.0.2
# Update:12/25/2019
########################
DDNS_LIST='a1.ddns.net a2.ddns.net'
for DDNS in $DDNS_LIST
do
PUBLIC_IP=$( dig +short $DDNS )
DATE=`date +%Y%m%d_%H%M`
LOG=/var/log/ddns_update.log
HOSTSFILE=/etc/hosts.allow
echo $DATE >> $LOG
echo $PUBLIC_IP >> $LOG
sed -i '/^\#DDNS/{n;N;d}' $HOSTSFILE
echo "sshd: ${PUBLIC_IP}" >> $HOSTSFILE
#cat $HOSTSFILE
curl -X POST -H '<Here put LINE NOTIFY of TOKEN>' -F "message=IP updated:${DATE}: ${DDNS} of IP is $PUBLIC_IP " https://notify-api.line.me/api/notify
done
In your cell phone (android) install the app :
Multi DynDNS Updater(Free)
Quick Link
e.g. Go to changeip.com to register an account and update the account of information into the app ” Multi DynDNS Updater(Free) ”
DDNS_LIST='<Put your Dynamic DNS in here, separated by space.>’
e.g. DDNS_LIST=’a1.ddns.net a2.ddns.net’
/etc/hosts.allow
#DDNS
sshd: 110.50.134.9
sshd: 39.10.75.23

FB 留言