Skip to main content
Home
The Baheyeldin Dynasty
The journey for wisdom starts with knowledge
  • Home
  • About
  • Site Map
  • Contact

Using Linode Dynamic DNS with OpenWRT

  1. Home

By Khalid on 2014/04/07 - 13:38, last updated 2014/04/07 - 13:39

If you have a VPS at Linode, then you have free Dynamic DNS. You can use that from a regular Linux machine, or from a router that runs OpenWRT.

This article describes how to setup an OpenWRT router with Linode Dynamic DNS.

First, the script itself, which goes into the file: /etc/custom/linodedns.sh

#!/bin/ash
 
BASE=`basename $0 .sh`
DIR=`dirname $0`

OUTPUT1=/tmp/$BASE-1.out
OUTPUT2=/tmp/$BASE-2.out

# Read the configuration file
CONF=$DIR/$BASE.conf
if [ -r "$CONF" ]; then
  . $CONF
else 
  logger -t $BASE "Could not read configuration file: $CONF"
  exit 1
fi

# External Ethernet interface
IFACE=`uci get network.wan.ifname`

# Get the current external IP address
CURRIP=`ifconfig $IFACE | grep 'inet addr' | awk '/inet addr/ {print $2}' | awk -F: '{print $2}'`

# Get the currently configured IP address in Linode's DNS
curl -sk "https://api.linode.com/?api_key=$APIKEY&action=domain.resource.list&ResourceID=$RESOURCEID&DomainID=$DOMAINID" > $OUTPUT1
RC=$?
if [ "$RC" != 0 ];then 
  logger -t $BASE "curl list reported error: $RC"
  exit 2
fi

# Parse the output for the IP address
DNSIP=`cat $OUTPUT1 | sed -e 's/^.*"TARGET":"//' -e 's/",.*$//'`

if [ "$DNSIP" = "$CURRIP" ]; then
  logger -t $BASE "External IP address has not changed. No IP update necessary. IP address: $CURRIP"
  exit 0
fi

curl -sk "https://api.linode.com/?api_key=$APIKEY&action=domain.resource.update&ResourceID=$RESOURCEID&DomainID=$DOMAINID&Target=$CUR
RIP" > $OUTPUT2
RC=$?
if [ "$RC" != 0 ];then 
  logger -t $BASE "Curl update reported error: $RC"
  exit 2
fi

# Log the IP address change
logger -t $BASE "Updated IP address from $DNSIP to $CURRIP"

Then you have to create a configuration file, with the same name as the script, except that instead of .sh its suffix is .conf, for example: /etc/custom/linodedns.conf. You need to get the following values and place them in your configuration file.

APIKEY="your-api-key-goes-here"
RESOURCEID="resource-id-goes-here"
DOMAINID=domainid

Finally, have the script run automatically 3 times per hour, from cron. Use crontab -e, or "Scheduled Tasks" from LuCI, and add the following lines.

# Check external IP address, and update Linode's DNS if changed
5,25,45 * * * * /etc/custom/linodedns.sh

That is it. Now your public IP address will be updated no later 20 minutes if it changes!

Contents: 
Linux
Tags: 
OpenWRT
Linode
Dynamic DNS
  • Add comment

Current

Pandemic

  • COVID-19
  • Coronavirus

Search

Site map

Contents

  • Family
    • Khalid
    • Ancestry
    • Extended
  • Friends
  • Nokat نكت
  • Writings
    • Cooking
    • Culture
    • Science
    • History
    • Linguistics
    • Media
    • Literature
    • Politics
    • Humor
    • Terrorism
    • Business
    • Philosophy
    • Religion
    • Children
  • Technology
    • Linux
    • Arabization
    • Drupal
      • Association
    • Software
    • Internet
    • Technology in Society
    • Digital Archeology
    • NCR History
    • MidEast Internet
    • Programming
    • Saudi ISPs
    • Miscellaneous
  • Places
    • Canada
      • Weather
    • Egypt
      • Cuisine
      • Alexandria
      • E.G.C.
    • USA
    • Saudi Arabia
  • Interests
    • Astronomy
    • Fishing
    • Photography
    • Snorkeling
    • Nature
    • Photomicroscopy
  • Miscellany

In Depth

  • al-Hakim bi Amr Allah: Fatimid Caliph of Egypt الحاكم بأمر الله
  • Alexandria, Egypt
  • Arabic on the Internet
  • Articles on the history of Muslims and Arabs in the Iberian Peninsula تاريخ المسلمين و العرب في الأند
  • DIY GOTO Telescope Controller With Autoguiding and Periodic Error Correction
  • E.G.C. English Girls College in Alexandria, Egypt
  • Egyptian Cuisine, Food and Recipes مأكولات مصرية
  • George Saliba: Seeking the Origins of Modern Science?
  • Internet Scams and Fraud
  • Mistaken for an Arab or Muslim: Absurdities of being a victim in the War on Terror
  • Mistaken Identity: How some people confuse my site for others
  • One People's Terrorist Is Another People's Freedom Fighter
  • Overview of Google's Technologies
  • Photomicroscopy
  • Pseudoscience: Lots of it around ...
  • Resources for using Google Adsense with Drupal
  • Rockwood Conservation Area, Southern Ontario
  • Selected Symbolic Novels And Movies
  • Snorkeling the Red Sea near Jeddah
  • Updates and Thoughts on the Egyptian Revolution of 2011

Recent Content

Most recent articles on the site.

  • Origin Of COVID-19: Natural Spillover, Lab Leak Or Biological Weapon?
  • Kamal Salibi and the "Israel from Yemen" theory
  • How To Upgrade HomeAssistant Core In A Python Venv Using uv
  • Ancestry - Paternal Side
  • Review of Wait Water Saver For Whole House Humidifiers
more

Most Comments

Most commented on articles ...

  • Another scam via Craigslist: offering more than asking price
  • Warning to female tourists thinking of marrying Egyptians
  • Craigslist classified for used car: Cheque fraud scam
  • Winning the lottery scam email: World Cup South African lottery
  • Email Scam: BMW 5 Series car and lottery winning
more

About Khalid

Various little bits of information ...

  • Khalid Baheyeldin: brief biography
  • Presentations and Talks
  • Youtube Videos
  • GitHub Projects
  • Drupal.org Profile
  • Astrophotography @ Flickr

Sponsored Links

Your Link Ad Here

Tags

Android Mobile Ubuntu Sony OnStep OpenWRT Router Ericsson COVID-19 Rogers Coronavirus Arabic Kubuntu Home Assistant GSM Telescope tablet Spectrum Scam Python 419 Laptop Firefox DIY CPU Conspiracy Comet Balkanization backup App
More

© Copyright 1999-2025 The Baheyeldin Dynasty. All rights reserved.
You can use our content under the Terms of Use.
Please read our privacy policy before you post any information on this site.
All posted articles and comments are copyright by their owner, and reflect their own views and opinions, which may not necessarily be consistent with the views and opinions of the owners of The Baheyeldin Dynasty.

Web site developed by 2bits.com Inc.