Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the hueman domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /var/www/CloudIngenium.com/htdocs/wp-includes/functions.php on line 6114
How to: Enable proper domain DNS search in Ubuntu when using Windows Azure – Knowledge eXchange

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 myWebServer.CloudIngenium.com 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)

# DO NOT EDIT THIS FILE BY HAND — YOUR CHANGES WILL BE OVERWRITTEN

nameserver 10.0.0.1

search ServerName.b3.internal.cloudapp.net AzureNetwork.CloudIngenium.com

As you can see the Azure guys via DHCP decided to add a dns-search parameter of ServerName.b3.internal.cloudapp.net which comes before my DNS Zone of AzureNetwork.CloudIngenium.com! So if I wanted to ping MySQLServer it would first try MySQLServer.ServerName.b3.internal.cloudapp.net and then MySQLServer.AzureNetwork.CloudIngenium.com. 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 “AzureNetwork.CloudIngenium.com”;

prepend domain-search “AzureNetwork.CloudIngenium.com”;

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 “azurenetwork.cloudingenium.com”;

supersede domain-search “azurenetwork.cloudingenium.com”;

supersede search “azurenetwork.cloudingenium.com”;

 

send host-name “<hostname>”;

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

#send dhcp-lease-time 3600;

#supersede domain-name “fugue.com home.vix.com”;

#prepend domain-name-servers 127.0.0.1;

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.name-servers, 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”;

#reject 192.33.137.209;

 

#alias {

# interface “eth0”;

# fixed-address 192.5.5.213;

# option subnet-mask 255.255.255.255;

#}

 

#lease {

# interface “eth0”;

# fixed-address 192.33.137.200;

# medium “link0 link1”;

# option host-name “andare.swiftmedia.com”;

# option subnet-mask 255.255.255.0;

# option broadcast-address 192.33.137.255;

# option routers 192.33.137.250;

# option domain-name-servers 127.0.0.1;

# 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

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

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