DHCP

routers, servers and any other devices of which location is usually not te be moved or changed physically/logically may be given static IP address. however, client workstations in an organization are likely to be moved physically/logically. this can be a burden for network administrators having to give a new IP address for those workstations everytime they are moved. DHCP services help network administrator do this task. with DHCP services, IP addressing can be made automatically and transparently. usually network administrators use a seperate server for offering DHCP services. in a small organization or SOHO envinronment, a cisco router can be used as a DHCP server. IOS has a feature set called Easy IP offers full-featured DHCP server.

DHCP servers assign not only IP address to a client but also the subnet mask, a gateway address and also DNS server address. DHCP works in a client/server environment.

The main task of a DHCP server is to provide IP addressess to clients. DHCP includes three different IP address alocation mechanism:
  • Manual allocation. the Administrator assigns a pre-allocation IP address for a corresponding workstation. DHCP will only allocate the address to the specified client.
  • Automatic allocation. DHCP automatically assigns an IP address selected from a pool to a device. there's no lease and the address is permanently assigned to the device
  • Dynamic allocation. DHCP automatically assigns an IP address selected from a pool to a device. the given IP address is leased to the device for a period of time or until the client tells that it's no longer needs the address. this ensures that hosts moved or no longer needs the address don't hold the addresses. when the lease time expires, DHCP server returns the address to the pool for reallocations. clients must contact the DHCP server periodically to extend the lease (when the lease time expires).


DHCP Operations
  • Discover. when a client boots or wants to join a network, it will send a DHCPDISCOVER message to find a DHCP server in the network. because the client doesn't have a valid address. it uses an L2 or L3 broadcast addresses to communicate with the server.
  • Offer. when the DHCP server receives the DHCPDISCOVER message, it will find an available IP address from the pool and try to offer it to the requesting client. the offer will be sent as a DHCPOFFER message to client as a unicast packet (under some circumstances, the packet is broadcasted rather than unicasted) using the L2 MAC address of the server as the source and the L2 MAC address of the requesting client as the destination.
  • Request. after the client receives the DHCPOFFER, it sends back a DHCPREQUEST message. this message has two purposes, it's used as a lease origination and lease renewal and verification. when used as a lease origination, the DHCPREQUEST sent request that the IP information be verified after it has been assigned. this provide error checking so that the assignment is valid. DHCPREQUEST also serves as a binding acceptance notice to the selected server and an implicit decline to any other servers that may have provided the host a binding offer (many organizations use multiple DHCP servers).
  • Acknowledge. after receiving the DHCPREQUEST message, the DHCP server then will send a DHCPACK message to the requesting client. the DHCPACK message is a duplicate of the DHCPREQUEST message with just a simple change in the message type field. when the client receives the DHCPACK message, it will then logs the configuration information and sends an ARP broadcast to the network for the leased IP, if there's no reply then the client knows that it's a valid ip address and start using it. the time that the address is leased is different as network administrators set it at the server, the default time is three days.



BOOTP
BOOTP (RFC 951) is a predecessor of DHCP and share some operational characteristics (both BOOTP and DHCP are client/server based and use UDP ports 67 and 68). BOOTP is a way to download address and boot configurations for diskless workstations (example, automated cash register system at super market). three primary differences between DHCP and BOOTP are:
  • BOOTP is used for manual pre-configuration while DHCP is used for dynamic address allocation. when a client requests an address from a BOOTP server, the server searches the client MAC address, if it exists in the server database, the server will give the address and configuration to the client bound to the client's MAC. this means that, the binding must be configured/entered manually to the server.
  • DHCP uses leasing system. a client is given a leased address for a period of time. when the time is over. the address can be allocated to any other client. while BOOTP has its clients reserved IP address which cannot be allocated to any other client.
  • BOOTP only supports 4 configuration parameters. DHCP supports over 20 configuration parameters (domain name, WINS).

For compatibility reason, DHCP messages have the same format as BOOTP messages. except that DHCP messages have additional fields called DHCP options which varies in length. the fields in a DHCP message are:
  • Operational Code (OP). 1 byte. specifies the general type of the message. 1 indicates a request mesasge, 2 is a reply message.
  • Hardware Type. 1 byte. indicates the type of the hardaware used in the network. example, 1 is ethernet, 15 is frame relay and 20 is a serial line. this is the same code used in ARP messages.
  • Hardware Address legnth. 1 byte. specify the length of the hardware address.
  • Hops. 1 byte. set to 0 by clients before transmitting a request and used by realy agents to control the forwarding of DHCP messages.
  • Transaction Identifier. 4 bytes. generated by a client to match its request with the replies from the server.
  • Seconds. 2 bytes. number of seconds elapsed since a client attempt to request or renew its address. DHCP servers use this to prioritize clients requests.
  • Flags. 2 bytes. only one bit is used, the broadcast bit. the client that doesn't know its address sends a request setting the broadcast bit to 1. the receiving server will send the reply as a broadcast message.
  • Client IP address. 4 bytes. sets by the client when it has a valid and usable address while in the bound state. otherwise it is set to 0. (the client cannot use this during the process of acquiring an address.
  • Your IP Address. 4 bytes. IP address the server offers to the client.
  • Server IP Address. 4 bytes. address of the server, the server always includes its IP address in a field called the Server Identification DHCP Option. the client should set this address it has known the address of the server.
  • Gateway IP Address. 4 bytes. routes DHCP messages between different networks. this facilitate DHCP communication between different subnets or networks.
  • Client Hardware Address. 16 bytes. the Physical layer address of the client.
  • Server Name. 64 bytes. a server sending DHCPACK or DHCPOFFER message may include its name in this field. the name could be its nickname or its DNS domain name.
  • Boot Filename. 128 bytes. optionally, used by a client to request a particular type boot file in a DHCPDISCOVER message. used by a serer to fully specifies a boot file directory and filename in a DHCPOFFER message.
  • Options. variable length. holds some option parameters, used by DHCP. both client and server may use this field.


if a client is configured to acquire its address automatically, it will send a DHCPDISCOVER when it boots or senses an active network connection. because the client has no idea the subnet that it belongs to, it sends the DHCPDISCOVER message as an IP broadcaset (address of 255.255.255.255). the source IP address (the client address) is set to 0.0.0.0. the server notes the Gateway Address of the message sent from the client, if it's undefined then the server knows that the client is on the same subnet as the server. clients send mesages to the server on port 67, servers send messages to the client on port 68.

0 comments:

top