How to: Enable dynamic DNS updates to a Microsoft DNS Server using an Ubuntu client workstation

How to: Enable dynamic DNS updates to a Microsoft DNS Server using an Ubuntu client workstation

To my surprise it seems that the beauty of Windows being able to dynamically update corporate DNS servers is something that only exists on Windows client machines (at least since 2000 I guess). Apparently if you are using an Ubuntu server that has DHCP, said server can do the updates to the DNS server and issue resolved! () But if you are in the market for a solution that say… works on Windows Azure which does not allow you to get your own DHCP server then you need another option.

I wasn’t able to find any solution that provided an automated solution specially for a dynamically assigned IP. In the case of a static IP address I recommend you simply set the record on your DNS server and call it a day. In the case you are still in the camp of I need a solution to dynamically update my DNS server because my computer uses dynamic IPs then keep reading.

NsUpdate is a utility used to update DNS servers by passing them instructions. You can leverage this in a script to update your Windows DNS server but it involves having an unsecure DNS zone and some scripting. This works in my scenario as my client computers are all in a virtual network inside Windows Azure so I hope nobody decides messing with my DNS records.

First, set your DNS server to allow unsecure updates.

Then, create a script and save it in /etc/network/if-up.d. This script is called as a hook from network manager every time an interface goes up. It receives one parameter: the name of the interface (i.e. eth0 or wlan0). I named my script 99updatedns:



_HOST=$(hostname -f)

_IP=$(ifconfig $_INTERFACE | grep inet | grep -v inet6 | cut -d “:” -f 2 | cut -d ” ” -f 1)


nsupdate << EOF



update delete $_HOST A

update add $_HOST 86400 A $_IP




If this doesn’t work you could hardcode the Interface and run this through a cron job every so often…

Another option is doing the DNS updates via the DHCP Client:


The client now has some very limited support for doing DNS updates when

a lease is acquired. This is prototypical, and probably doesn’t do

what you want. It also only works if you happen to have control over

your DNS server, which isn’t very likely.


Note that everything in this section is true whether you are using

DHCPv4 or DHCPv6. The exact same syntax is used for both.


To make it work, you have to declare a key and zone as in the DHCP

server (see dhcpd.conf(5) for details). You also need to configure

the fqdn option on the client, as follows:


send fqdn.fqdn “”;

send fqdn.encoded on;

send fqdn.server-update off;

also request fqdn, dhcp6.fqdn;


The fqdn.fqdn option MUST be a fully-qualified domain name. You MUST

define a zone statement for the zone to be updated. The fqdn.encoded

option may need to be set to on or off, depending on the DHCP server

you are using.


The do-forward-updates statement


do-forward-updates [ flag ] ;


If you want to do DNS updates in the DHCP client script (see dhclient-

script(8)) rather than having the DHCP client do the update directly

(for example, if you want to use SIG(0) authentication, which is not

supported directly by the DHCP client, you can instruct the client not

to do the update using the do-forward-updates statement. Flag should

be true if you want the DHCP client to do the update, and false if you

don’t want the DHCP client to do the update. By default, the DHCP

client will do the DNS update.

Enhanced by Zemanta

You may also like...

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: