DHCP Configuration in Redhat /Cent OS
One of the basics elements found on all networks is a Dynamic Host Configuration Protocol (DHCP) server, making it an important part of any network. DHCP makes network administration easy because you can make changes to a single point (the DHCP server) on your network and let those changes filter down to the rest of the network.
Before you can begin the installation or setup of a DHCP server, you need to verify that the server is configured with a static IP address. To verify this, you can look at the interface config file:
# cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=”eth0”
NM_CONTROLLED=”yes”
ONBOOT=yes
HWADDR=00:0C:29:80:F1:FD
TYPE=Ethernet
BOOTPROTO=static
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPADDR=192.168.1.253
NETMASK=255.255.255.0
IPADDR=192.168.1.253
NETMASK=255.255.255.0
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
Installing a DHCP Server
Strangely, the DHCP server package is called dhcp, while the service is called dhcpd.
Step 1. Start by installing the dhcp package:
# yum install -y dhcp
Step 2. With the package installed, make sure that the dhcpd service starts when the system boots as well:
# chkconfig dhcpd on
Step 3. Verify that the DHCP service starts on boot:
# chkconfig dhcpd --list
dhcpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
Configuring the DHCP Server
To start the configuration, let’s look at the important files that handle the options
for the DHCP service:
/etc/dhcp/dhcpd.conf Main config file for the DHCP service using IPv4 addresses
/etc/dhcp/dhcpd6.conf Main config file for the DHCP service using IPv6 addresses
/var/lib/dhcpd/dhcpd.leases IPv4 client lease file
/var/lib/dhcpd/dhcpd6.leases IPv6 client lease file
The main config file is usually empty aside from a comment or two. The good news is that the package does provide a sample config file for you to use. This sample file provides examples and comments on how you can configure options for your DHCP server.
To copy the sample file, use the following command:
# cp /usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample /etc/dhcp/dhcpd.conf
Or else u can edit the same configuration file.
Here is the sample DHCP server config file:
# Global Options
ddns-update-style none;
# Subnet definition
subnet 192.168.1.0 netmask 255.255.255.0 {
# Parameters for the local subnet
option routers 192.168.1.1;
option subnet-mask 255.255.255.0;
option domain-name “example.com”;
option domain-name-servers 192.168.1.1;
default-lease-time 21600;
max-lease-time 43200;
# Client IP range
range 192.168.1.100 192.168.1.200;
}
Let’s 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 This means that the DHCP server won’t update client DNS records.
authoritative 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.
We also need to adjust the /etc/sysconfig/dhcpd file. In this case, you need to edit the following daemon option:
DHCPDARGS=”eth0”
After that we want to test the configuration file is correct or not.
Check the config file for any errors:
# service dhcpd configtest
Syntax: OK
Now restart the DHCP service:
# service dhcpd start
Starting dhcpd: [ OK ]
Verify that the service is running:
# service dhcpd status
dhcpd (pid 3366) is running...
Client Configuration
Go to the configuration of networking
#system-config-network
Select the device
Now u can select the dhcp that will resolve ip address from the server
The ipaddress will be in the range of 100 to 200..
As a final tip, make sure you use the configtest option to test the syntax of your config files before starting or restarting the service.This prevents any errors from occurring when you try to start the service.Thank you....



No comments:
Post a Comment