When provisioning new Ubuntu Precise (12.04) servers, the hostname they're getting seems to be generated from the DNS search path, not a reverse lookup on the hostname.

Take the following configuration

BIND is configured with the hostname, and reverse name

Normal zone $TTL 600 $ORIGIN srv.local.net.

@ IN SOA ns0.local.net.  hostmaster.local.net. (
        600 )

@               IN      NS      ns0.local.net.
@               IN      MX      5   mail.local.net.

my-new-server           IN      A

And reverse @ IN SOA ns0.local.net. hostmaster.local.net. ( 2014082101 10800 3600 604800 600 )

@ IN NS ns0.local.net.

$ORIGIN 32.10.in-addr.arpa.

30.2  IN  PTR my-new-server.srv.local.net.

Then DHCPD is configured to hand out static leases based on mac addresses like so

subnet netmask {
    option subnet-mask;
    option routers;
    option domain-name-servers;
    option domain-name "util.of1.local.net of1.local.net srv.local.net";

    site-option-space "pxelinux";
    option pxelinux.magic f1:00:74:7e;
    if exists dhcp-parameter-request-list {
        option dhcp-parameter-request-list = concat(option dhcp-parameter-request-list,d0,d1,d2,d3);

    group {

        option pxelinux.configfile "pxelinux.cfg/pxeboot";

        host my-new-server {
            fixed-address my-new-server.srv.local.net;
            hardware ethernet aa:aa:aa:bb:bb:bb;

So the hostname should be my-new-server.srv.local.net, however when building a Ubuntu 12.04 node, the hostname ends up as my-new-server.util.of1.local.net

When building Lucid (10.04) hosts, the hostname will be correct, it's only on Precise/12.04 nodes we have the problem.

Doing a normal and reverse lookup on the host and IP returns the correct result

Sams-MacBook-Pro:~ sam$ host my-new-server
my-new-server.srv.local.net has address
Sams-MacBook-Pro:~ sam$ host my-new-server.srv.local.net
my-new-server.srv.local.net has address
Sams-MacBook-Pro:~ sam$ host domain name pointer my-new-server.srv.local.net.

The contents of the hosts file is incorrect too       localhost       my-new-server.util.of1.local.net of1.local.net srv.local.net       my-new-server

So it looks like when it creates the hosts file, it puts the entire contents of the DNS search path into the local address so the FQDN according to the server is the short hostname as defined, then the first domain in the search path.

Is there a way to get around this behaviour, or fix this so it gets the hostname correctly? It's picking up the first part of the hostname, then the rest is wrong.


Fix it in your /etc/hosts file, that's where it is wrong. Names in the hosts file override what is in DNS. As to where it picked up util.of1.local.net during the install, it's right there in your DHCP config:

option domain-name "util.of1.local.net of1.local.net srv.local.net";

You can see it stuck that in verbatim into the /etc/hosts file, spaces and all...

Keep in mind the domain-name option by definition must only contain one domain name in it, the default domain. But here's where things get complicated. On older Linux platforms, as witness here, it would take the string in the domain-name option and blindly stick it into places, like /etc/hosts, and it also puts it in /etc/resolv.conf for the search parameter which effectively gave you a search list set. The proper way to convey this today is to use the domain-search option, e.g.,

option domain-search "util.of1.local.net","of1.local.net","srv.local.net";

Unfortunately, that will be ignored by the older 12.04 release and won't get you a search list set.

So I think you're stuck with just fixing up what's in /etc/hosts after every install as that is a one-time touch point.

And you probably know this, but the latest Ubuntu LTS release is 14.04.1 as of this writing. There are a ton of bug fixes in that LTS release compared to 12.04, you really should be using 14.04.1 if at all possible. You can configure the DHCP client (in /etc/dhcp/dhclient.conf) to ask for the domain-search parameter and do things proper.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.