Hey here a dirt easy ways to redirect a dns from the following services all of these are examples feel free to improve upon them some of the services are free some of em are $€£ but you might own one of those so i included them.
These are all working examples how you implement em is up too you
#afraid.org
Here is a working example, for afraid.org’s free DDNS (you must update the URL to use your private API key from afraid.org).
#!/bin/bash
curl -k "https://freedns.afraid.org/dynamic/update.php?PASTE_YOUR_KEY_HERE" >/dev/null 2>&1 &
if [ $? -eq 0 ]; then echo "update succeeded"; else echo "update failed"; fi
#dnsExit.com
Free DNS server that also offers DDNS services.
#!/bin/bash
USER=
PASS=
DOMAIN=
wget -qO - "http://update.dnsexit.com/RemoteUpdate.sv?login=$USER&password=$PASS&host=$DOMAIN"
if [ $? -eq 0 ]; then echo "update suceeded"; else echo "update failed"; fi
#Google Domains
#!/bin/bash
set -u
U=xxxx
P=xxxx
H=xxxx
# args: username password hostname
google_dns_update() {
CMD=$(curl -s https://$1:$2@domains.google.com/nic/update?hostname=$3)
logger "google-ddns-updated: $CMD"
case "$CMD" in
good*|nochg*) echo "update suceeded" ;;
abuse) echo "update abused" ;;
*) echo "update failed" ;;
esac
}
google_dns_update $U $P $H
exit 0
#DyNS
NOTE: the example below uses non-HTTPS which isn’t recommended. See example for afraid above.
provide a number of free and premium DNS related services for home or office use.
#!/bin/bash
# http://dyns.cx/documentation/technical/protocol/v1.1.php
USERNAME=
PASSWORD=
HOSTNAME=
DOMAIN= # optional
IP=${1}
DEBUG= # set to true while testing
URL="http://www.dyns.net/postscript011.php?username=${USERNAME}&password=${PASSWORD}&host=${HOSTNAME}&ip=${IP}"
if [ -n "${DOMAIN}" ] ; then
URL="${URL}&domain=${DOMAIN}"
fi
if [ -n "${DEBUG}" ] ; then
URL="${URL}&devel=1"
fi
wget -q -O - "$URL"
if [ $? -eq 0 ]; then
echo "update suceeded"
else
echo "update failed"
fi
#CloudFlare
If you use CloudFlare for your domains, this script can update any A record on your account.
#!/bin/bash
EMAIL= # Your CloudFlare E-mail address
ZONE= # The zone where your desired A record resides
RECORDID= # ID of the A record
RECORDNAME= # Name of the A record
API= # Your CloudFlare API Key
IP=${1}
curl -fs -o /dev/null -X PUT "https://api.cloudflare.com/client/v4/zones/$ZONE/dns_records/$RECORDID" \
-H "X-Auth-Email: $EMAIL" \
-H "X-Auth-Key: $API" \
-H "Content-Type: application/json" \
--data '{"id":"'$RECORDID'","type":"A","name":"'$RECORDNAME'","content":"'$IP'"}'
if [ $? -eq 0 ]; then
echo "update suceeded"
else
echo "update failed"
fi
#Namecheap
If you use Namecheap for your domains, this script can update any A record on your account. The script is currently (as of Aug 1 2015) required because the built-in script uses HTTP, while Namecheap requires HTTPS. To use this, replace HOSTNAME, DOMAIN and PASSWORD with your own values. You can refer to the DDNS FAQ at Namecheap for steps required.
#!/bin/bash
# Update the following variables:
HOSTNAME=[hostname]
DOMAIN=[domain.com]
PASSWORD=XXXXXXXXXXXXXXXXXXXXXXXX
# Should be no need to modify anything beyond this point
/usr/sbin/wget --no-check-certificate -qO - "https://dynamicdns.park-your-domain.com/update?host=$HOSTNAME&domain=$DOMAIN&password=$PASSWORD&ip="
if [ $? -eq 0 ]; then
echo "update suceeded"
else
echo "update failed"
fi
#DNS-O-Matic
If you use DNS-O-Matic to update your domains, this script can update all or a single host record on your account. To use this, replace dnsomatic_username, dnsomatic_password with your own values. You can refer to the DNS-O-Matic API Documentation for additional info.
Note: the HOSTNAME specified in the script below will update all records setup in your DNS-O-Matic account to have it only update a single host you will need to modify it accordingly. In some cases this may require you to specify the host entry, sometimes the domain entry.
To troubleshoot update issues you can run the curl command directly from the command line by passing in your details and removing the --silent option. If you get back good and your IP address back you’ve got it setup correctly. If you get back nohost, you’re not passing in the correct hostname value.
#!/bin/bash
# Update the following variables:
USERNAME=dnsomatic_username
PASSWORD=dnsomatic_password
HOSTNAME=all.dnsomatic.com
# Should be no need to modify anything beyond this point
/usr/sbin/curl -k --silent "https://$USERNAME:$PASSWORD@updates.dnsomatic.com/nic/update?hostname=$HOSTNAME&wildcard=NOCHG&mx=NOCHG&backmx=NOCHG&myip=" > /dev/null
if [ $? -eq 0 ]; then
echo "update suceeded"
else
echo "update failed"
fi
Note: It seems that the DNS-O-Matic API (at least when using a single https command) does not like an email address as the user name and will fail. DNS-O-Matic no longer allows the creation of a separate user name. However there is a workaround: Your DNS-O-Matic account is the same as your OpenDNS account. If you go to my account at opendns.com and choose display name (purportedly for forum use), this will also work in this script for user name. The suggestion above about running the curl command directly from the command line to test is really useful!
#Duck DNS
Just replace yoursubdomain and your-token with the values you got from duckdns. The hostname you set up in the GUI doesn’t matter, but I recommend setting it to your subdomain anyway.
#!/bin/bash
# register a subdomain at https://www.duckdns.org/ to get your token
SUBDOMAIN="yoursubdomain"
TOKEN="your-token"
# no modification below needed
curl --silent "https://www.duckdns.org/update?domains=$SUBDOMAIN&token=$TOKEN&ip=" >/dev/null 2>&1
if [ $? -eq 0 ];
then
echo "update suceeded"
else
echo "update failed"
fi
Just edit USERNAME, PASSWORD and HOSTNAME according to your setup, and you should be good to go. Dy.fi drops hosts after 7 days of inactivity, so I’d also recommend setting this to a cronjob.
#!/bin/bash
# http://www.dy.fi/page/specification
USERNAME="yourusername@whatever.com"
PASSWORD="yourtopsecretpassword"
HOSTNAME="yourhostname.dy.fi"
curl -D - --user $USERNAME:$PASSWORD https://www.dy.fi/nic/update?hostname=$HOSTNAME >/dev/null 2>&1
if [ $? -eq 0 ]; then
echo "update suceeded"
else
echo "update failed"
fi
#CloudFlare
#!/bin/bash
NEW_IP=`wget http://ipinfo.io/ip -qO -`
curl https://www.cloudflare.com/api_json.html \
-d 'a=rec_edit' \
-d 'tkn=YOUR_API_KEY_HERE’ \
-d 'email=YOUR_ACCOUNT_EMAIL_HERE’ \
-d 'z=ZONE_OR_ROOT_DOMAIN_NAME’ \
-d 'id=RECORD_ID’ \
-d 'type=A' \
-d 'name=DOMAIN_NAME’ \
-d 'ttl=1' \
-d "content=$NEW_IP"
echo $NEW_IP > /var/tmp/current_ip.txt
if [ $? -eq 0 ]; then
echo "update suceeded"
else
echo "update failed"
fi
#BIND9 DDNS using nsupdate
If you run your own DNS server with BIND9, this script uses nsupdate to update an A record. This requires that you are updating a zone configured for use with dynamic updates rather than the standard zone config files.
#!/bin/bash
# A bash script to update BIND9 DDNS using nsupdate and tsig key
# Tested with bash and bind-client to be installed from entware-ng
#User variables - replace with your variables
NS="ns1.example.com"
ZONE="dynamic.example.com"
DHOST="dhost.dynamic.example.com"
TSIGFILE="/tmp/sda1/mykey.tsig"
NSUPDATE=$(which nsupdate)
IP=$1
echo "server $NS" > /tmp/nsupdate
echo "debug yes" >> /tmp/nsupdate
echo "zone $ZONE." >> /tmp/nsupdate
echo "update delete $DHOST A" >> /tmp/nsupdate
echo "update add $DHOST 600 A $IP" >> /tmp/nsupdate
echo "send" >> /tmp/nsupdate
$NSUPDATE -k $TSIGFILE /tmp/nsupdate 2>&1 &
wait $!
echo $?
if [ $?==0 ]; then
echo "update suceeded"
else
echo "update failed"
fi
#Loopia
This scripts add Loopia support using curl just edit hostname and cred.
#!/bin/bash
# https://support.loopia.com/wiki/CURL
# Add your credentials here
cred=username:password
hostname=domain.com
# Don't edit anything beyond this point
burl=https://dns.loopia.se/XDynDNSServer/XDynDNS.php
wanip=$(curl -s ipecho.net/plain)
url="$burl"'?hostname='"$hostname"'&'myip="$wanip&wildcard=NOCHG"
loopia_dns_update() {
CMD=$(curl -s --user "$cred" "$url")
logger "ddns status: $CMD"
case "$CMD" in
good*|nochg*) echo "update suceeded" ;;
abuse) echo "update suceeded" ;;
*) echo "update failed" ;;
esac
}
loopia_dns_update
exit 0
#DNSimple
This script adds DNSimple support, get token and record_id from the site and edit all the variables.
#!/bin/bash
LOGIN="your@email"
TOKEN="your-api-token"
DOMAIN_ID="yourdomain.com"
RECORD_ID="12345" # Replace with the Record ID
IP=`curl -s http://icanhazip.com/`
curl --silent \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "X-DNSimple-Token: $LOGIN:$TOKEN" \
-X "PUT" \
-i "https://api.dnsimple.com/v1/domains/$DOMAIN_ID/records/$RECORD_ID" \
-d "{\"record\":{\"content\":\"$IP\"}}" > /dev/null
if [ $? -eq 0 ]; then
echo "update suceeded"
else
echo "update failed"
fi