[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 192.168.2.1; # 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 255.255.255.0; # Subnet Mask
option routers 192.168.1.1; # Default Gateway
subnet 192.168.1.0 netmask 255.255.255.0 # Defines the subnet

WINS Support

option netbios-name-servers 192.168.2.1;
option netbios-dd-server 192.168.2.1;
option netbios-node-type 8;
range dynamic-bootp 192.168.1.128 192.168.1.254; # 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 192.168.1.255 # 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;
fixed-address 192.168.1.10;
}

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:

DHCPDARGS=ethN

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.