Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

The dashboard for Rackspace's next generation of servers doesn't have an option to set the reverse DNS for a cloud server. You have to use the Rackspace Cloud API. How do I use the API to set up the reverse DNS for my server?

share

migrated from stackoverflow.com Nov 22 '12 at 16:40

This question came from our site for professional and enthusiast programmers.

locked by Mark Henderson Nov 23 '12 at 5:14

This question exists because it has historical significance, but it is not considered a good, on-topic question for this site, so please do not use it as evidence that you can ask similar questions here. This question and its answers are frozen and cannot be changed. More info: help center.

comments disabled on deleted / locked posts

1 Answer

I've written this up largely so that I've got a future reference for it, but also because I imagine there'll be other people looking for the info and I couldn't find it online. There may also be a better way of doing this, so any suggestions are very welcome.

Here's the method used to set the reverse DNS for a next generation cloud server - this one is based at the UK data center but there's also a link for the US one. Unlike the previous cloud offering, there's no way of doing this using the web interface so you have to use curl and the Rackspace Cloud API plus a bit of JSON magic.

Here goes...

Step 1: Get an Authentication Token

This is different from your Rackspace API key - sounds obvious, but I made this mistake. It stays live for 24 hours and you'll need the token to authenticate your request to set the reverse DNS.

curl -H "x-auth-key:RACKSPACE_API_KEY" -H "x-auth-user:RACKSPACE_USERNAME" \
https://lon.identity.api.rackspacecloud.com/v1.0 -i

N.B. If your server is in the US, you'll need to use a different URL https://identity.api.rackspacecloud.com/v1.0 (see this knowledgebase article for info).

You can find your API key by logging into to your Rackspace MyCloud Dashboard, click on your username (you'll need that too) in the top right hand corner and choose the API Keys option.

The response will looking something like this:

HTTP/1.1 204 No Content
Server: nginx/0.8.55
Date: Thu, 22 Nov 2012 10:15:37 GMT
Connection: keep-alive
X-Storage-Token: YOUR_STORAGE_TOKEN
X-Auth-Token: YOUR_AUTH_TOKEN
vary: Accept, Accept-Encoding, X-Auth-Token, X-Auth-Key, X-Storage-User, X-Storage-Pass, X-Auth-User
Cache-Control: s-maxage=74459
VIA: 1.0 Repose (Repose/2.3.5)
Front-End-Https: on

There'll be some other info too, but the one you want is YOUR_AUTH_TOKEN.

Step 2: Create a JSON file with the reverse DNS info

The reverse DNS record or PTR record, for those that speak DNS, is specified using JSON and saved into a file. Use the template below and fill in the info that's specific to your server, save it in to a file, here we'll use the file ptr.

{
"recordsList":{
"records": [ {
"name" : "DOMAIN_NAME",
"type" : "PTR",
"data" : "IP_ADDRESS",
"ttl" : 56000
}
]},
"link" : {
"content" : "",
"href" : "https://lon.servers.api.rackspacecloud.com/v2/RACKSPACE_USERID/servers/NEXTGEN_SERVERID",
"rel" : "cloudServersOpenStack"
}
}

replacing the following place holders with your info:

  • DOMAIN_NAME - the domain name to use e.g. server1.mycompany.com
  • IP_ADDRESS - used for the reverse lookup
  • RACKSPACE_USERID - the numeric ID for the Rackspace user, find this in the API Keys page on your Rackspace Dashboard, click on username in top right-hand corner, select API Keys.
  • NEXTGEN_SERVERID - The ID of the server - get from the main list of servers, hover over the server name and you'll get a pop-up window listing the server's ID.

Step 3: Use Rackspace Cloud API to Set Reverse DNS

Last job is to fire this information at Rackspace Cloud's API to set the record. Almost there!

Use the following curl command, substituting in the values YOUR_AUTH_TOKEN and RACKSPACE_USERID that you'll have obtained from the previous two steps.

The @ptr part of the command refers to the file with the JSON info that we created above:

curl -H "x-auth-token: YOUR_AUTH_TOKEN" \
https://lon.dns.api.rackspacecloud.com/v1.0/RACKSPACE_USERID/rdns \
-d @ptr -H "Content-Type: application/json" -i

The response should look something like this:

HTTP/1.1 202 Accepted
Date: Thu, 22 Nov 2012 10:22:12 GMT
Content-Length: 598
X-API-VERSION: 1.0.20
Content-Type: application/json
Server: Jetty(8.0.y.z-SNAPSHOT)

which is good news and means the info has been accepted. It'll take a while to propogate across the DNS system. Last time I set a record, it took about 30 mins for most servers to pick up the info.

Bit fiddly, but once you've wrapped your head around it, should all work fine. A massive thank you to Oliver Gross at Rackspace's support for fantastic support on this and pointers to Rackspace support docs. As always, use at your own peril and make sure there's plenty of testing.

Cross-posted from this post on my blog.

share
add comment