Difference between revisions of "Dyndns Updater"
Jump to navigation
Jump to search
Rafahsolis (talk | contribs) |
Rafahsolis (talk | contribs) m Tag: visualeditor |
||
| (4 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
| − | = Duck DNS = | + | =Duck DNS= |
| − | * Create an account at https://www.duckdns.org/ | + | |
| − | * Create the script /var/local/duckdns/updater.sh (chmod 700) | + | *Create an account at https://www.duckdns.org/ |
| − | + | *Create the script /var/local/duckdns/updater.sh (chmod 700) | |
| + | *create the log file: touch /var/local/duckdns/duck.log | ||
| + | <source lang="bash">LOG_FILE=/var/local/duckdns/duck.log | ||
DATE=$(date +"%F %T") | DATE=$(date +"%F %T") | ||
| − | RESULT=$( echo url="https://www.duckdns.org/update?domains=flirt,zr0ke,r0942,m0rpheus&token= | + | RESULT=$( echo url="https://www.duckdns.org/update?domains=flirt,zr0ke,r0942,m0rpheus&token=********-****-****-****-************&ip=" | curl -s -k -K - ) |
echo ${DATE} ${RESULT} >> ${LOG_FILE} | echo ${DATE} ${RESULT} >> ${LOG_FILE} | ||
| − | </source> | + | </source><blockquote>improved script</blockquote><syntaxhighlight lang="bash"> |
| − | * crontab -e | + | #!/bin/bash |
| + | |||
| + | # Your DuckDNS token | ||
| + | TOKEN="********-****-****-****-************" | ||
| + | |||
| + | # List of your DuckDNS subdomains | ||
| + | DOMAINS=("r0942" "zr0ke" "labelbosque") | ||
| + | |||
| + | # Optional: IP address to set (leave empty to use external IP) | ||
| + | IP="" | ||
| + | |||
| + | # Log file | ||
| + | LOGFILE="$HOME/duckdns/update.log" | ||
| + | |||
| + | log() { | ||
| + | local message="$1" | ||
| + | local timestamp | ||
| + | timestamp=$(date '+%Y-%m-%d %H:%M:%S') | ||
| + | echo "$timestamp - $message" >> "$LOGFILE" | ||
| + | } | ||
| + | |||
| + | for DOMAIN in "${DOMAINS[@]}"; do | ||
| + | if [ -z "$DOMAIN" ]; then | ||
| + | log "Skipped empty domain entry" | ||
| + | continue | ||
| + | fi | ||
| + | |||
| + | URL="https://www.duckdns.org/update?domains=${DOMAIN}&token=${TOKEN}&ip=${IP}" | ||
| + | RESPONSE=$(curl -s --fail "$URL") || RESPONSE="curl_error" | ||
| + | |||
| + | if [ "$RESPONSE" == "OK" ]; then | ||
| + | log "Updated $DOMAIN successfully" | ||
| + | else | ||
| + | log "Failed to update $DOMAIN: $RESPONSE" | ||
| + | fi | ||
| + | done | ||
| + | |||
| + | |||
| + | </syntaxhighlight> | ||
| + | |||
| + | *crontab -e | ||
| + | |||
*/5 * * * * /var/local/duckdns/updater.sh >/dev/null 2>&1 | */5 * * * * /var/local/duckdns/updater.sh >/dev/null 2>&1 | ||
| − | = NO-IP = | + | =NO-IP= |
| − | == Ubuntu 16.04 server == | + | ==Ubuntu 16.04 server== |
<nowiki>sudo apt install ddclient</nowiki> | <nowiki>sudo apt install ddclient</nowiki> | ||
| − | == /etc/ddclient.conf example == | + | ==/etc/ddclient.conf example== |
<nowiki>## ddclient configuration file | <nowiki>## ddclient configuration file | ||
| − | daemon=600 | + | daemon=600 |
| − | # check every 600 seconds | + | # check every 600 seconds |
| − | syslog=yes | + | syslog=yes |
| − | # log update msgs to syslog | + | # log update msgs to syslog |
| − | mail-failure=redteam@bbva.com # Mail failed updates to user | + | mail-failure=redteam@bbva.com # Mail failed updates to user |
| − | pid=/var/run/ddclient.pid | + | pid=/var/run/ddclient.pid |
| − | # record PID in file. | + | # record PID in file. |
| − | ssl=yes | + | ssl=yes |
| − | # use HTTPS | + | # use HTTPS |
| − | ## Detect IP with our CheckIP server | + | ## Detect IP with our CheckIP server |
| − | use=web, web=checkip.dyndns.com/, web-skip='IP Address' | + | use=web, web=checkip.dyndns.com/, web-skip='IP Address' |
| − | ## DynDNS username and password here | + | ## DynDNS username and password here |
| − | login=RedTeam | + | login=RedTeam |
| − | password=##YOUR PASSWORD## | + | password=##YOUR PASSWORD## |
| − | ## Default options | + | ## Default options |
| − | protocol=dyndns2 | + | protocol=dyndns2 |
| − | server=members.dyndns.org | + | server=members.dyndns.org |
| − | ## Dynamic DNS hosts | + | ## Dynamic DNS hosts |
| − | rrafara.dyndns.org</nowiki> | + | rrafara.dyndns.org</nowiki> |
| − | Restart service | + | Restart ddclient service |
Latest revision as of 12:32, 4 November 2025
Duck DNS[edit]
- Create an account at https://www.duckdns.org/
- Create the script /var/local/duckdns/updater.sh (chmod 700)
- create the log file: touch /var/local/duckdns/duck.log
LOG_FILE=/var/local/duckdns/duck.log
DATE=$(date +"%F %T")
RESULT=$( echo url="https://www.duckdns.org/update?domains=flirt,zr0ke,r0942,m0rpheus&token=********-****-****-****-************&ip=" | curl -s -k -K - )
echo ${DATE} ${RESULT} >> ${LOG_FILE}
improved script
#!/bin/bash
# Your DuckDNS token
TOKEN="********-****-****-****-************"
# List of your DuckDNS subdomains
DOMAINS=("r0942" "zr0ke" "labelbosque")
# Optional: IP address to set (leave empty to use external IP)
IP=""
# Log file
LOGFILE="$HOME/duckdns/update.log"
log() {
local message="$1"
local timestamp
timestamp=$(date '+%Y-%m-%d %H:%M:%S')
echo "$timestamp - $message" >> "$LOGFILE"
}
for DOMAIN in "${DOMAINS[@]}"; do
if [ -z "$DOMAIN" ]; then
log "Skipped empty domain entry"
continue
fi
URL="https://www.duckdns.org/update?domains=${DOMAIN}&token=${TOKEN}&ip=${IP}"
RESPONSE=$(curl -s --fail "$URL") || RESPONSE="curl_error"
if [ "$RESPONSE" == "OK" ]; then
log "Updated $DOMAIN successfully"
else
log "Failed to update $DOMAIN: $RESPONSE"
fi
done
- crontab -e
*/5 * * * * /var/local/duckdns/updater.sh >/dev/null 2>&1
NO-IP[edit]
Ubuntu 16.04 server[edit]
sudo apt install ddclient
/etc/ddclient.conf example[edit]
## ddclient configuration file
daemon=600
# check every 600 seconds
syslog=yes
# log update msgs to syslog
mail-failure=redteam@bbva.com # Mail failed updates to user
pid=/var/run/ddclient.pid
# record PID in file.
ssl=yes
# use HTTPS
## Detect IP with our CheckIP server
use=web, web=checkip.dyndns.com/, web-skip='IP Address'
## DynDNS username and password here
login=RedTeam
password=##YOUR PASSWORD##
## Default options
protocol=dyndns2
server=members.dyndns.org
## Dynamic DNS hosts
rrafara.dyndns.org
Restart ddclient service