Академический Документы
Профессиональный Документы
Культура Документы
DEVICE="eth0"
HWADDR="00:0C:29:0A:26:80"
NM_CONTROLLED="yes"
ONBOOT=yes
BOOTPROTO=static
IPADDR=192.168.3.5
NETMASK=255.255.255.0
GATEWAY=192.168.3.1
DNS1=202.56.215.55
gedit /etc/sysconfig/network
NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=rdc.sushilsharma.com
Step 2.
Step 3.
With the package installed, make sure that the dhcpd service
starts when the system boots as well:
# chkconfig dhcpd on
Step 4.
2:on
3:on
4:on
5:on
Main config file for the DHCP service using IPv4 addresses
/etc/dhcp/dhcpd6.conf
Main config file for the DHCP service using IPv6 addresses
In RHEL5, the location of the main config file was /etc/dhcpd.conf. Now
in RHEL6, the config file has been moved into a directory (/etc/dhcp)
because there are additional config files for IPv6 addresses.
To copy the sample file, use the following command:
# cp
/usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample
/etc/dhcp/dhcpd.conf
172.168.1.1;
option subnet-mask
255.255.255.0;
option domain-name
example.com;
option domain-name-servers
172.168.1.1;
default-lease-time
21600;
max-lease-time
43200;
# Client IP range
range dynamic-bootp 172.168.1.100 172.168.1.200;
}
Lets break down this file into sections. The first section contains two
options for the DHCP server itself, also called global options:
ddns-update-style:
none
authoritative
This means that the DHCP server wont update client DNS
records.
This informs the client that the DHCP server contains
legitimate information.
The next section defines a subnet. Any options that you list in a subnet
section are specific to the subnet for which you define them. If you want
to set global options (such as authoritative), you need to define them
outside the subnet section. In this section, the following options are used:
option routers
subnet
option subnet-mask
subnet
option domain-name
option domain-
name-servers
default-lease-time
Specifies how long each client keeps its lease until a renewal
is re- quested (in seconds)
max-lease-time
range dynamic-bootp
Even though the DHCP server is set to run, there is another exam- ple to
consider. It is common in the real world to have to reserve an IP address
for a particular client. If you dont want to make the IP address of the client
static, you
Again, lets look at each of these options and what they do.
hardware ethernet
fixed-address
These three options are defined in a host subsection, just like you defined a
subnet section earlier. With the config files in place, you are now ready to
start the serv- ice. The DHCP server offers a particularly nice feature built
into the startup scripts; it can check the syntax of your config file for errors.
This capability is nice because prior to actually starting the service, you can
check to make sure nothing is set incorrectly.
Check the config file for any errors:
# service dhcpd configtest
Syntax: OK
If the DHCP service does find errors, it attempts to tell you where in the
config file the error exists. Open your config file and remove the brace (})
that ends the sub- net section. Save your config file and run the syntax
check on your config file again:
# service dhcpd configtest
Internet Systems Consortium DHCP Server V3.0.5-RedHat
Copyright 2004-2006 Internet Systems Consortium. All rights reserved.
For info, please visit http://www.isc.org/sw/dhcp/
/etc/dhcpd.conf line 18: unexpected end of file
^
Configuration file errors encountered exiting
Here, the service points out that the } is missing from the config file by giving
you the line where the issue occurs
as well as a general description of what the problem is. Now replace the }
again and restart the DHCP service:
# service dhcpd start
Starting dhcpd:
[ OK ]
You should now have a fully functional DHCP server! You can boot up your
clients and see if they pick up an IP address,
or if the client is al- ready powered on, you can use the dhclient command to
request an IP address from the server.
Request a dynamic IP from the server:
# dhclient
Internet Systems Consortium DHCP Client V3.0.5-RedHat
Copyright 2004-2006 Internet Systems Consortium. All rights reserved.
For info, please visit http://www.isc.org/sw/dhcp/
Listening on LPF/eth0/08:00:27:74:5b:11
Sending on
LPF/eth0/08:00:27:74:5b:11
Sending on
Socket/fallback
Troubleshooting DHCP
Not all configurations go as smoothly as you might like. When youre troubleshooting the DHCP server, there
are a few things to watch out for. For example, in the main config file,
/etc/dhcp/dhcpd.conf, make sure that you
end all your options with a semicolon (;). If you dont, the service throws an
error when you check the config file.
For client troubleshooting, the DHCP server provides a client leases file. This
file contains all the lease information about each client that has
ob- tained an IP address from the server. When you have a client that has a
DHCP address, you can view the
leases file by using the following:
# cat /var/lib/dhcpd/dhcpd.leases
lease 172.168.1.200 {
starts 2 2010/05/11 12:24:10; ends
2010/05/11 18:24:10; binding state free;