4

Preface

I'm building a virtualization environment with Ubuntu 14.04 and LXC. I don't want to write my own template since the upgrade from 12.04 to 14.04 has shown that backwards compatibility is not guaranteed.

Therefore I'm deploying my virtual machines via lxc-create, using the default Ubuntu template. The DNS for the servers is provided by Amazon Route 53, so no local DNS server is needed.

I also use Puppet to configure my servers, so I want to keep the manual effort on the deployment minimal.

Now, the default Ubuntu template assigns IP addresses via DHCP. Therefore, I need a local DHCP server to assign IP addresses to the nodes, so I can SSH into them and get Puppet running. Since Puppet requires a proper DNS setup, assigning temporary IP addresses is not an option, the client needs to get the right hostname and IP address from the start.

Question

What DHCP server do I use and how do I get it to assign the IP address based only on the host-name DHCP option by performing a DNS lookup on that very host name?

What I've tried

I tried to make it work using the ISC DHCP server, however, the manual clearly states:

Please be aware that only the dhcp-client-identifier option and the hardware address can be used to match a host declaration, or the host-identifier option parameter for DHCPv6 servers. For example, it is not possible to match a host declaration to a host-name option. This is because the host-name option cannot be guaranteed to be unique for any given client, whereas both the hardware address and dhcp-client-identifier option are at least theoretically guaranteed to be unique to a given client.

I also tried to create a class that matches the hostname like this:

class "my-client-name" {
    match if option host-name = "my-client-name";
    fixed-address my-client-name.my-domain.com;
}

Unfortunately the fixed-address option is not allowed in class statements. I can replace it with a 1-size pool, which works as expected:

subnet 10.103.0.0 netmask 255.255.0.0 {
    option routers 10.103.1.1;

    class "my-client-name" {
        match if option host-name = "my-client-name";
    }
    pool {
        allow members of "my-client-name";
        range 10.103.1.2 10.103.1.2;
    }
}

However, this would require me to administer the IP addresses in two places (Amazon Route53 and the DHCP server), which I would prefer not to do.

About security

Since this is only used in the bootstrapping phase on an internal network and is then replaced by a static network configuration by Puppet, this shouldn't be an issue from a security standpoint. I am, however, aware that the virtual machine bootstraps with "ubuntu:ubuntu" credentials, which I intend to fix once this is running.

migrated from superuser.com Jun 1 '14 at 17:15

This question came from our site for computer enthusiasts and power users.

2

Hopefully, you can control the hardware MAC addresses of your virtual ethernet interfaces.

In that case, I had a similar problem, and ISC bind was equally uncooperating with my configuration efforts. The best solution, which I am still using for years reliably, is to edit the leases file so that desired IP addresses get assigned to corresponding hardware MAC.

First, you just start the clients to populate the leases file. Then stop the clients and bind, then edit the leases file.

  • Unfortunately the ubuntu LXC template generates random MAC addresses and the virtual machines are being added over time. I could of course create the machine, then create an entry using the generated MAC address, but I'd like to keep the administrative overhead as small as possible. – Janos Pasztor Jun 1 '14 at 15:30
0

As a friend pointed out, I could use Puppet to replace the automatically generated MAC address in the LXC configuration file. This would allow me to use the fixed-address directive with the DNS name.

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.