Dec 4, 2009

Configure DHCP on a Cisco router or switch

Takeaway: Many administrators forget—or don't even realize—that they can configure Dynamic Host Configuration Protocol (DHCP) on Cisco IOS routers and switches. David Davis discusses the pros and cons of this option, and he walks you through the configuration process.
If you want to configure Dynamic Host Configuration Protocol (DHCP) on PC clients, you currently have multiple options to choose for your DHCP server. One of the more common ways to accomplish this is by using a Windows or Linux server. However, most home networks get DHCP from their DSL or cable router.
Many administrators forget—or don't even realize—that DHCP is also available on Cisco IOS routers and switches. Keep in mind that DHCP is only available on newer IOS-based switches. For example, Catalyst 3550 and 3750 offer DHCP.

Getting started

Let's look at how to configure basic DHCP on an IOS-based router. For this example, we'll start off with the default configuration on a Cisco 2611 router running IOS 12.2. (The configuration should be the same—or very similar—on all IOS-based routers).
To begin, connect the router's Ethernet port to a switch, and connect the switch to a laptop, which will serve as the DHCP client.
To configure Cisco IOS DHCP, follow these steps, which include sample commands:
1.              Configure an IP address on the router's Ethernet port, and bring up the interface. (On an existing router, you would have already done this.)
Router(config)# interface ethernet0/0

Router(config-if)#ip address

Router(config-if)# no shutdown
2.              Create a DHCP IP address pool for the IP addresses you want to use.
Router(config)# ip dhcp pool mypool
3.              Specify the network and subnet for the addresses you want to use from the pool.
Router(dhcp-config)# network /8   
4.              Specify the DNS domain name for the clients.
5.              Specify the primary and secondary DNS servers.
6.              Specify the default router (i.e., default gateway).
7.              Specify the lease duration for the addresses you're using from the pool.
Router(dhcp-config)#lease 7
8.              Exit Pool Configuration Mode.
This takes you back to the global configuration prompt. Next, exclude any addresses in the pool range that you don't want to hand out.
For example, let's say that you've decided that all IP addresses up to .100 will be for static IP devices such as servers and printers. All IP addresses above .100 will be available in the pool for DHCP clients.
Here's an example of how to exclude IP addresses .100 and below:
Router(config)#ip dhcp excluded-address
Next, enter the ipconfig /renew command on the laptop to receive an IP address. After you have the IP address, enter the ipconfig /all command. 

Using DHCP commands

After configuring DHCP on the router, you can use DHCP show commands to see what's going on. For example, you can use one of the most common DHCP commands to view which DHCP IP addresses currently have leases: show ip dhcp bindings.
Keep in mind that DHCP configuration can be very complex on Cisco routers. You can configure backup servers, settings to prevent conflicts, secure DHCP, and many other options.


Post a Comment