DHCP Server Configuration:
Dynamic Host Configuration Protocol (DHCP) automatically assigns IP addresses
and other network configuration information (subnetmask, broadcast address, etc)
to computers on a network.
A client configured for DHCP will send out a broadcast request to the DHCP
server requesting an address.
The DHCP server will then issue a "lease" and assign it to that client.
The time period of a valid lease can be specified on the server.
DHCP reduces the amount of time required to configure clients and allows
one to move a computer to various networks and be configured with the
appropriate IP address, gateway and subnet mask. For ISP's it conserves
the limited number of IP addresses it may use.
DHCP servers may assign a "static" IP address to specified hardware.
Microsoft NetBios information is often included in the network information
sent by the DHCP server.
DHCP assignment:
- Lease Request:
Client broadcasts request to DHCP server with a source address of 0.0.0.0
and a destination address of 255.255.255.255.
The request includes the MAC address which is used to direct the reply.
- IP lease offer: DHCP server replies with an IP address, subnet mask,
network gateway, name of the domain,
name servers, duration of the lease and the IP address of the DHCP server.
- Lease Selection: Client recieves offer and broadcasts to al DHCP servers
that will accept given offer so that other DHCP server need not make an offer.
- The DHCP server then sends an ack to the client. The client is configured to use TCP/IP.
- Lease Renewal: When half of the lease time has expired, the client will
issue a new request to the DHCP server.
DHCP server installation:
- Red Hat/CentOS/Fedora: rpm -ivh dhcp-x.xxx.elx.i386.rpm
- Ubuntu/Debian 8: apt-get install dhcp3-server
( Later releases of Ubuntu (11.04) used the busybox release known as udhcpd and the configuration is NOT shown here)
Starting DHCP server:
- Red Hat/CentOS/Fedora: service dhcpd start
(or /etc/rc.d/init.d/dhcpd start for Red Hat, Fedora and CentOS Linux distributions)
- Ubuntu/Debian: /etc/init.d/networking restart
Sample DHCP server config file: (DHCP v3.0.1)
- Red Hat/CentOS/Fedora: /etc/dhcpd.conf
(See /usr/share/doc/dhcp-3.X/dhcp.conf.sample)
[Potential Pitfall]: Its /etc/dhcpd.conf NOT /etc/dhcp.conf !!
- Ubuntu/Debian: /etc/default/dhcp3-server
01 | ddns-update-style interim; |
04 | subnet 192.168.1.0 netmask 255.255.255.0 { |
06 | range 192.168.1.128 192.168.1.254; |
07 | option subnet-mask 255.255.255.0; |
08 | option broadcast-address 192.168.1.255; |
09 | option routers 192.168.1.1; |
10 | option domain-name "your-domain.org" ; |
11 | option domain-name-servers 40.175.42.254, 40.175.42.253; |
12 | option netbios-name-servers 192.168.1.100; |
18 | default-lease- time 21600; |
21 | option time -offset -18000; |
31 | next-server ns2.your-domain.com; |
32 | hardware ethernet 00:02:c3:d0:e5:83; |
33 | fixed-address 40.175.42.254; |
39 | host laser-printer-lex1 { |
40 | hardware ethernet 08:00:2b:4c:a3:82; |
41 | fixed-address 192.168.1.120; |
Test configuration file for errors with the following command:
/etc/rc.d/init.d/dhcpd configtest
(Other distributions may use:
/usr/sbin/dhcpd -f)
Note: The MAC addresses for the static address name server (ns2.your-domain.com), can be obtained with either of the two commands:
- /sbin/ip addr show:
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:02:c3:d0:e5:83 brd ff:ff:ff:ff:ff:ff
inet 192.168.42.214/24 brd 192.168.42.255 scope global dynamic eth0
valid_lft 82646sec preferred_lft 82646sec
inet6 f080::477:3e0e:d5fd:803a/64 scope link
valid_lft forever preferred_lft forever
OR
- /sbin/ifconfig:
eth0 Link encap:Ethernet HWaddr 00:02:C3:D0:E5:83
inet addr:192.168.42.214 Bcast:192.168.42.255 Mask:255.255.255.0
inet6 addr: fe80::202:b3ff:fef0:e484/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:4070 errors:0 dropped:0 overruns:0 frame:0
TX packets:3878 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:3406445 (3.2 MiB) TX bytes:439612 (429.3 KiB)
When dhcpd is running it will generate entries in the file: /var/lib/dhcp/dhcpd.leases
lease 192.168.1.128 {
starts 2 2004/12/01 20:07:05;
ends 3 2004/12/02 08:07:05;
hardware ethernet 00:00:e8:4a:2c:5c;
uid 01:00:00:e8:4c:5d:31;
client-hostname "Node1";
}
Options:
- ddns-update-style:
- interim: allows your DHCP server to update a DNS server whenever it hands out a lease. Allows your DNS server to know which IP addresses are associated with which computers in your network. Requires that your DNS server support DDNS (Dynamic DNS).
- none: to disable dynamic DNS updates or DNS is not supporting DDNS.
- ad-hoc: been deprecated and shouldn't be used
- Default options (Red Hat/CentOS/Fedora) are set in /etc/sysconfig/dhcpd
LANs separated by routers: In order to have your DHCP
broadcast pass through a router on the the next network, one must
configure the router to allow DHCP relay. (Cisco: ip-helper address, Juniper: dhcp-relay)
The local lan subnet{ } configuration must come before the configuration directives of the remote LANs.
Look for errors in /var/log/messages
See dhcp-options man page below.
DHCP man pages:
- Client: dhclient: DHCP client daemon (replaces dhcpcd)
- Server: dhcpd: Dynamic Host Configuration Protocol Server daemon
- dhcrelay: bootp relay agent. One DHCP server to service multiple network segments.
- omshell: OMAPI Command Shell - interactive way to connect to, query, and possibly change, the ISC DHCP Server's state via OMAPI
One can make the changes while the server is running.
DHCP RFC's: RFC2131, RFC1541 (obsolete), RFC2132
Note: DHCP client will overwrite your /etc/resolv.conf file with
new information recieved from the DHCP server.

Books:
 |
"Ubuntu Unleashed 2017 edition:"
Covering 16.10 and 17.04, 17.10 (12th Edition)
by Matthew Helmke, Andrew Hudson and Paul Hudson
Sams Publishing, ISBN# 0134511182
|
|
 |
"Ubuntu Unleashed 2013 edition:"
Covering 12.10 and 13.04 (8th Edition)
by Matthew Helmke, Andrew Hudson and Paul Hudson
Sams Publishing, ISBN# 0672336243
(Dec 15, 2012)
|
|
 |
"Ubuntu Unleashed 2012 edition:"
Covering 11.10 and 12.04 (7th Edition)
by Matthew Helmke, Andrew Hudson and Paul Hudson
Sams Publishing, ISBN# 0672335786
(Jan 16, 2012)
|
|
 |
"Red Hat Enterprise Linux 7: Desktops and Administration"
by Richard Petersen
Surfing Turtle Press, ISBN# 1936280620
(Jan 13, 2017)
|
|
 |
"Fedora 18 Desktop Handbook"
by Richard Petersen
Surfing Turtle Press, ISBN# 1936280639
(Mar 6, 2013)
|
|
 |
"Fedora 18 Networking and Servers"
by Richard Petersen
Surfing Turtle Press, ISBN# 1936280698
(March 29, 2013)
|
|
 |
"Fedora 14 Desktop Handbook"
by Richard Petersen
Surfing Turtle Press, ISBN# 1936280167
(Nov 30, 2010)
|
|
 |
"Fedora 14 Administration and Security"
by Richard Petersen
Surfing Turtle Press, ISBN# 1936280221
(Jan 6, 2011)
|
|
 |
"Fedora 14 Networking and Servers"
by Richard Petersen
Surfing Turtle Press, ISBN# 1936280191
(Dec 26, 2010)
|
|
 |
"Practical Guide to Ubuntu Linux (Versions 8.10 and 8.04)"
by Mark Sobell
Prentice Hall PTR, ISBN# 0137003889
2 edition (January 9, 2009)
|
|
 |
"Fedora 10 and Red Hat Enterprise Linux Bible"
by Christopher Negus
Wiley, ISBN# 0470413395
|
|
 |
"Red Hat Fedora 6 and Enterprise Linux Bible"
by Christopher Negus
Sams, ISBN# 047008278X
|
|
 |
"Fedora 7 & Red Hat Enterprise Linux: The Complete Reference"
by Richard Petersen
Sams, ISBN# 0071486429
|
|
 |
"Red Hat Fedora Core 6 Unleashed"
by Paul Hudson, Andrew Hudson
Sams, ISBN# 0672329298
|
|
 |
"Red Hat Linux Fedora 3 Unleashed"
by Bill Ball, Hoyt Duff
Sams, ISBN# 0672327082
|
|