Friday, 26 November 2010

Dynamic DNS for EC2

I have just had to setup dynamic DNS for one of our test EC2 instances. We use DNS Made Easy for our DNS who allow dynamic DNS updates. Once I had setup the record in their systems a very quick groovy script was all I needed:


def ip = getPublicIP()
def id = "[recordID]"
def username = "username"
def password = "password"

def url = "http://www.dnsmadeeasy.com/servlet/updateip?username=${username}&password=${password}&id=${id}&ip=${ip}"
def result = url.toURL().text
println result

def getPublicIP(){
"http://169.254.169.254/latest/meta-data/public-ipv4".toURL().text
}

No comments: