Categories
Networking Routers

OpenWRT and DNS UPDATE

How to set up OpenWRT to update a hostname in your own domain with your current IP via dynamic DNS update.

I’m hosting my domain myself on a dedicated root server, and I wanted my Internet router to automatically update a hostname in my own domain (in a designated dynamic zone) with my current public IP. With OpenWRT this was easily accomplished. I used these instructions as a starting point.

When trying to check whether everything was set up correctly I always got some strange error from the following command:

# ACTION=update INTERFACE=wan /sbin/hotplug-call iface

It turned out that the following statement

config_get ipaddr wan ipaddr

did not return the currently assigned IP address in my case, but just an empty response, so I got the following error message:

could not read rdata
syntax error

(For testing I hooked a spare router with a fresh OpenWRT install with the WAN port into my LAN, and configured the WAN interface to receive its IP address via DHCP from out of the LAN. In “production” the WAN interface receives its IP via PPPoE.)

Some friendly guy in the OpenWRT forum suggested I try the following instead:

. /lib/functions/network.sh
network_get_ipaddr ipaddr wan

And indeed this worked well.

By Ralf Bergs

Geek, computer guy, licensed and certified electrical and computer engineer, husband, best daddy.

One reply on “OpenWRT and DNS UPDATE”

I had a strange problem with dynamic DNS updates on a router I flashed with OpenWRT’s unstable distro “Barrier Breaker” — instead of the DNS record be updated I just got an error message, but it was totally non-obvious what went wrong:
Communication with server failed: operation canceled

I used the debug -d option to nsupdate, and this gave me the clue I needed: Strangely nsupdate tried to contact my DNS server via its IPv6 address, even though my network and Internet provider aren’t yet IPv6-capable:
Sending update to 2a01:4f8:xx:xxxx::x#53
Outgoing update query:

On Attitude Adjustment this hasn’t been a problem. My “hacky” solution (or rather “work-around”) to this was to simply use the IPv4 address instead of the hostname to force use of IPv4 communications.

Leave a Reply

Your email address will not be published. Required fields are marked *