Monday, May 18, 2009

DHCP

DHCP automates the assignment of IP addresses to network hosts. DHCP addresses can be allocated:
  • Manually—A specific IP address is assigned to a MAC address.
  • Automatic—An IP address is permanently assigned to a host.
  • Dynamic—The IP address is assigned for a limited amount of time or until the client releases it.

The process of acquiring an IP address from a DHCP server has four
steps:

Step 1. The host broadcasts a DHCPDISCOVER message.
Step 2. The server responds with a DHCPOFFER message containing IP address and optionally other settings.
Step 3. The client broadcasts a DHCPREQUEST message, requesting the offered IP address.
Step 4. The server sends a DHCPACK confirming the address assignment.


Configuring DHCP
Cisco routers can be DHCP clients, servers, or relay agents. To configure an IOS device as a DHCP client, use the ip address dhcp command on the interface that needs to obtain the DHCP address. To configure a router as a DHCP server, you must create an IP address pool and assign a network or subnet to that pool. You can optionally add information, such as default gateway, DNS server, lease duration, or options such as Option 150 for Cisco IP phones. Exclude any static IP addresses within the pool, such as the router’s address. You may also want to identify an external server to hold the DHCP database of IP address bindings.

Cisco routers have an auto-configuration feature that allows the downloading of some DHCP information from a central server. This saves the trouble of configuring every router with complete DHCP information. To do this, one interface on the router must have a DHCP address.

The following example shows a router configured as a DHCP server that imports its domain name, DNS servers, and other information from another DHCP server off interface Gi0/0. The IP address range of 10.6.3.1–10.6.3.5 is excluded from the pool.

Router(config)#ip dhcp excluded-address 10.6.3.1 10.6.3.5
!
Router(config)#ip dhcp pool Gator
Router(dhcp-config)#network 10.6.3.0 /24
Router(dhcp-config)#default-router 10.6.3.1
Router(dhcp-config)#import all
!
Router(config)#int gi 0/0
Router(config-if)#ip address dhcp


DHCP Relay Agent
Hosts discover their DHCP server by sending broadcasts. If that server is on a different subnet, those broadcasts must be routed to the server as unicasts. You can configure a router to relay DHCP messages with the ip helper-address interface command. It is important to understand that this command must be given on the interface that receives the host broadcasts. A Cisco DHCP relay agent functions as follows:

Step 1. A client broadcasts a DHCP request, which is seen by the IOS device (a router, for instance).
Step 2. The router changes the destination address of the packet to the unicast address of the server. It optionally adds option 82 (relay agent option) information.
Step 3. The router sends the unicast packet to the server.
Step 4. The server responds with the IP address and other parameters, such as the default gateway assigned to the client.
Step 5. The router gets the packet from the server, removes any option 82 information, and forwards it to the client.

The ip helper-address command enables the relaying of UDP broadcasts only. By default, eight broadcast types are enabled:
  • Time, port 37
  • TACACS, port 49
  • DNS, port 53
  • BOOTP/DHCP server, port 67
  • BOOTP/DHCP client, port 68
  • TFTP, port 69
  • NetBIOS name service, port 137
  • NetBIOS datagram service, port 138

To disable the forwarding any of these protocols, use the interface command no ip forward-protocol udp port-number. To add UDP protocols to be relayed, use the interface command ip forward-protocol udp port-number.

Verify your DHCP configuration with the commands show ip dhcp database, show ip dhcp server statistics, and show ip dhcp binding. Delete address assignments with the clear ip dhcp binding {address | *} command.

No comments:

Post a Comment