[How To] Install and Configure DHCP Server

dhcpd server is designed for automatic and dynamic assignment of:

  • IP-addresses
  • wins
  • dns
  • default gateway
  • time server
  • subnet mask

Dhcp does not require a server on each subnet, it can work through the relay agent. DHCP protocol uses 67 (messages from client to server) and 68 (from server to client) UDP ports. Client sends broadcast packets to get the IP address.

Installing Dhcpd

yum install dhcpd (CentOs 5)

Setting up dhcpd

The main configuration file is dhcpd.conf, depending on the choice of Linux distribution can be located in /etc/dhcpd.conf, /etc/dhcp/dhcpd.con, /etc/dhcp3/dhcpd.conf.

In CentOs5 It is located in /etc/dhcpd.conf It looks like:

# cat /etc/dhcpd.conf
option ntp-servers; # Time Server
option domain-name-servers192.168.2.1; # DNS server
option domain-name "example.com"; # domain name
option nis-domain " example.com"; # Nis domain
option subnet-mask; # Subnet Mask
option routers; # Default Gateway
subnet netmask # Defines the subnet

WINS Support

option netbios-name-servers;
option netbios-dd-server;
option netbios-node-type 8;
range dynamic-bootp; # Range of IP addresses that will be provided to clients
default-lease-time 21600; # lease time in seconds
max-lease-time 43200; # maximum lease time
option broadcast-adress # You can also define a broadcast address
option ip-forwarding on; # and enable IP-Forwarding

Static address can be assigned

host station1 {
hardware ethernet 12:34:56:78:AB:CD;

Dhcpd.leases file is used to record the selected address, and dhcpd.leases ~ file to overwrite the temporary file, i.e. first created the file dhcpd.leases ~, which logs all entries at the moment, and then the file is renamed dhcpd.leases. May be located in /var/lib/dhcpd/dhcpd.leases.

If you have multiple network interfaces and to make the server run dhcpd on one of them, then the file vi /etc/sysconfig/dhcpd needs to be written as follows:


For details see man dhcpd.conf.

Source: http://plutonit.ru/view_post.php?id=124

[External Links]

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.