How to: Enable proper domain DNS search in Ubuntu when using Windows Azure

How to: Enable proper domain DNS search in Ubuntu when using Windows Azure

So as part of the latest using your own DNS server with Linux machines inside Windows Azure I had a bit of a problem. Even though my corporate DNS server was set up correctly, DNS entries were correct, etc. Ubuntu would just take for ever to resolve the name. The idea is that if you ping myWebServer it would resolve automatically to and then ping the host… but it would take like 30 seconds to finally decide to try the dns-search value I set up at /etc/network/interfaces. I finally realized what was the problem when I opened /etc/resolv.conf. I was suspecting it was trying other domains for search first and then when they timed out mine would get used. Take a look at the file:

# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)




As you can see the Azure guys via DHCP decided to add a dns-search parameter of which comes before my DNS Zone of! So if I wanted to ping MySQLServer it would first try and then Effectively until the first name resolution fails will it resolve the correct server name. You could imagine how this can have an impact! So lesson learned, always use FQDNs, lol. Anyway, there is a way to fix this in case you really like to just type MyServer and be done.

Because this “error” is caused by DHCP for listening to those silly Microsoft guys we need to tell the DHCP client to be smarter than that. To set resolv.conf to what you need it to be regardless of what the DHCP server says you need to edit  /etc/dhcp/dhclient.conf and play with the following:

supersede domain-name “”;

prepend domain-search “”;

So here is how it works:

  • Use Supersede if you want to have a value overwrite whatever the DHCP server sends (if it doesn’t provide the value then it won’t be superseded.
  • Use Prepend if you want to add a value before whatever the DHCP server sends. Remember that if you just wanted to add something you should use /etc/network/interfaces or /etc/resolvconf/resolv.conf.d/ where you can find the base and head files. The base adds entries at the base of /etc/resolv.conf while head… to the top of /etc/resolv.conf.

That’s all, happy domain name resolving! (Don’t forget to have the resolv.conf regenerated you need to run the dhcp client again and the easiest way is executing /etc/init.d/networking restart or service networking restart)

Here is a sample of the changes I mad to the /etc/dhcp/dhclient.conf file with the modifications in bold:

# Configuration file for /sbin/dhclient, which is included in Debian’s

# dhcp3-client package.


# This is a sample configuration file for dhclient. See dhclient.conf’s

# man page for more information about the syntax of this file

# and a more comprehensive list of the parameters understood by

# dhclient.


# Normally, if the DHCP server provides reasonable information and does

# not leave anything out (like the domain name, for example), then

# few changes must be made to this file, if any.



option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;


supersede domain-name “”;

supersede domain-search “”;

supersede search “”;


send host-name “<hostname>”;

#send dhcp-client-identifier 1:0:a0:24:ab:fb:9c;

#send dhcp-lease-time 3600;

#supersede domain-name “”;

#prepend domain-name-servers;

request subnet-mask, broadcast-address, time-offset, routers,

domain-name, domain-name-servers, domain-search, host-name,

netbios-name-servers, netbios-scope, interface-mtu,

rfc3442-classless-static-routes, ntp-servers,

dhcp6.domain-search, dhcp6.fqdn,, dhcp6.sntp-servers;

#require subnet-mask, domain-name-servers;

#timeout 60;

#retry 60;

#reboot 10;

#select-timeout 5;

#initial-interval 2;

#script “/etc/dhcp3/dhclient-script”;

#media “-link0 -link1 -link2”, “link0 link1”;



#alias {

# interface “eth0”;

# fixed-address;

# option subnet-mask;



#lease {

# interface “eth0”;

# fixed-address;

# medium “link0 link1”;

# option host-name “”;

# option subnet-mask;

# option broadcast-address;

# option routers;

# option domain-name-servers;

# renew 2 2000/1/12 00:00:01;

# rebind 2 2000/1/12 00:00:01;

# expire 2 2000/1/12 00:00:01;



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: