Red Hat Fedora Linux 3 Bible

Assuming you have already set up the physical connections between your DHCP server and the client computers on your network (presumably an Ethernet LAN), the minimum tools you need to get the DHCP server working are:

After the DHCP server is running, it broadcasts its availability as a DHCP server to the LAN. A client simply boots up (with an Ethernet network interface turned on and DHCP identified as its method of getting network addresses), and the information it needs to get up and running on the network is fed to it from the server.

Note 

The dhcpd.conf file can serve a wide range of configuration information to DHCP clients. To see the full set of options and parameters you can set in that file, refer to the dhcp-options and dhcpd.conf man pages (type man dhcp-options).

Opening your firewall for DHCP

The firewall on your DHCP server must be configured to allow access to UDP ports 67 and 68. If you are using iptables (and you did not open ports 67 and 68 during installation), you can add a new rule to iptables and then save the changes permanently. Type the following as root user:

# iptables -I INPUT -i eth0 -p udp --sport 67:68 --dport 67:68 -j ACCEPT

In this example, requests are allowed to and from ports 67 and 68 on the eth0 interface (which is your first Ethernet card). If your DHCP server is also a routing firewall for your network, you want to make sure that you are only offering DHCP services to your LAN and not to the Internet. (You need to figure out if eth0, eth1, or some other card is connected to your LAN.)

If the rule was accepted (type iptables -L to make sure), you can save your entire firewall configuration so that the new rule is included permanently. To do that, type the following (as root user):

# iptables-save > /etc/sysconfig/iptables

This updates your /etc/sysconfig/iptables file so that all the current rules (including the one you just added) are included the next time iptables is restarted.

Configuring the dhcpd.conf file

Suppose you have a single pool of IP addresses that you want to distribute to a set of computers that are all on the same subnetwork. In other words, all the computers are connected to one switch or cluster of switches with no routing between the devices. Here is an example of a simple dhcpd.conf file:

ddns-update-style interim; ignore client-updates; subnet 10.0.0.0 netmask 255.0.0.0 { option routers 10.0.0.1; option domain-name-servers 10.0.0.1; option subnet-mask 255.0.0.0; option domain-name "handsonhistory.com"; range dynamic-bootp 10.0.0.150 10.0.0.225; default-lease-time 21600; max-lease-time 43200; # Set name server to appear at a fixed address host ns { next-server ns1.handsonhistory.com; hardware ethernet 00:D0:B3:79:B5:35; fixed-address 10.0.0.1; } }

In this example, this DHCP server is providing IP addresses for client computers on a small LAN. The first two lines tell the DHCP server not to update DNS records for the local domain based on the IP addresses it assigns.

The DHCP server is serving a single LAN: 10.0.0.0 network with a 255.0.0.0 netmask. Other data in this file define what information the DHCP server will hand out to clients on this LAN.

A single server at address 10.0.0.1 is used as the router (or gateway) and DNS server for the LAN. To ensure that this server always gets the fixed address of 10.0.0.1, a host entry is set to the hardware address (00:D0:B3:79:B5:35) for the Ethernet card on the host named ns.

The pool of addresses handed out by this DHCP server is 10.0.0.150 to 10.0.0.225, as set by the range dynamic-bootp line. (Using dynamic-bootp allows bootp and dhcp clients to get addresses.) Along with the IP address that each client is assigned, the client is also given the associated subnet-mask and domain name.

The IP addresses that the DHCP server hands out are leased to each client for a particular time. The default-lease-time (set to 21,600 seconds here, or 6 hours) is the time assigned if the client doesn’t request a particular lease period. The max-lease-time (43,200 seconds here, or 12 hours) is the highest amount of time the server will assign, if the client requests it. Clients can renew leases, so they don't have to lose the IP address while they are still using it.

Expanding the dhcpd.conf file

As I noted earlier, this is a very simple example that works well for a single network of client computers. Below are some examples of ways that you can expand your dhcpd.conf file.

In the previous example, the boot file used by the diskless workstation from the DHCP server is located at /dwboot/maple.nb. The hardware ethernet value identifies the address of the Ethernet card on the client. The client’s IP address is set to 10.0.0.150. All of those lines are contained within a host definition, where the host name is defined as maple. (See the Thin Clients heading in Table 23-2 for other options that may be useful for configuring thin clients.)

Adding options

There are dozens of options you can use in the /etc/dhcpd.conf file to pass information from the DHCP server to DHCP clients. Table 23-1 describes data types you can use for different options. Table 23-2 describes options that are available.

Table 23-1: Data Types

Data Types

Description

ip-address

Enter ip-address as either an IP address number (11.111.111.11) or a fully qualified domain name (comp1.handsonhistory.com). To use a domain name, the name must be resolvable to an IP address number.

int32, int16, int8, uint32, uint16, uint8

Used to represent signed and unsigned 32-, 16-, and 8-bit integers.

"string"

Enter a string of characters, surrounded by double quotes.

Boolean

Enter true or false when a boolean value is required.

data-string

Enter a string of characters in quotes ("client1") or a hexadecimal series of octets (00:04:5A:4F:8E:47).

Options contain values that are passed from the DHCP server to clients. Although Table 23-2 lists valid options, the client computer will not be able to use every value you could potentially pass to it. In other words, not all options are appropriate in all cases.

Table 23-2 is divided into the following categories:

Table 23-2: DHCP Options

Options

Descriptions

Names, Addresses, and Time

option host-name string;

Indicates the name that the client computer can use to identify itself. It can either be a simple host name (for example, pine) or a fully qualified domain name (for example, pine.handsonhistory.com). You may use this in a host declaration, where a host computer is identified by an Ethernet address.

option domain-name string

Identifies the default domain name the client should use to resolve DNS host names.

option subnet-mask ip-address;

Associates a subnetwork mask with an IP address. For example, option 255.0.0.0 10.0.0.1;.

option time-offset int32;

Indicates the offset (in seconds) from the Universal Time Coordinate (UTC). For example, a six-hour UTC offset is set as follows: option time-offset 21600;.

Servers and Routers

option routers ip-address [, ip- address... ];

Lists, in order of preference, one or more routers connected to the local subnetwork. The client may refer to this value as the gateway.

option domain-name-servers ip- address [, ip-address... ];

Lists one or more Domain Name System (DNS) servers that the client can use to resolve names into IP addresses. List servers in the order in which they should be tried.

option time-servers ip-address [, ip- address... ];

Lists, in order of preference, one or more time servers that can be used by the DHCP client.

option ien116-name-servers ip-address [, ip-address... ];

Lists, in order of preference, one or more IEN 116 name servers that can be used by the client. (IEN 116 name servers predate modern DNS servers and are considered obsolete.)

option log-servers ip-address [, ip- address... ];

Lists one or more MIT-LCS UDP log servers. List servers in the order in which they should be tried.

option cookie-servers ip-address [, ip- address... ];

Lists one or more Quote of the Day (cookie) servers (see RFC 865). List servers in the order in which they should be tried.

option lpr-servers ip-address [, ip- address... ];

Lists one or more line printer servers that are available. List servers in the order in which they should be tried.

option impress-servers ip-address [, ip- address... ];

Lists one or more Imagen Impress image servers. List servers in the order in which they should be tried.

option resource-location-servers ip- address [, ip-address... ];

Lists one or more Resource Location servers (RFC 887). List servers in the order in which they should be tried.

option nis-domain string;

Indicates the name of the NIS domain, if an NIS server is available to the client.

option nis-servers ip-address [, ip- address... ];

Lists addresses of NIS servers available to the client, in order of preference.

option ntp-servers ip-address [, ip- address... ];

Lists addresses of network time protocol servers, in order of preference.

option netbios-name-servers ip- address [, ip-address...];

Lists the addresses of WINS servers, used for NetBIOS name resolution (for Windows file and print sharing).

option netbios-dd-server ip-address [, ip-address... ];

Lists the addresses of NetBIOS datagram distribution (NBDD) servers, in preference order.

option netbios-node-type uint8;

Contains a number (a single octet) that indicates how NetBIOS names are determined (used with NetBIOS over TCP/IP). Acceptable values include: 1 (broadcast: no WINS), 2 (peer: WINS only), 4 (mixed: broadcast, then WINS), 8 (hybrid: WINS, then broadcast).

option font-servers ip-address [, ip- address... ];

Indicates the location of one or more X Window font servers that can be used by the client, listed in preference order.

option nisplus-domain string;

Indicates the NIS domain name for the NIS+ domain.

option nisplus-servers ip-address [, ip- address... ];

Lists addresses of NIS+ servers available to the client, in order of preference.

option smtp-server ip-address [, ip- address... ];

Lists addresses of SMTP servers available to the client, in order of preference.

option pop-server ip-address [, ip- address... ];

Lists addresses of POP3 servers available to the client, in order of preference.

option nntp-server ip-address [, ip- address... ];

Lists addresses of NNTP servers available to the client, in order of preference.

option www-server ip-address [, ip- address... ];

Lists addresses of WWW servers available to the client, in order of preference.

option finger-server ip-address [, ip- address... ];

Lists addresses of Finger servers available to the client, in order of preference.

option irc-server ip-address [, ip- address... ];

Lists addresses of IRC servers available to the client, in order of preference.

Routing

option ip-forwarding flag;

Indicates whether the client should allow (1) or not allow (0) IP forwarding. This would be allowed if the client were acting as a router.

option non-local-source-routing flag;

Indicates whether or not the client should allow (1) or disallow (0) datagrams with nonlocal source routes to be forwarded.

option static-routes ip-address ip- address [, ip-address ip-address... ];

Specifies static routes that the client should use to reach specific hosts. (List multiple routes to the same location in descending priority order.)

option router-discovery flag;

Indicates whether the client should try to discover routers (1) or not (0) using the router discovery mechanism.

option router-solicitation-address ip- address;

Indicates an address the client should use to transmit router solicitation requests.

Thin Clients

option boot-size uint16;

Indicates the size of the default boot image (in 512-octet blocks) that the client computer uses to boot.

option merit-dump string;

Indicates where the core image should be dumped if the client crashes.

option swap-server ip-address;

Indicates where the client computer’s swap server is located.

option root-path string;

Indicates the location (path name) of the root disk used by the client.

option tftp-server-name string;

Indicates the name of the TFTP server that the client should use to transfer the boot image. Used more often with DHCP clients than with BOOTP clients.

option bootfile-name string;

Indicates the location of the bootstrap file that is used to boot the client. Used more often with DHCP clients than with BOOTP clients.

option x-display-manager ip-address [, ip-address... ];

Indicates the locations of X Window System Display Manager servers that the client can use, in order of preference.

Starting the DHCP server

After the /etc/dhcpd.conf file is configured, you can start the DHCP server immediately. As root user from a Terminal window, type the following:

# service dhcpd start

Your DHCP server should now be available to distribute information to the computers on your LAN. If there are client computers on your LAN waiting on your DHCP server, their network interfaces should now be active.

If everything is working properly, you can have your DHCP server start automatically each time your computer boots by turning on the dhcpd service as follows:

# chkconfig dhcpd on

There are a few ways you can verify that your DHCP server is working:

When the server is running properly, you can continue to add DHCP clients to your network to draw on the pool of addresses you assign.

Категории