Thursday, 25 December 2014

DHCP Relay Agent in RHEL 6


DHCP Relay Agent in RHEL 6 

What is DHCP Relay Agent ?


A DHCP relay agent is any host that forwards DHCP packets between clients and servers. Relay agents are used to forward requests and replies between clients and servers when they are not on the same physical subnet. Relay agent forwarding is distinct from the normal forwarding of an IP router, where IP datagrams are switched between networks somewhat transparently. By contrast, relay agents receive DHCP messages and then generate a new DHCP message to send out on another interface.


The DHCP Relay Agent is the routing protocol that enables DHCP clients to obtain IP addresses from a DHCP server on a remote subnet, or which is not located on the local subnet. If you have no configured DHCP Relay Agent, your clients would only be able to obtain IP addresses from the DHCP server which is on the same subnet. To enable clients to obtain IP addresses from a DHCP server on a remote subnet, you have to configure the DHCP Relay Agent on the subnet that contains the remote clients, so that it can relay DHCP broadcast messages to your DHCP server.

A DHCP relay agent is a router or computer that is configured to listen for DHCP or BOOTP broadcast from DHCP clients and then relay those messages to DHCP servers on different subnets.

DHCP clients use broadcasts from a DHCP server to secure a lease. Network routers do not pass broadcasts, unless they are specifically configured to do so. his means that a DHCP server can normally provide IP addresses to clients which are located on the same subnet.

Many organizations want to centralize their DHCP servers, as they find it easier to manage. These organizations must configure their network so that DHCP broadcasts will be passed from the client to the DHCP server. This can be done in any of the two ways: by configuring the routers which connect the subnets to forward DHCP broadcasts, or by configuring DHCP Relay Agents. The Routing and Remote Access Service under Microsoft Windows is able to function as a DHCP relay agent.

How relay agents work ?


 A relay agent relays DHCP/BOOTP messages that are broadcast on one of its connected physical interfaces, such as a network adapter, to other remote subnets to which it is connected by other physical interfaces. The following illustration shows how client C on Subnet 2 obtains a DHCP address lease from DHCP server 1 on Subnet 1.



  1. DHCP client C broadcasts a DHCP/BOOTP discover message (DHCPDISCOVER) on Subnet 2, as a User Datagram Protocol (UDP) datagram using the well-known UDP server port of 67 (the port number reserved and shared for BOOTP and DHCP server communication).
  2. The relay agent, in this case a DHCP/BOOTP relay-enabled router, examines the gateway IP address field in the DHCP/BOOTP message header. If the field has an IP address of 0.0.0.0, the agent fills it with the relay agent or router's IP address and forwards the message to the remote Subnet 1 where the DHCP server is located.
  3. When DHCP server 1 on remote Subnet 1 receives the message, it examines the gateway IP address field for a DHCP scope that can be used by the DHCP server to supply an IP address lease.
  4. If DHCP server 1 has multiple DHCP scopes, the address in the gateway IP address field (GIADDR) identifies the DHCP scope from which to offer an IP address lease.

    For example, if the gateway IP address (GIADDR) field has an IP address of 10.0.0.2, the DHCP server checks its available set of address scopes for a scope range of addresses that matches the class A IP network that includes the gateway address as a host. In this case, the DHCP server would make a check for a scope of addresses between 10.0.0.1 and 10.0.0.254. If a matching scope exists, the DHCP server selects an available address from the matched scope to use in an IP address lease offer response to the client.
  5. When DHCP server 1 receives the DHCPDISCOVER message, it processes and sends an IP address lease offer (DHCPOFFER) directly to the relay agent identified in the gateway IP address (GIADDR) field.
  6. The router then relays the address lease offer (DHCPOFFER) to the DHCP client.
The client IP address is still unknown, so it has to be broadcast on the local subnet. Similarly, a DHCPREQUEST message is relayed from client to server, and a DHCPACK message is relayed from server to client, according to RFC 1542.

DHCP Relay Agent Configuration Lab :-



DHCP Relay Agent Practical Video :-


DHCP Relay Agent Configuration Steps :-


Step 1:- Configure the NIC (Network Interface Card).
              Execute the following command to configure NIC.

              #setup

Step 2:- Restart the Network Service by executing the following command.

              #service network restart

Step 3:- Then check your NIC Configuration with the help of following command.

              # Ifconfig

Step 4:- In the next step insert the RHEL 6 DVD into your PC and mount it.
              To mount it, use the following command:-

              # mount /dev/cdrom /mnt

Step 5:- Now install the DHCP-Relay Packages.
              There are two ways to install its packages.

              i. RPM command.
              ii. YUM Server.

I have configured Local Yum Server in my Lab. So I will install DHCP RELAY packages using myYUM Repository. To install package using YUM-Server, use the following command:-

              #yum install dhcp*

              To verify DHCP Relay Package, execute the following command:-

              #rpm -qa dhcp*

Step 6:- In the next step,edit the main configuration file of DHCP-Relay and add the following lines to it.

              To edit the main configuration file of DHCP Relay, execute the following command:-

              #vim /etc/sysconfig/dhcrelay

              After executing the above command, add the following two lines to it :-

              INTERFACES= “eth0 eth1”
              DHCPSERVERS=”172.18.9.10”

Note :- 172.18.9.10 is the IP Address of DHCP Server, in your case it may be changed.

Step 7:- Use the following command to forward DHCP Client packets to DHCP through DHCP-RELAY.

              #echo 1 /proc/sys/net/ipv4/ip_forward

Step 8:- In the last step start the DHCP Relay service by executing the following command :-

              #service dhcrelay start

              To start the DHCP Relay service at boot time, execute the following command:-

              #chkconfig dhcrelay on

              To restart the DHCP Relay service, execute the following command:-

              #service dhcrelay restart

              To check the status of DHCP Relay service, execute the following command:-

              #service dhcrelay status

              To check connectivity between DHCP Relay and DHCP Server, execute the following command :-

              #ping 172.18.9.10

Where 172.18.9.10 is the IP Address of DHCP Server.

Back to RHEL 6 Tutorials

No comments:

Post a Comment