Setting up a DHCP Server

The Dynamic Host Configuration Protocol (DHCP) can automatically give all TCP/IP computers on your network the information that it needs to communicate. This includes the routers, the DNS servers, other name type servers, as well as basic IP addressing information.

To set up a computer as a DHCP server, you ll need to make sure that the network card can handle multicast requests . If you have older Microsoft Windows computers, you should also set up the broadcast address as a dedicated route. Then you can configure the DHCP configuration file, /etc/ dhcpd.conf . If you want to use your DHCP server for remote networks, you ll also have to configure dhcrelay on the router/gateway between your LANs. The dhcrelay daemon supports the BOOTP protocol. But first, let s take a look at the RPM packages that you ll need.

Packages

Not all of the RPM packages that you need for DHCP are installed by default. The required packages are listed in Table 24.4; as you might remember from Chapter 10 and earlier in this chapter, you can use the rpm -q packagename command to see if they re installed. After you confirm this, you can use the rpm -ql packagename command to see the associated files.

Table 24.4: DHCP RPM Packages

Package

Function

dhcp-*

DHCP server software

dhcp- devel -*

DHCP development tools; not required

dhclient-*

DHCP client software

Basic Configuration

A Linux computer configured as a DHCP server requires multicast support on the network card and the all ones broadcast address enabled.

Multicast support is probably already built into your network card and kernel. To check, run the ifconfig command. You should see output for your network card(s). Just under the entries for the associated IP addresses, you should see the following:

 UP BROADCAST RUNNING MULTICAST  MTU:1500  METRIC:1 

If you don t see MULTICAST in this line, you ll need to reconfigure network support for MULTICAST in the kernel. Refer to Chapter 12 for details.

You may also need to configure the route to the all ones broadcast address, which is 255.255.255.255. Older clients , such as Microsoft Windows 95, need to hear this broadcast address; otherwise , they won t even know that your DHCP server is there. If your DHCP server will be used for older clients on your network, run the following command:

 # route add -host 255.255.255.255 dev eth0 

The Configuration File: /etc/dhcpd.conf

Now you can configure the main DHCP server configuration file, /etc/dhcpd.conf . Let s start with a sample file from the dhcp-* RPM, dhcp.conf.sample in the /usr/share/doc/dhcp- versnum directory. This sample lists a number of IP addresses, which you ll want to change to match the settings for your own network.

To learn more about DHCP servers, you may find it helpful to analyze the file in detail. The following is based on a line-by-line excerpt from the sample file. The first line allows Dynamic DNS updates to the latest available interim standard. A number of IP addresses are shown. If the applicable IP addresses for your network are different, substitute accordingly :

 ddns-update-style interim; 

You may not want individual users to update their hostname or IP address entries in the DNS server, so you use this command:

 ignore client-updates; 

Alternatively, you can use the command allow client-updates , which permits users to update their hostname or IP address entries.

The following line sets the default range of allowable IP addresses. Some of these addresses may be reserved for specific computers by later commands:

 subnet 192.168.0.0 netmask 255.255.255.0 { 

If your LAN is connected to another LAN, there should be a gateway IP address on a router that connects your LAN to the other. The following command specifies that gateway IP address:

 option routers 192.168.0.1; 

The following command is straightforward; it specifies the subnet mask, also known as the network mask, for the network:

 option subnet-mask 255.255.255.0; 

If you configure an NIS authorization database for your network, you can specify its domain (substitute it for domain.org in this command). For more information on NIS, see Chapter 28 .

 option nis-domain "domain.org"; 

Naturally, you probably have a domain name for your network. Based on the examples earlier in this chapter, it might be something like example.com. In this command, substitute the domain name for your LAN for domain.org :

 option domain-name "domain.org"; 

If you ve set up a DNS server on your LAN, list its address here. It can help this DHCP server find your DNS server for updates as required. You can use similar lines to identify the servers for incoming or outgoing e-mail ( option pop-server or smtp-server ), a web server ( option www-server ), or even a server dedicated to log files ( option log-server ):

 option domain-name-servers 192.168.1.1; 

The next statement helps you keep your network synchronized. The time is shown in seconds, relative to Greenwich Mean Time (GMT). In other words, U.S. Eastern Standard Time is 18000 seconds, or 5 hours, behind GMT. If you are in a different time zone, substitute accordingly.

 option time-offset -18000; # Eastern Standard Time 

Some computer clocks are faster than others. Computer clocks can slow down if a battery is low. If you have several computers running the same process, such as a web server, it can be important to synchronize their clocks. This is possible with a Network Time Protocol (NTP) server, which you may have configured in Chapter 19 with the redhat-config-time utility. This statement allows you to call the NTP server of your choice:

 option ntp-servers 192.168.1.1; 

Some Linux computers are configured as part of a Microsoft Windows “based network. One of the Microsoft name services for different computers is based on NetBIOS names . This is known as the Windows Internet Naming Service (WINS):

 option netbios-name-servers 192.168.1.1; 

It is possible to configure the DHCP server as a p-node computer; in other words, it looks for a WINS server and possibly a LMHOSTS file for name resolution:

 option netbios-node-type 2; 

You can configure a range of IP addresses that this DHCP server can assign to computers on remote networks. These addresses must fit within the range of defined network addresses.

 range dynamic-bootp 192.168.0.128 192.168.0.254 

DHCP servers assign IP addresses on a temporary basis. The first time an IP address may be renewed is the default-lease-time , in seconds:

 default-lease-time 21600 

An IP address should be renewed by the max-lease-time , in seconds:

 max-lease-time 43200 

You can assign a fixed IP address, based on the hardware address of a specific computer s network card. The next-server variable in this case refers to the alternate DNS server ( host ns ):

 host ns {     next-server marvin.redhat.com     hardware ethernet 12:23:34:45:AB:CD     fixed-address 207.175.42.254 } 

Once you ve customized this file for your LAN, save it as /etc/dhcpd.conf .

Starting the DHCP Server

To run the Linux DHCP server, you need a network card that already has an IP address. If necessary, use the ifconfig command to assign an IP address, as discussed in Chapter 21 .

Starting the DHCP service is easy. Just run the dhcpd script with a command such as service dhcpd start . Remember to use a command such as chkconfig to make sure that your DHCP server starts the next time you boot Linux.

DHCP Servers and Remote Networks

When you can configure a DHCP server to reserve a series of IP addresses for remote networks (see the range dynamic-bootp variable in the previous section), a DHCP server needs help. Normally, gateways or routers that sit between networks block DHCP messages. That is where you should implement the BOOTP protocol, which opens up a path through a router or gateway for DHCP communication between your LANs.

To set up BOOTP, install the dhcrelay daemon (from the dhcp-* RPM package) on the gateway or router computer. Then you can configure command options in the /etc/sysconfig/dhcrelay configuration file. For example, the following commands in that file let dhcrelay listen on both the eth0 and eth1 network cards. The DHCPSERVERS should be connected to at least one of these network cards. You can then specify any network cards connected to networks that need remote DHCP service.

 INTERFACES="eth0 eth1" DHCPSERVERS="192.168.0.213" 

Remember to start the dhcrelay script and use chkconfig to make sure that dhcrelay is active the next time you boot Linux.

Tip  

One common mistake is to specify only the network adapters that are connected to the LANs that need remote DHCP service. Remember to include the adapter that is connected to the LAN with the DHCP server.

A Lease Database

Once computers on your networks start getting addressing information from your DHCP server, the results will be documented in /var/lib/dhcp/dhcpd.leases . An example of this file is shown in Figure 24.12, which displays IP address assignments to the hardware address of different network cards on your LAN.

click to expand
Figure 24.12: dhcpd.leases      
 


Mastering Red Hat Linux 9
Building Tablet PC Applications (Pro-Developer)
ISBN: 078214179X
EAN: 2147483647
Year: 2005
Pages: 220

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