Your own dyndns with Linode

Problem: you want a fixed host name to connect to your home network on some residential ISP service. You don’t have a static ip, so it could change at any time, and you want it to stay up to date.

There are a lot of services out there like dyndns and no-ip that do that for you for free, but it’s on their domain names. If you are hosting some of your own domains on linode, you can use their DNS API to do the same thing, but with your own host names. This is a little script I banged out 6 months ago to do that. The ruby can be used as is, the config.yml will need to be tweaked to your own needs below.

#!/usr/bin/ruby

require "yaml"
require "rubygems"
require "linode"
require "pp"

config = YAML.load_file('config.yml')

domain = config["domain"]
host = config["host"]

@d_id = 0
@r_id = 0

l = Linode.new(:api_key => config["API Key"])

# Get the domain id
l.domain.list.each do |d|
    if d.domain == domain
        @d_id = d.domainid
    end
end

# Get the actual host resource id
l.domain.resource.list("DomainID" => @d_id).each do |h|
    if h.name == host
        @r_id = h.resourceid
    end
end

# Update that to the current remote record
l.domain.resource.update(
                         "DomainID" => @d_id,
                         "ResourceID" => @r_id,
                         "Target" => "[remote_addr]"
                         )

This assumes a config.yml that looks something like this:

API Key: from linode account
domain: adomainthatIown.com
host: myhostname

One thought on “Your own dyndns with Linode”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s