Created
March 7, 2026 08:53
-
-
Save marco79cgn/7e086deb9fdad83a10199690518ca6d5 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
| myAddrApiKey="b3******f4" | |
| myAddrUrl="marco79.myaddr.io" | |
| ntfyUrl="https://ntfy.sh/****" | |
| if ! currentDynDns=$(dig +time=5 +tries=6 +short $myAddrUrl @86.54.11.100); then | |
| echo "Problem: dig network error or timeout." | |
| exit 1 | |
| fi | |
| echo "myaddr ip: $currentDynDns" | |
| currentIp=$(curl -s https://api.ipify.org) | |
| echo "Public ip: $currentIp" | |
| if [ $currentIp != "$currentDynDns" ]; then | |
| echo "IP changed, updating myaddr dns..." | |
| ddnssResult=$(curl -s "https://ipv4.myaddr.tools/update?ip=$currentIp&key=$myAddrApiKey") | |
| currentIpV6=$(curl -s 'https://api64.ipify.org') | |
| curl -s "https://ipv6.myaddr.tools/update?ip=$currentIpV6&key=$myAddrApiKey" | |
| ntfyResult=$(curl -s -X POST -H "Title: DDNS Update" -H "Tags: ballot_box_with_check" -d "$myAddrUrl mit IP-Adresse $currentIp aktualisiert!" $ntfyUrl) | |
| else | |
| echo "Nothing to do, ip hasn't changed." | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment