DDns script for dnspod.cn and written in Python3
Write for router(Openwrt/LEDE), but it could be used in any Linux machine
opkg update
- install python3:
opkg install python3
- install pip:
- download
https://bootstrap.pypa.io/get-pip.py
- install
python get-pip.py
- download
- install requests:
pip install requests
- in
ddns.py
file
ID = "" # your ID
TOKEN = "" # Your Token
DOMAIN_NAME = "" # your domain
SUB_DOMAIN = "" # your sub domain
- upload file to router
- create a file in
/etc/ppp/ip-up.d
,and addpython3 /root/script/ddns.py > /tmp/log/dnspod.log
to file. DO NOT USE crontab! chmod 777 /etc/ppp/ip-up.d/<your_script_name>
Dnspod.cn declare a limitation that every user can only upload 5 times in an hour if remote IP address and local IP address is same.
They also sugget that build a script when you create a new dial-up connection, run the script to update your IP address.
So it is in /etc/ppp/ip-up.d
folder, that every time you use pppoe
to connect to the Internet and you will receive a new IP address. Then every time pppoe
runs, the OS will run every script in /etc/ppp/ip-up.d
folder.
- move all personal parameters to a config file.
- simplify code
WFTDPL
You just DO WHAT THE FUCK YOU WANT TO.