Configuration Database Project

Home Computing DAQ E-mail Notes Meetings Subsystems Search

        Generating dhcpd.conf from the database

Introduction

A DHCP server provides the clients with IP addresses and boot images. In the LHCb online system, the DHCP servers will be located in Control PCs and will configure the subfarm controllers, the subfarm nodes and the credit cards using the information stored in the Configuration Database. The first section explains how a DHCP server finds the host names it had to handle with. The second section focuses on getting the right boot images for the different hosts.

Finding the hosts of a DHCP server

In the dhcpd.conf, we have to specify the hosts which will be configured by the current DHCP server.

To find all the hosts that a DHCP server needs to handle with, we generate the destination table of the DHCP server. To see how this table is generated, please see Generating Routing Tables

Once this table is generated, we select all the different host IDs. With these host IDs, we can select the IP and ethernet addresses, the subnet Mask and also the IP name from the IP_ethernet table.

So at the end of this step we have all the entries for host, hardware ethernet and fixed-addresses.

Finding the different subnet IDs

However it's not sufficient. Indeed we also have to specify to which subnet ID (or address) these hosts belong to.

To do so we compute the subnet IDs using the subnet Mask and the IP address:

Let's take the following example :

IP address : 137.192.25.15

Subnet Mask : 255.255.255.0

1. Convert the IP address and the Subnet Mask to binary formats:

IP address :        100001001.11000000.00011001.00001111

Subnet Mask:     11111111. 11111111.11111111.000000000

We consider these two numbers as 2 vectors.

2. Multiply the coordinates of the 2 (similar as the operator .* in Matlab)

So the subnet ID: 100001001.11000000.00011001.00000000

3. Convert it into decimal format : 137.192.25.0

Then we group the hosts by subnet IDs as follows:

subnet 137.192.25.0 netmask 255.255.255.0 {

group {
host eposly15 {
hardware ethernet 00:80:a2:00:90:c7; fixed-address 137.192.25.12;
 }

host ...

}

 }

subnet ....

Providing the boot image location

Next step is to find the boot image location which is required by the hosts to boot as they are diskless.

This information is stored in the devicetype_booting table. Indeed this kind of information depends on the type of the device. The table has the following attributes:

                                                                Fig.1 devicetype_booting table

So we first find the type of the host using the device table and then we select the boot_image location which corresponds to the filename attribute in a DHCP config. file

Implementation

To generate the dhcpd.conf, we have used the following method:

 

                                                  

The result of the queries are printed as an XML file which is then converted to a text file using a xslt template.

All these steps are performed using a Perl script. To run this script, you need to provide the name of the DHCP server you want to configure.

Regarding the perl modules,  XSLT and DBI are required.

Option handling

Normally in a dhcpd.conf, there are some options you have to add depending on the network such as

ddns-update-style ad-hoc; deny unknown-clients ; use-host-decl-names on ...

To solve that problem, the user just has to add manually the options he needs. It will add the following line in the XML file:

<options><option> ddns-update-style ad-hoc </option></options>

 

Package to download only for Linux (.zip)

Install everything on the same directory

To make it run :

1) perl test.pl

2) ./test <name of the dhcp server>

      3) dhcpd.conf has been generated. Modify the options if needed