Configure DHCP

Configuring DHCP Server
a Cisco router running IOS can be configured as a DHCP server. the steps to configure a Cisco router to be a DHCP server are:
  • step 1. Define a range of addresses that should not be used for address allocation. this could be some static ip addresses assigned to servers or printers, switch management IP address and gateway/router address. the command to specify the excluded addresses are
ip dhcp excluded-address low-addess [high-address]

low-address: the (lowest) address of the reserved address that should not be used for DHCP address allocation.
highest-address: optional, if you want to specify a range of reserved address, this should be the highest address of the range.

a best practice is to configure these reserved addresses first at the global configuration level to prevent DHCP assigns these reserved addresses accidentally.

  • step 2. create a DHCP pool. using the command
ip dhcp pool pool-name

pool-name : the name of the pool te be created.

after entering the command, you'll be at the DHCP configuration level. at this configuration level you can configure specifics of the pool

  • step 3. configure the specifics of the pool. here you need to configure the network address the pool is assigned to, and the gateway address of the network. to define the network of the pool use the command
network network-number {mask | /prefix-length}

network-number : the network address
mask : subnet mask of the address

to define a default gateway for the network enter the following command
default-router address {address2 .. address8}

typically the gateway address is the address of the router's LAN interface connected to the network. at least one address is required but you can list up to eight addresses.
there are some optional configurations for the DHCP pool. some of those optional commands are
  •  define DNS server
dns-server address {address2 .. address8}
  • define the domain name
domain-name domain
  • define the duration of the lease
lease { days [hours] [minutes] | infinite }
  • define the NetBIOS WINS server
netbios-name-server address {address2 .. address8}



here is an example to configure DHCP for network 192.168.10.0/24. with 192.168.10.1 - 192.168.10.10 and 192.168.10.100 addresses should not be used in DHCP address allocation. here we create a DHCP pool named "pool1"

ip dhcp excluded-address 192.168.10.1 192.168.10.10
ip dhcp excluded-address 192.168.10.100
ip dhcp pool pool1
network 192.168.10.0 255.255.255.0
default-router 192.168.10.1
end


to verify the DHCP configuration you can use the command "show ip dhcp binding" at privileged EXEC mode. it will show information of current bindings of the addresses in the pool to clients. use the command "show ip dhcp server" to see DHCP statistic and message received/sent by the server. to see information of the pools that have been created use the command "show ip dhcp pool".

administrators can also specify which MAC addresses to service and assign them the same address everytime they boot.

DHCP services can be disabled with the command "no service dhcp". reenable it with the command "service dhcp".

you can also configure a router to be a DHCP server using SDM. click the configure tab, in the task list. click the DHCP folder > DHCP pool and click the add button. a dialog box will appear with some text-fields that you can fill in to specify the pool parameters such as the pool's name, pool network, starting and ending address of the pool, lease time, etc.. when you've finished specifying the parameters, klik the ok button. SDM automatically exclude IP address used by the interface connected to the LAN of the pool.

Configure DHCP Client
sometimes, Cisco routers on a SOHO network needs to get its IP address automatically assigned by the ISP. this could be done, by using the command "ip address dhcp" at the interface that should get its address from a DHCP server.
example, a cisco router is connected to an ISP through the interface Serial0/0/0. ISP will automatically assign this interface an address, so this interface address should not be configured manually. the commands are
interface serial0/0/0
ip address dhcp
no shutdown


DHCP Relay
in most enterprise environments, servers are located in a seperate network (the server farm) including the DHCP server. a problem arise as when a client need an address from a DHCP server on a seperate network. DHCPDISCOVER message is a broadcast message and a router won't forward the message to any other network. (this problem is not specific only to DHCP service, some other services use broadcasts. Cisco routers and other devices use broadcast to locate a TFTP server or an authentication server, eg TACACS server).
the problem can be solve by configuring intervening routers and switches to act as a DHCP relay agent with the Cisco IOS helper address feature. this enable routers to forward DHCP messages to the DHCP servers. to configure a router as a relay agent, use the following command at the interface receiving the broadcast (nearest/directly connected to the client)
ip helper-address forward-address

forward-address : an ip address to which broadcasts will be forwarded.

using that command, broadcasts received at the interface will be forwarded to the specified address as a unicast.

example, host1 on subnet 192.168.10.0 needs to renew its address from a DHCP server on subnet 192.168.20.0. both devices are seperated by a router. host1 (subnet 192.168.10.0) is connected to the router by the FastEthernet0/0 interface. the DHCP server address is 192.168.20.254. assume that you're at the global configuration level of the router. enter the following commands at the router.
interface FastEthernet0/0
ip helper-address 192.168.20.254


as default, ip helper-address forward the follwoing eight UDP services:
  • Port 37: time
  • Port 49: TACACS
  • Port 53: DNS
  • Port 67: DHCP/BOOTP client
  • Port 68: DHCP/BOOTP server
  • Port 69: TFTP
  • Port 137: NetBIOS name service
  • Port 138: NetBIOS datagram service

to add additional services to be forwarded use the command "ip forward-protocol".

0 comments:

top