Recipe 24.3. Setting Up a DHCP Server

 < Day Day Up > 

24.3.1 Problem

You don't want to hassle with configuring name resolution on workstations. They don't need static IP addresses, so you want to set up a DHCP server to take care of them automatically.

24.3.2 Solution

Install and configure dhcp. You can get the source tarball from http://www.isc.org. RPMs and Debian packages are also available; just look for packages named "dhcp." Configure client PCs to point to your dhcp server, and you're done.

24.3.3 Discussion

A dhcp server can feed all network configuration data to the clients. The configuration file is /etc/dhcpd.conf. Here is a sample configuration:

# /etc/dhcpd.conf default-lease-time 259200; max-lease-time 518400;     subnet 192.168.1.0 netmask 255.255.255.0 {    option subnet-mask 255.255.255.0;    option broadcast-address 192.168.1.255;    option routers 192.168.1.1;    option domain-name "test.net";    range 192.168.1.50 192.168.1.100;    option domain-name-servers 152.163.199.56, 198.83.210.28; }

This is pretty straightforward. The lease times are in seconds, so the minimum and maximum in this example are three days and six days. "Option routers" points to your Internet gateway, or the gateway to the subnet. A pool of 50 addresses is made available in the "range." The name servers are either your own private caching server or servers, or the name servers at your ISP.

This example uses private, nonroutable IPv4 (Internet Protocol Version 4) addresses. Here are the private IPv4 address classes, in both dotted-quad and Classless Inter-Domain Routing (CIDR) notation:

10.0.0.0     - 10.255.255.255  (10/8) 172.16.0.0   - 172.31.255.255  (172.16/12) 192.168.0.0  - 192.168.255.255 (192.168/16)

These are for use on private networks, so you'll select your subnet ranges from these. See Section 2.2 of TCP/IP Network Administration, Third Edition, by Craig Hunt (O'Reilly) to learn more about IP addressing.

You've probably heard about IPv6, which is the next generation of IP addressing. IPv6 is not covered in this book; IPv4 is going to be with us for quite a while yet. To learn more about IPv6, start at http://www.iana.org/ipaddress/ip-addresses.htm.

See the next recipe to learn how to configure both Linux and Windows dhcp clients.

24.3.4 See Also

  • dhcp-options(5), dhcpd.conf(5), dhcpd(8)

  • RFC 1918 Address Allocation for Private Internets

  • TCP/IP Network Administration, Third Edition

     < Day Day Up > 


    Linux Cookbook
    Linux Cookbook
    ISBN: 0596006403
    EAN: 2147483647
    Year: 2004
    Pages: 434

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net