-
-
Save pklaus/7fb26b32a9e1395c31a0 to your computer and use it in GitHub Desktop.
DynDNS with the InterNetworX XML-RPC API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<methodCall> | |
<methodName>updateRecord</methodName> | |
<params> | |
<param> | |
<value> | |
<struct> | |
<member> | |
<name>user</name> | |
<value> | |
<string>my_username</string> | |
</value> | |
</member> | |
<member> | |
<name>lang</name> | |
<value> | |
<string>en</string> | |
</value> | |
</member> | |
<member> | |
<name>pass</name> | |
<value> | |
<string>my_password</string> | |
</value> | |
</member> | |
<member> | |
<name>id</name> | |
<value> | |
<int>10777xxxx</int> | |
</value> | |
</member> | |
<member> | |
<name>content</name> | |
<value> | |
<string>%wan_ip%</string> | |
</value> | |
</member> | |
<member> | |
<name>ttl</name> | |
<value> | |
<int>300</int> | |
</value> | |
</member> | |
</struct> | |
</value> | |
</param> | |
</params> | |
</methodCall> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#------------------------------------------------------------------------------------------------------------ | |
# /root/updatedomain.sh | |
#------------------------------------------------------------------------------------------------------------ | |
# http://snippets.sim4000.de/show/35/ | |
# http://anwendungsentwickler.ws/dyndns_mit_der_inwx_xml-rpc_api/entry/313/ | |
if [ ! -f /root/updatedomainlastip ]; then | |
touch /root/updatedomainlastip | |
fi | |
current_ip=$(cat /root/updatedomainlastip) | |
wan_ip=`ifconfig ppp0 | grep "inet addr:" | cut -d ':' -f2 | cut -d ' ' -f1` | |
if [ ! "$wan_ip" == "$current_ip" ]; then | |
wget -q --user-agent="Mozilla/4.0" \ | |
--header="Host: api.domrobot.com" \ | |
--header="Content-Type: text/xml" \ | |
--post-data="$(cat /root/updatedata.xml | sed "s/%wan_ip%/$wan_ip/g")" \ | |
--no-check-certificate -O - \ | |
https://api.domrobot.com/xmlrpc/nameserver | |
echo $wan_ip > /root/updatedomainlastip | |
else | |
echo "do nothing..."; | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment