Sunday, June 29, 2014

Tip for using ddclient on AWS EC2 instances

I have a long-running EC2 instance on which I host a few simple services. On this instance I configured ddclient to update my public IP for my no-ip hostname.

Recently I started getting warnings from no-ip that if I don't update the IP, my hostname will be deleted.

After checking the logs on my instance, I found this:
Jun 29 13:04:09 hostname ddclient[1676]: WARNING:  cannot connect to checkip.dyndns.com:80 socket: IO::Socket::INET: Bad hostname 'checkip.dyndns.com'

I googled for that error message and found several bug reports, mostly from last year, and the bug was supposedly fixed.
Regardless, I was using dyndns to check for my IP, and updating my ip on the no-ip service. That feels kind of wrong. I wanted to kill two flies with one blow, so I tried using EC2 metadata to update the IP.

My new /etc/ddclient.conf:
protocol=noip
use=web, web=http://169.254.169.254/latest/meta-data/public-ipv4
server=dynupdate.no-ip.com
login=<mylogin>
password='mypassword'
myhostname.no-ip.org

The only thing changed in my config is this:
web=http://169.254.169.254/latest/meta-data/public-ipv4

Testing time:
service ddclient stop

ddclient 
here...<mylogin> --> <REDACTED>
SUCCESS:  updating myhostname.no-ip.org: good: IP address set to <my-instance-public-ip>

service ddclient start