Книга: Fedora™ Unleashed, 2008 edition

Using DHCP to Configure Network Hosts

Using DHCP to Configure Network Hosts

Configuring your network with DHCP can look difficult, but is actually easy if your needs are simple. The server configuration can take a bit more work if your network is more complex and depending on how much you want DHCP to do.

DHCP Server Configuration

Configuring the server takes some thought and a little bit of work. Luckily, the work involves editing only a single configuration file, /etc/dhcpd.conf. To start the server at boot time, use the service command or the GUI-based system-config-services.

The /etc/dhcpd.conf file contains all the information needed to run dhcpd. Fedora includes a sample dhcpd.conf in /usr/share/doc/dhcp*/dhcpd.conf.sample. The DHCP server source files also contain a sample dhcpd.conf file.

The /etc/dhcpd.conf file can be looked at as a three-part file. The first part contains configurations for DHCP itself. The configurations include

Setting the domain nameoption domain-name "example.org".

Setting DNS serversoption domain-name-servers ns1.example.org, ns2.example.org (IP addresses can be substituted).

Setting the default and maximum lease timesdefault-lease-time 3600 and max-lease-time 14400.

Other settings in the first part include whether the server is the primary (authoritative) server and what type of logging DHCP should use. These settings are considered defaults and can be overridden by the subnet and host portion of the configuration in more complex situations.

NOTE

The dhcpd.conf file requires semicolons (;) after each command statement. If your configuration file has errors or runs improperly, check for this.

The next part of the dhcpd.conf deals with the different subnets that your DHCP server serves; this section is quite straightforward. Each subnet is defined separately and can look like this:

subnet 10.5.5.0 netmask 255.255.255.224 {
 range 10.5.5.26 10.5.5.30;
 option domain-name-servers ns1.internal.example.org;
 option domain-name "internal.example.org";
 option routers 10.5.5.1;
 option broadcast-address 10.5.5.31;
 default-lease-time 600;
 max-lease-time 7200;
}

This defines the IP addressing for the 10.5.5.0 subnet. It defines the IP address ranging from 10.5.5.26 through 10.5.5.30 to be dynamically assigned to hosts that reside on that subnet. This example shows that any TCP/IP option can be set from the subnet portion of

the configuration file. It shows to which DNS server the subnet will connect, which can be good for DNS server load balancing, or which can be used to limit the hosts that can be reached through DNS. It defines the domain name, so you can have more than one domain on your network. It can also change the default and maximum lease time.

If you want your server to ignore a specific subnet, the following entry can be used to accomplish this:

subnet 10.152.187.0 netmask 255.255.255.0 {
}

This defines no options for the 10.152.187.0 subnet; therefore, the DHCP server ignores it.

The last part of your dhcp.conf is for defining hosts. This can be good if you want a computer on your network to have a specific IP address or other information specific to that host. The key to completing the host section is to know the hardware address of the host. The hardware address is used to differentiate the host for configuration. You can obtain your hardware address by using the ifconfig command as described previously. The hardware address is on the eth0 line labeled "Hwaddr".

host fantasia {
 hardware ethernet 08:00:07:26:c0:a5;
 fixed-address fantasia.fugue.com;
}

This example takes the host with the hardware address 08:00:07:26:c0:a5 and does a DNS lookup to assign the IP address for fantasia.fugue.com to the host.

DHCP can also define and configure booting for diskless clients like this:

host passacaglia {
 hardware ethernet 0:0:c0:5d:bd:95;
 filename "vmunix.passacaglia";
 server-name "toccata.fugue.com";
}

The diskless host passacaglia gets its boot information from server toccata.fugue.com and uses the vmunix.passacaglia kernel. All other TCP/IP configuration can also be included.

CAUTION

Remember, only one DHCP server should exist on a local network to avoid problems. Your DHCP might not work correctly on a LAN with hosts running outdated legacy operating systems. Often Windows NT servers have the Windows DHCP server installed by default. Because there is no configuration file for NT to sort through, that DHCP server configures your host before the Linux server if both machines are on the same LAN. Check your Windows NT servers for this situation and disable DHCP on the Windows NT server; afterward, your other DHCP-enabled hosts should configure correctly. Also, check to make sure that there are no conflicts if you use a cable or DSL modem, wire less access point (WAP), or other intelligent router on your LAN that can provide DHCP

Оглавление книги


Генерация: 1.392. Запросов К БД/Cache: 3 / 0
поделиться
Вверх Вниз