DHCP
DHCP, dnsmasq configuration, IP ranges and subnets
Documentation
The dhcp server dnsmasq assign fixed IP addresses out of the 192.168/16 subnet as configured in configuration files. Besides, IP addresses from the range 192.168.255/24 are assigned dynamically. The configured IP addresses are assigned with an infinite lease time while the dynamic ones will get a lease for one day.
There are four directories to configure of persistent and temporary networks:
/etc/hosts.d/ and /etc/ethers.d/ contain two different types of files which bind hostnames to IP addresses and respectively hostnames to MAC addresses. Files with the suffix .tmp are for temporary setup networks while all other files in these directories deal with the persistent networks (like the normal testbed itself). The tmp files are deleted and newly created if necessary every time the register_hostnames script (see below) is running.
The directory /var/lib/ipranges/ contains two subdirectories: free and reserved. Both of them include empty files whose names represents IP prefixes. The ranges in the directory free are not yet assigned while the ranges in reserved directory are used by a network. In addition for all currently configured networks a symlink exist in this directory linking to the IP range assigned to this network where the symlink's filename is the network identifier string.
Finally all informations about nodes for temporarily created networks are stored in /testbed/tftpboot/hostnames/. All files with the suffix .netcfg contain line-by-line tuples of MAC addresses and hostnames. The first part of the filename (before the suffix) identifies the network.
To register all nodes from the persistent and temporary networks specified in the directories and files mentioned above you need to call the script /testbed/bin/register_hostnames. This script generates the tmp files in /etc/hosts.d/ and /etc/ethers.d/ out of the configuration in /testbed/tftpboot/hostnames/ and then creates the both files read by dnsmasq: /etc/hosts and /etc/dnsmasq.ethers. For that reason dnsmasq is reloaded. Finally, all currently unused IP ranges are freed.
Examples
To add new routers to the testbed you must create entries in /etc/hosts.d/testbed and /etc/ethers.d/testbed and call register_hostnames.
To setup a test network (for example with virtual machines) called mynetworkcreate a file in /testbed/tftpboot/hostnames/mynetwork.netcfg containing all MAC addresses and hostnames of your nodes. Again you have to call the register_hostnames script. Once you have shutdown your test network remove the corresponding file from /testbed/tftpboot/hostnames/. The next time the register script is called the IP ranges of your network will be freed.
Configuration files and directories
-
/etc/hosts.d/
Contains files with IP to hostname bindings.
-
/etc/ethers.d/
Contains files with MAC to hostname bindings.
-
/var/lib/ipranges/
Contains subdirectories for free and reserved IP ranges.
-
/testbed/tftpboot/hostnames/
Contains files with MAC addresses and hostnames for temporary networks.
-
/testbed/bin/register_hostnames
Register fixed IP ranges from DHCP for all networks in
/testbed/tftpboot/hostnames/, frees no longer used IP ranges and reloads dnsmasq.
NOTE: If you would like to setup a network of more than 255 nodes you must configure more than one network configuration file in code>/testbed/tftpboot/hostnames/ as every configured network will only get an IP range of 255 addresses.
deprecated (old file system)
Just a quick note to prevent further downtime of the testbed:
All mesh routers mount the same root filesystem over NFS. If interface eth0 is accidentially brought down, the routers hang and require manual reboots. When updating the DHCP client it can happen that the customized file /sbin/dhclient-script is overwritten and the DHCP client is restarted. This leads to the described problem.
So please respect the following rules:
- Do not update the DHCP client, package: dhcp3-client
- If you have to update the package restore the former state of the script
- Do not update the DHCP client, package: dhcp3-client
- 294 reads
- Printer-friendly version