At work we’re currently using Neustar’s UltraDNS service to host 200+ DNS records, and I started a project to automate changing IP addresses to switch to DR sites. There is a well documented API for this, with great examples and solutions built mostly on Python, Perl, and Java. UltraDNS has published examples for all three of those on their Github page, and there is even a Perl module available on CPAN.

Since Powershell is my current lingua franca, I put together this rough writeup with some test code. I’ll eventually shape things into a Powershell module that does a few different functions, then tie it into a web interface to fully automate switching to DR IP addresses. The rest of my team is of course, in a nerdgasmic state over being able to press a few buttons to accomplish this.

First, have a look at the https://restapi.ultradns.com/v1/docs, which gives you a quick overview. UltraDNS customers also have access to more in depth documentation, including a full user guide. Some familiarity with using REST web services, Powershell’s built in commands for them, and reading the API documentation is helpful.

The API is at https://restapi.ultradns.com/v1 and uses tokens to authenticate. To use the service, you’ll need to first build a call to get an access token. This token has to be passed on to subsequent calls. The code below will return the value of the accessToken property. It goes without saying the credentials should be hidden in production.

In this example I’m using the test URI. This call to /token will return some other output. Remove the pipe to Select-Object to see it.

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

# Get auth token.

functiongetToken{

# Set a var with the URI.

$url="https://test-restapi.ultradns.com/v1/authorization/token"

# Set the body with an array of params to pass in.

$body=@{

grant_type='password';

username='user@somedomain.com';

password='someuserspassword';

}

# Call the service, pass in the body as a POST with x-ww-form-urlencoded content type, and get just the token.