How to make DDNS update run at startup:
1_ Install PYthon via Synology package manager
2_ Take script from here (www.debian-administration.org/articles/28) and modify it to run the DDNS PY script through a SCREEN session (the following must be in the "start" session of some startup script):
echo "Starting refresh from FTPD" >> /root/refreshlog
/opt/bin/screen -d -m sh -c "/etc/init.d/pythonstrap"
/etc/init.d/pythonstrap being defined like this:
/usr/bin/python /etc/init.d/refresh_DDNS_JB.py
3_ You need "screen"! For that you need to install ipkg. Follow this: http://forum.synology.com/wiki/index.php/Overview_on_modifying_the_Synology_Server,_bootstrap,_ipkg_etc#How_to_install_ipkg
4_ ipkg is not working! You need to add /opt/bin AT THE BEGINING of your PATH at following locations:
* /root/.profile
* /etc/profile
4_ Now finish install ipkg:
* ipkg update
* ipkg upgrade
5_ Install screen:
* ipkg install screen
6_ ... Make DDNS script run at startup. I'M STUCK HERE. I copied my .sh script here (with CHMOD 0755) and there but it won't run at startup, don't know why:
* /opt/etc/init.d/S99refreshDDNSJB.sh
* /usr/syno/etc/rc.d/S99refreshDDNSJB.sh
So for now I run the script manually after each reboot... but what if power outage...
7_ FOUND THE REASON: in startup scripts, you must specify the full path to screen! Like: /opt/bin/screen. Yeepee!!!
8_ And: I had to put the script insite S99ftpd.sh. A standalone script won't be launched! But I'm tired to find out why.... There must be a Synology command to refresh the startup list but who cares.
Nice reference about startup scripts on Synology: http://forum.synology.com/enu/viewtopic.php?f=27&t=48260
dimanche 24 février 2013
jeudi 7 février 2013
How to fix Synology DDNS update (with No-IP)
Synology NAS are accessible from the outside using DDNS server, but their client apparently fails to update public IP changes when standing behind a NAT router (which is the common case for home usage, unless you're lucky enough to have an IPv6 ISP).
So what could I do? After not finding a solution, needing one and still loving my NAS, I wrote my own update script in Python.
To run it at startup: http://www.debian-administration.org/articles/28
Enjoy:
# Update my dynamic IP address on No-IP.org
import urllib2
import time
from datetime import datetime
URL = 'http://dynupdate.no-ip.com/nic/update?hostname=homebj.no-ip.org'
useragent = 'Synology DDNS bugfixer/1.0 your_email_noip@canazzi.com'
username = 'your_noip_username'
password = 'your_noip_password'
while 1:
try:
passman = urllib2.HTTPPasswordMgrWithDefaultRealm()
passman.add_password(None, URL, username, password)
authhandler = urllib2.HTTPBasicAuthHandler(passman)
opener = urllib2.build_opener(authhandler)
opener.addheaders = [('User-agent', useragent)]
urllib2.install_opener(opener)
pagehandle = urllib2.urlopen(URL)
reply_good = pagehandle.read()
pagehandle.close()
print datetime.now(), ":", reply_good
# every hour: update!
time.sleep(3600)
except:
print datetime.now(), ":", "Failed to update IP! "
time.sleep(300)
So what could I do? After not finding a solution, needing one and still loving my NAS, I wrote my own update script in Python.
To run it at startup: http://www.debian-administration.org/articles/28
Enjoy:
# Update my dynamic IP address on No-IP.org
import urllib2
import time
from datetime import datetime
URL = 'http://dynupdate.no-ip.com/nic/update?hostname=homebj.no-ip.org'
useragent = 'Synology DDNS bugfixer/1.0 your_email_noip@canazzi.com'
username = 'your_noip_username'
password = 'your_noip_password'
while 1:
try:
passman = urllib2.HTTPPasswordMgrWithDefaultRealm()
passman.add_password(None, URL, username, password)
authhandler = urllib2.HTTPBasicAuthHandler(passman)
opener = urllib2.build_opener(authhandler)
opener.addheaders = [('User-agent', useragent)]
urllib2.install_opener(opener)
pagehandle = urllib2.urlopen(URL)
reply_good = pagehandle.read()
pagehandle.close()
print datetime.now(), ":", reply_good
# every hour: update!
time.sleep(3600)
except:
print datetime.now(), ":", "Failed to update IP! "
time.sleep(300)
Inscription à :
Articles (Atom)