commit 4f24fad154365fbad40718ac4f1d3cdc46c4ef0e Author: Roger Sikorski Date: Mon Aug 1 21:54:05 2022 +0200 first commit diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..5d47c21 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,12 @@ +# EditorConfig is awesome: https://EditorConfig.org + +# top-most EditorConfig file +root = true + +[*] +indent_style = space +indent_size = 2 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..36be7a5 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "editor.defaultFormatter": "esbenp.prettier-vscode", + "editor.formatOnSave": true, + "editor.formatOnPaste": false +} diff --git a/README.md b/README.md new file mode 100644 index 0000000..dcecd16 --- /dev/null +++ b/README.md @@ -0,0 +1,6 @@ +Forked from [gist mcarpenterjr/godaddy_ddns.sh]8https://gist.github.com/mcarpenterjr/1dedf9f9f842710ba5f07937ef4f5ae49 + +Changes: +* usage of wtfismyip.com +* added IPv6 support (for the poor people which ISP is regularly changing the ipv6 ranges) +* lower ttl (600) diff --git a/godaddy_ddns_ipv4.sh b/godaddy_ddns_ipv4.sh new file mode 100755 index 0000000..552d465 --- /dev/null +++ b/godaddy_ddns_ipv4.sh @@ -0,0 +1,44 @@ +#!/bin/bash + +# This script is used to check and update your GoDaddy DNS server to the IP address of your current internet connection. +# Special thanks to mfox for his ps script +# https://github.com/markafox/GoDaddy_Powershell_DDNS +# +# First go to GoDaddy developer site to create a developer account and get your key and secret +# +# https://developer.godaddy.com/getstarted +# Be aware that there are 2 types of key and secret - one for the test server and one for the production server +# Get a key and secret for the production server +# +#Update the first 4 variables with your information + +domain="" # your domain +name="" # name of A record to update +key="" # key for godaddy developer API +secret="" # secret for godaddy developer API + +headers="Authorization: sso-key $key:$secret" + +# echo $headers # debug + +result=$(curl -s -X GET -H "$headers" \ + "https://api.godaddy.com/v1/domains/$domain/records/A/$name") + +dnsIp=$(echo $result | grep -oE "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b") +# echo "dnsIp:" $dnsIp # debug + +# Get public ip address there are several websites that can do this. +currentIp=$(curl -s GET "https://ipv4.wtfismyip.com/text") +echo "currentIp:" $currentIp + + if [ $dnsIp != $currentIp ]; + then + # echo "Ips are not equal" ## debug + request='{"data":"'$currentIp'","ttl":600}' + # echo $request # debug + nresult=$(curl -i -s -X PUT \ + -H "$headers" \ + -H "Content-Type: application/json" \ + -d $request "https://api.godaddy.com/v1/domains/$domain/records/A/$name") + echo $nresult +fi diff --git a/godaddy_ddns_ipv6.sh b/godaddy_ddns_ipv6.sh new file mode 100755 index 0000000..47a5e94 --- /dev/null +++ b/godaddy_ddns_ipv6.sh @@ -0,0 +1,44 @@ +#!/bin/bash + +# This script is used to check and update your GoDaddy DNS server to the IP address of your current internet connection. +# Special thanks to mfox for his ps script +# https://github.com/markafox/GoDaddy_Powershell_DDNS +# +# First go to GoDaddy developer site to create a developer account and get your key and secret +# +# https://developer.godaddy.com/getstarted +# Be aware that there are 2 types of key and secret - one for the test server and one for the production server +# Get a key and secret for the production server +# +#Update the first 4 variables with your information + +domain="" # your domain +name="" # name of A record to update +key="" # key for godaddy developer API +secret="" # secret for godaddy developer API + +headers="Authorization: sso-key $key:$secret" + +# echo $headers + +result=$(curl -s -X GET -H "$headers" \ + "https://api.godaddy.com/v1/domains/$domain/records/AAAA/$name") + +dnsIp=$(echo $result | grep -oE "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b") +echo "dnsIp:" $dnsIp + +# Get public ip address there are several websites that can do this. +currentIp=$(curl -s GET "https://ipv6.wtfismyip.com/text") +echo "currentIp:" $currentIp + + if [ $dnsIp != $currentIp ]; + then + # echo "Ips are not equal" # debig + request='{"data":"'$currentIp'","ttl":600}' + # echo $request # debug + nresult=$(curl -i -s -X PUT \ + -H "$headers" \ + -H "Content-Type: application/json" \ + -d $request "https://api.godaddy.com/v1/domains/$domain/records/AAAA/$name") + echo $nresult +fi