Account Links: Cart | Register | Log In

Skip to content

Red Hat Knowledgebase
Red Hat Knowledgebase Search
Article translations:
Currently Being Moderated

How do I configure my Red Hat Enterprise Linux DHCP server?

Article ID: 1673 - Created on: Nov 6, 2004 6:00 PM - Last Modified:  Nov 9, 2004 6:00 PM

Dynamic Host Configuration Protocol (DHCP is a protocol that lets network administrators centrally manage and automate the assignment of IP addresses on a network. Without DHCP each machine must have its IP address manually.

 

DHCP allows a network administrator to manage and distribute IP addresses and network settings from a DHCP server. The server must be configured to send this information to clients configured to use the DHCP protocol to obtain IP and other network information.

 

DHCP clients periodically refresh their network information from the DHCP server, if any changes have been made on the DHCP server the client will change their settings accordingly. The time between refresh is known as the lease time.

 

In the example below, you will need to modify each of the lines to suit the network which you are serving addresses for. The example below uses the fictitious example.com domain.

 

The /etc/dhcpd.conf file.

 



# The options outside a subnet directive are global unless
# over-ridden by the same setting inside the subnet directive.

option domain-name-servers 192.0.34.43, 193.0.0.236;

default-lease-time 6000; max-lease-time 7200;

# If this DHCP server is the official DHCP server for the local
# network, the authoritative directive should be uncommented.

authoritative;

# Use this to send dhcp log messages to a different log file (you also
# have to hack syslog.conf to complete the redirection).

log-facility local7;

# Handle client dynamic dns updates
ddns-update-style none;

# Example Network 1 ( on eth0 )

subnet 192.168.200.0 netmask 255.255.255.0 {
     option domain-name “corp.example.com";
     range 192.168.200.100 192.168.200.200;
     option routers 192.168.200.254;
}

 

The example above is seperated into two sections, subnet specific and global. Multiple subnets can be configured, although for the sake of simplicity only a single subnet is shown.

 

Subnet

 

A subnet declaration in the example above, is the line that starts with subnet and has a set of curly brackets ( {} ) surrounding its subnet specific options. Any option set inside a subnet declaration over-rides the configuration set globally.

 

Global

 

Any configuration option considered global is situated outside a subnet declaration. If the same option is not specifically overwritten, it will be valid to every subnet declaration.

 

Configuration Options

 

Listed below is an explanation of the directives in the example provided above. Any line that begins with the # character is considered a comment and is ignored by the DHCP server.

 



option domain-name-servers 192.0.34.43, 193.0.0.236;

 

This line specifies which domain name servers (DNS) that will be handed out to clients, it can be declared globally as it is in the above example or specifically per subnet.

 



default-lease-time 6000;
max-lease-time 7200;

 

These lines are related, the default-lease-time is the time in seconds before a client should refresh its information. The max-lease-time is the time that a client will forget its networking settings if it has not obtained the infromation from the server after this time it will relinquish its current network settings and return to operating system defaults.

 



authoritative;

 

The authorative line specifies that when a client machine attempts to obtain an IP address that is not being served by this DHCP server, the DHCP server will send a request denied, rather than wait for the request to time out. When the request has been denied, the client should request a new address from the current DHCP server.

 



log-facility daemon;

 

The log-facility option tells the DHCP server which loglevel to send to the local syslog facility.

 



ddns-update-style none;

 

This determines the method that clients may use to dynamically update their hostname to IP address mapping. In this example it is disabled.

 



subnet 192.168.200.0 netmask 255.255.255.0 {
     option domain-name “corp.example.com";
     range 192.168.200.100 192.168.200.200;
     option routers 192.168.200.254;
}

 

The above is the subnet declaration.

 

The first line specifies the network address and the netmask of the subnet that you are serving for. There must be an network card in the machine configured statically with an IP address in this range.

 

The first IP address after the word subnet network address, the second is the netmask.

 

The domain-name option sets the domain name on the client.

 

The DHCP server can serve the entire range, but allows you to configure the server to only hand out a certain subset of the range. This can be useful when there is a reserved part of the range set for devices that require a static IP such as a printer.

 

The default gateway can be also be configured using the “option routers” option.

 

After modifying the file, and saving it, ensure that the file /etc/sysconfig/dhcpd exists and contains the name of the interface that you wish to serve clients on, in the ‘DHCPARGS=’ line:

 



# Command line options here
DHCPDARGS="eth0";

 

Finally, start or restart the DHCP server

 



/etc/init.d/dhcpd restart

 

Clients connected to this machine by a network device should receive an IP address when they request it.

 

It is important not to run more than one DHCP server on a network segment. Unless you are a network administrator it is unlikely you will need to run a DHCP server.

Feedback from users like yourself is a critical factor in helping us make the Red Hat Knowledgebase as useful as possible.

More Like This

  • Retrieving data ...