DHCP

Purpose
This HOWTO is intended to describe how to get a Gentoo box configured as a DHCP server.

Scope
This HOWTO describes how to setup the DHCP server on Gentoo, but does not cover how to setup the client machines. This HOWTO assumes Gentoo 2005.1, but is likely to work with other versions.

Acronyms

 * DHCP : Dynamic Host Configuration Protocol.
 * NIC : Network Interface Card, commonly an Ethernet ISA/PCI card.
 * DNS : Domain Name Service

Requirements
For a DHCP server you will need to emerge dhcp:

Configuration
A freshly emerged dhcp will contain a sample configuration file (/etc/dhcp/dhcpd.conf.sample). This file can be copied to /etc/dhcp/dhcpd.conf and used as the basis of the configuration.

The example shown below is typical for a small network. It contains a definition for the subnet, plus the hosts you want to assign a specific details such as IP address.

This configuration file is described below: Global organisation-wide domain name.
 * domain-name

Global organisation-wide domain name servers, comma separated.
 * domain-name-servers

The default gateway address.
 * routers

none: This tells the DHCP server not to update DNS
 * ddns-update-style

The MAC address of the clients NIC.
 * hardware ethernet

A DHCP server can actually run with other DHCP servers on the subnet. But if you want this one to be the one that everyone should look for in case of address collisions, then add authoritative to part of your config file, preferably the first line.
 * authoritative

If setting up your DHCP server to accept DHCP requests for clients booting over the network, add those two entries somewhere (one per line) to your config. Likely you'll need more than just those.
 * allow booting and allow bootp

If you want your DHCP server to send messages to a system logger other than the local machine, use this setting here. You'll have to setup your system logger (running on the ip address specified) to listen to remote logging.
 * option log-servers 

Which IP you want your NETBIOS to be provided or broadcast to all Windows Client. Windows client will refer to this server for NETBIOS name resolve.
 * netbios-name-servers 

What type of NETBIOS Server is this?
 * option netbios-node-type 

:

1 B-node: Broadcast - no WINS

2 P-node: Peer - WINS only

4 M-node: Mixed - broadcast, then WINS

8 H-node: Hybrid - WINS, then broadcast

For lots more options and explanations, see man dhcpd.conf and man dhcp-options

Starting the server
DHCP DHCP-сервер

Setup BIND
We need to setup bind to allow dynamic updates.

First add a key. I'll call it key "dhcpupdate" but it can be anything

dnssec-keygen -a hmac-md5 -b 128 -n USER dhcpupdate

This will output 2 files that begin with Kdhcpupdate rename the .key file to something like dhcpupdate.key and move it to the /etc directory

See http://www.semicomplete.com/articles/dynamic-dns-with-dhcp/

Dynamically addressed hosts can be configured to supply their hostname to DHCPd, so that DHCPd can register their name with a nameserver. To do so, dhcpd.conf requires the logic to update the server with nsupdate, a key for authentication against BIND, a zone section for each domain or subdomain to be updated, and a few configuration settings.

After you restart DHCP, an configure BIND to accept dynamic updates from this machine, you can then ping DHCP-addressed hosts by their hostname.


 * http://roy.marples.name/projects/dhcpcd/