How to Config NAS IP Monitor

2014.09.14 | Rev 0.00

I use shell script + cron service to monitor dynamic IP address.

Config NAS IP Monitor and push it to server

IpMonitor.sh

#!/bin/bash

####################################

# 2013/10/25 IpMonitor.sh v0.00

# Auther: Fleviliu

####################################

#PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin

#export PATH

#Read current file to get previous IP address

SavedIP=$(cat ip.txt)

# Get current IP address from ddns.oray.com/checkip

curl http://ddns.oray.com/checkip | grep '\:*\<' | cut -d ":" -f2 | cut -d "<" -f1 | cut -d " " -f2 > ip.txt

#Read current file to get previous IP address

NewIP=$(cat ip.txt)

remotedir=/www/

host=256.256.256.256

userid=admin

# Check the current IP address if is changed

if [ "$NewIP" != "$SavedIP" ]

then

scp ip.txt ${userid}@${host}:${remotedir}

echo "[===== IP Changed! =====]"

else

echo "No Change"

fi

#Write to log file.