Dynamic DNS with NameSilo and PowerShell

Most people have cable internet and with ISPs like this you will notice that your IP changes from time to time. This causes headaches if you want to know how to access devices at your home network from a remote location. The typical solution to this is to use a Dynamic DNS provider. At one time it was DynDNS but they eliminated their free option years ago. I’ve been using the free option from No-IP but after the whole seized domain issues last summer I decided to look for another alternative. I was already looking for a new registrar for the domain names I own and after much research decided to switch to NameSilo. They had the best prices I could find and they also had a solution to the Dynamic DNS issue.

API Access

NameSilo, in addition to a number of other great features, also provides API access to manage domains. Once I found this out it was only a matter of writing some code to do it. In this example I created a PowerShell script to run as a scheduled task on a Windows machine but it would be similarly easy to write it in any programming language. First you need to get your API key:

Get an API Key

Go to the API Manager page and check the box for “Generate New API Key” and the checkbox to accept the API terms of use then click “Next”.


The following screen will show you the API key to be used in the next step


Create the PowerShell File

Below are the PowerShell commands that will compare the current public IP and if the DNS entry is doesn’t match the script will update it. The variables are all at the top of the list. Copy the code below and paste it into a text editor, change the APIkey, the domain you want to work with and the host you want to update (this should be a pre-existing A Record). In this example we’re update dyn.forkrobotics.com. Once you’re done save the file as NameSiloDDNS.ps1

# NameSilo API Dynamic DNS
$APIkey = "49d7202378997443f699a016”
$domain = "forkrobotics.com"
$record = "dyn"

###Code - Do not edit below this line
# Gather data about the DNS entries in the domain
$listdomains = Invoke-RestMethod -Uri "https://www.namesilo.com/api/dnsListRecords?version=1&type=xml&key=$APIkey&domain=$domain"
$CurrentIP = $listdomains.namesilo.request.ip
$RecordIP = ($listdomains.namesilo.reply.resource_record|where {$_.host -eq "$record.$domain"}).value
$RecordID = ($listdomains.namesilo.reply.resource_record|where {$_.host -eq "$record.$domain"}).record_id

# If the current IP address is not the same as the one in the record it updates it
if ($CurrentIP -ne $RecordIP){
$update = Invoke-RestMethod -Uri "https://www.namesilo.com/api/dnsUpdateRecord?version=1&type=xml&key=$APIkey&domain=$Domain&rrid=$RecordID&rrhost=$record&rrvalue=$CurrentIP&rrttl=3600"

Scheduled Task

Now we need to create a scheduled task for this to run automatically.

  1. Click Start and search for “Task Scheduler” or “Schedule Tasks” (depending on which version of Windows you’re on)
  2. Click “Create Basic Task”
  3. Name the Task & click Next
  4. Select Daily for when to run the task (you can set it to run more or less frequently if you like) & click Next
  5. Pick a time to run the script & click Next
  6. Pick “Start a Program” and click Next
  7. In the Program text box type “PowerShell.exe”
  8. In the “Add Arguments” box type “-ExecutionPolicy Bypass C:\scripts\NameSiloDDNS.ps1” & click Next
  9. Click Finish

 Next Steps

This is a simple script and is effective for Windows machines, however many of us use other platforms that will not run PowerShell commands. The next steps would be to recode this for a Linux based language.

3 thoughts on “Dynamic DNS with NameSilo and PowerShell

  1. Hi Justin,

    I replaced the APIKey and Domain name and record with mine own as shown below:

    –$APIkey = “my API Key”
    –$domain = “mydomain.com”
    –$record = “A” <—changed this to A record

    But i am getting msg below.

    code detail resource_record
    —- —— —————
    300 success {resource_record, resource_record, resource_record, resource_r…
    108 Missing parameters for the specified operation

    can you pls help?


    • Jan,

      I see you entered “A” as the record there this is the actual record, not the type of record. For example if you want your hostname to be “janhome.example.com” then $record should be “janhome”. And the janhome record of type A should already be created in NameSilo. I hope this helps.


      • Hi Justin,

        Thank for your reply. I am still having issue.

        I created “test” a CNAME for my domain.com and my script looks like this now:

        –$APIkey = “my API Key”
        –$domain = “domain.com”
        –$record = “test”

        The rest of script i have not touched it. But this time I get an msg which says

        300 success {resource_record, resource_record, resource_record..
        280 xxx.xxx.xx.xx (My public IP) must be a valid host

        Now we are getting close but it shows my public IP and says “must be a valid host”

        If i change the $record to “test1″ I get the first error which i posted.

        What am I missing here?

        Thanks for your help.


Leave a Reply to Jan Cancel reply