Monthly Archives: January 2015

perl programming

Selfmade dyndns

Dyn.com stopped providing free dyndns hosting some time ago. It were sad news.
However most necessary functionality can be implemented in 70 lines of code.
To dynamically update dns records we must find a way to:

  1. get current ip
  2. update DNS record
  3. schedule script for execution

1. Getting current ip address

Many ISP use NAT for security and money saving reasons. Also NAS used in routers. So, to get your IP address you need to ask your IP address from service located outside your network.
For example internet.yandex.ru web page ask resource http://ipv4.internet.yandex.ru/api/v0/ip to determine IP address. So, let’s use it.

2. Updating DNS record

Yandex provide API for DNS records management for domains parked in yandex. API reference should be located here but link is currently broken :-(. UPD: API reference.
In two words you should send POST request with token in header and data in request’s body to https://pddimp.yandex.ru/api2/admin/dns/edit url.
It should looks like following snippet:

3. Scheduling dns records updating

Use the cron, Luke :-) I mean that adding following line to cronjobs would be a simplies way to schedule updating of our dns records:

That’s all. Complete script on github.