What is DHCP ?
Dynamic Host Configuration Protocol (DHCP) is a network protocol that enables a server to automatically assign an IP address to a computer from a defined range of numbers (i.e., a scope) configured for a given network.
DHCP (Dynamic Host Configuration Protocol) is a communications that lets network administrators centrally manage and automate the assignment of Internet Protocol IP addresses in an organization's network. Using the Internet Protocol, each machine that can connect to the Internet needs a unique IP address, which is assigned when an Internet connection is created for a specific computer. Without DHCP, the IP address must be entered manually at each computer in an organization and a new IP address must be entered each time a computer moves to a new location on the network. DHCP lets a network administrator supervise and distribute IP addresses from a central point and automatically sends a new IP address when a computer is plugged into a different place in the network.
RFCs 2131 and 2132 define DHCP as an Internet Engineering Task Force (IETF) standard based on Bootstrap Protocol (BOOTP), a protocol with which DHCP shares many implementation details. DHCP allows hosts to obtain necessary TCP/IP configuration information from a DHCP server.
Benefits of DHCP :-
- Reliable IP address configuration. DHCP minimizes configuration errors caused by manual IP address configuration, such as typographical errors, or address conflicts caused by the assignment of an IP address to more than one computer at the same time.
-
Reduced network administration. DHCP includes the following features to reduce network administration:
- Centralized and automated TCP/IP configuration.
- The ability to define TCP/IP configurations from a central location.
- The ability to assign a full range of additional TCP/IP configuration values by means of DHCP options.
- The efficient handling of IP address changes for clients that must be updated frequently, such as those for portable computers that move to different locations on a wireless network.
- The forwarding of initial DHCP messages by using a DHCP relay agent, thus eliminating the need to have a DHCP server on every subnet.
How DHCP Works :-
DHCP provides an automated way to distribute and update IP addresses and other configuration information on a network. A DHCP server provides this information to a DHCP client through the exchange of a series of messages, known as the DHCP conversation or the DHCP transaction. It is also known as "DORA-Process". If the DHCP server and DHCP clients are located on different subnets, a DHCP relay agent is used to facilitate the conversation.
DHCP Server Messages :-
1. DHCP-Discover:-
Broadcast by a DHCP client when it firest attempts to connect to the network. The DHCPDiscover message requests IP address information from a DHCP server.
2. DHCP-Offer:-
Broadcast by each DHCP server that receives the client DHCPDiscover
message and has an IP address configuration to offer to the client. The
DHCPOffer message contains an unleased IP address and additional TCP/IP
configuration information, such as the subnet mask and default gateway.
More than one DHCP server can respond with a DHCPOffer message. The
client accepts the best offer, which for a Windows DHCP client is the
first DHCPOffer message that it receives.
3. DHCP-Request:-
Broadcast by a DHCP client after it selects a
DHCPOffer. The DHCPRequest message contains the IP address from the
DHCPOffer that it selected. If the client is renewing or rebinding to a
previous lease, this packet might be unicast directly to the server.
4. DHCP-ACK:-
Broadcast by a DHCP server to a DHCP client acknowledging the
DHCPRequest message. At this time, the server also forwards any options.
Upon receipt of the DHCPAck, the client can use the leased IP address
to participate in the TCP/IP network and complete its system startup.
This message is typically broadcast, because the DHCP client does not
officially have an IP address that it can use at this point. If the
DHCPAck is in response to a DHCPInform, then the message is unicast
directly to the host that sent the DHCPInform message.
DHCP Server Configuration Lab :-
DHCP Server Video :-
DHCP Server Configuration Steps :-
Step 1: First of all configure your NIC with above lab structure.
To check the current configuration of NIC , execute the following command.
# ifconfig <NIC_Name>
e.g. I use the following command here :-
#ifconfig eth0
where eth0 is my NIC name , in your case it may be different.
to configure NIC, execute the following command-
#setup
#service NetworkManager start
# service network restart
Now check the NIC the configuration
#ifconfig eth0
Step 2 :- In the next step install the "DHCP" packages.
There are two ways to install packages.
1.RPM(Redhat Package Manager).
2.YUM Server.
following package you have to install to configure DHCP Server in RHEL 6 :-
dhcp-4.1.1-12.P1.el6.x86_64
If you haven't configured YUM Server in your network, then you have to install DHCP packages
manually with the help of rpm command.
I have configured YUM-Server in lab, so i install DHCP package using it.
before installing DHCP packages, check that packages are installed or not, to check that use the following command :-
#rpm -qa dhcp*
Now use the following command to install DHCP packages using YUM-Server :-
#yum install dhcp*
Now check DHCP Packages install or not in your PC, use the following command.
#rpm -qa <package-name>
Step 3 :- Now copy the main configuration file of DHCP Server from /usr/share/doc/dhcp-4.1.1/ to
/etc/dhcp/
By default the main configuration file (dhcpd.conf) is located in /usr/share/doc/dhcp-4.1.1/ directory.
to copy the sample file from /usr/share/doc/dhcp-4.1.1/ to /etc/dhcp/:-
#cp -rf /usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample /etc/dhcp/dhcpd.conf
Step 4 :- Now edit the /etc/dhcp/dhcpd.conf file.
to edit the /etc/dhcp/dhcpd.conf file, use the following command,
#vim /etc/dhcp/dhcpd.conf
the file will look like as below :-
Add the following lines to the main configuration file or edit the default scope :-
subnet 172.18.9.0 netmask 255.255.255.0 {
range 172.18.9.20 172.18.9.50;
option domain-name-servers ns1.internal.example.org;
option domain-name "mysolutions.com";
option routers 172.18.9.9;
option broadcast-address 172.18.9.255;
option domain-name-servers 172.18.9.1;
default-lease-time 21600;
max-lease-time 43200;
}
after adding these lines or edit the default scope, save the file and exit from it.
to save and exit from the file press "ESC + : + w + q + ! + Enter key".
Step 5 :- In the next step, start the "dhcpd" daemon.
to start the "dhcpd" daemon, execute the following command.
#service dhcpd start
to restart "dhcpd" daemon, execute the following command.
#service dhcpd restart
to start "dhcpd" daemon on boot time, execute the following command.
#chkconfig dhcpd on
to check the "dhcpd" daemon status, execute the following command.
#service dhcpd status
To check DHCP syntax error in RHEL 6, execute the following command :-
#dhcpd -t
this will show you that where did you make mystake in main configuration file of DHCP Server.
Client Side configuration :-
Linux :-
to obtain ip from DHCP Server, edit the particular NIC configuration file likewise on client PC.The NIC Configuration file is located in the "/etc/sysconfig/network-scripts/" directory.
edit the file with vim editor and set BOOTPROTO type DHCP:-
#vim /etc/sysconfig/network-scripts/ifcfg-eth0
Note:- In the above command "eth0" is your NIC number, which you wanna configure,it may be different in your PC.
file configuration is :-
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=dhcp
HWADDR=08:00:27:c0:4f:bf
then save the file and exit from it.
to save and exit from the file press "ESC + : + w + q + ! + Enter key".
Now restart the "Network" daemon.
execute the following command to restart the "Network" daemon.
#service network restart
and then check NIC configuration by executing the following command.
#ifconfig eth0
Now generate the lease database in the DHCP Server :-
execute the following command :-
#touch /var/lib/dhcpd/dhcpd.leases
to check the lease database,execute the following command.
#cat /var/lib/dhcpd/dhcpd.leases
Windows :-
to obtain ip from DHCP Server in Windows Operating System do the following :-
1st Method :-
Open the run menu -------->type "ncpa.cpl" -------->and then click on "OK".
the "Network and Sharing Center" wizard will appear.
2nd Method :-
Right click on "Network" icon on desktop ---------->then click on properties.
Click on Change adapter settings --------> Then go to NIC properties -------->Select "Internet Protocol Verstion 4 (TCP/IPv4)" -------> Properties -------> Select "Obtain an IP address automatically" ------->OK----->OK.
To check IP configuration graphically in Windows OS :-
Open the "Network Connections" wizard ----> and then Right click on "NIC" ---------> Click on "Status" ------->Then click on "Details".
To check IP configuration from command line :-
Use the following commad
ipconfig
ipconfig /all
Mac Binding :-
Static IP Address Using DHCP
to provide Static IP using DHCP, add the following line to "/etc/dhcp/dhcpd.conf" in file particular Subnet Scope.
host host_name {
hardware ethernet 00:A0:78:8E:9E:AA; fixed-address 192.168.1.4;}
Example :-
host xp {
hardware ethernet 08:00:27:1C:5C:4D;
fixed-address 172.18.9.22;
}
Back to RHEL 6 Tutorials
wherever you'll be able to get plenty of data with bit example keep writing like this and lots of folks select your content.
ReplyDeleteCheapest dedicated