Step 5 – Setup dynamic DNS client on NAS
Now both registrar and dynamic DNS provider is setup probably.
The final step is to install DDNS client so that our DNS record is updated for every IP address changes.
There are lots of ddns client provided on afraid.org
Following types of client is provided
- DD-WRT router client
- Tomato router client
- Windows client
- Unix client
If none of them works for you (hmmm… ) , you may want to try the simple client written by me below.
- SSH to the NAS as root
- Install wget and bash shell
# ipkg update # ipkg install bash # ipkg install wget # ipkg install dos2unix
- Copy the script below and paste to notepad. Modify your own afraid.org code and verify all the path highlighted in red. Save it to a share folder on the NAS, i.e. public. Save the file as ddns.sh.
#!/opt/bin/bash # # simple script to update everydns.net/afraid.org/opendns for ip changes # version 0.21 # # Copyrighted by Ray Chan 2011 # # pre-requistics # - wget # - bash # If you want a simple log file, assign 1 to log_enabled, otherwise set it to 0 log_enabled=1; #0=disable, 1=enable # date format used by log file datestamp=`date '+%Y-%m-%d %H:%M:%S'` #input the freedns dynamic domain code here freednscode=xxxxxxxxxxxxxxxxxxxxxxx # the actual command getting the public IP, change the URL to your php hosting myipnow=`wget --timeout=10 --tries=1 -qO - http://whatismyip.com/automation/n09230945.asp` previp="0.0.0.0"; # path of the log file, ignore if log_enabled=0 logfile="/opt/var/log/ddns.log" # path of the temporary file storing prevoius ip address iplog="/opt/tmp/ddns.log" if [ -f $iplog ]; then previp=`cat $iplog` fi if [ $myipnow != $previp ]; then # update to afraid.org wget --read-timeout=0.0 --waitretry=5 --tries=400 -qO - http://freedns.afraid.org/dynamic/update.php?$freednscode > /dev/null #write the new ip to log file echo $myipnow > $iplog #write to log if enabled if [ $log_enabled = 1 ]; then echo "$datestamp IP changed, updating ddns. [ $previp | $myipnow ]" >> $logfile fi fi
- Move the script to /usr/local/bin
# mv /volume1/public/ddns.sh /usr/local/bin
- convert the script to unix format
# cd /usr/local/bin
# dos2unix ddns.sh
- Make the script executable, and read only by root
# chmod 700 /usr/local/bin/ddns.sh
- Add a scheduled job (cron) to the NAS so that the script will be executed per 5 minutes in order to detect IP changes
# vi /etc/crontab
Add follow entries to the end of the crontab file
#minute hour mday month wday who command */5 * * * * root /opt/bin/bash /usr/local/bin/ddns.sh
- Restart crontab
# /usr/syno/etc/rc.d/S04crond.sh stop # /usr/syno/etc/rc.d/S04crond.sh start
Step 6 – Add port forwarding from broadband router for external access.
In order to access different NAS services from external network, you need to setup port forwarding in your broadband router. Most of the other articles here have description about setup port forwarding for linksys router. I will not repeat here again.
Following is some common ports you might want to forward to your NAS.
80 – web station, web mail (mail station), photo station
443 – web station with ssl encryption
7001 – file station
22 – ssh
5000, 5001 – control panel (DSM)
21, 55536-56559 – ftp
Now your own domain name (i.e. nas.yourdomain.com) is attached to your dynamic IP! You can always access your diskstation using your domain name:
http://nas.yourdomain.com (access the web station)
http://nas.yourdomain.com:5000 (access the control panel)
ftp://nas.yourdomain.com (ftp to your nas)
** If you are using afraid.org as described above, and you are satisfied with their services, please consider make a donation to show your appreciation of their services. Indeed, free services rely on donation to cover the daily operation cost. Please consider being a paid member 🙂
** DNS changes can take up to 48 hours to propagate. New domain name changes, however, may effect almost instantly. Please be patient if you DNS is not working yet.