Image of Cortney & Jeremy

Configuring a DHCP Server on a Cisco Router Running IOS

by Jeremy L. Gaddis on July 15, 2008 · 4 comments

in Networking

Below I’m going to illustrate how to configure a DHCP server on a Cisco router running IOS.

In this example, I have two Cisco 2621xm’s running c2600-ik9s-mz.123-22.bin. Each router’s FastEthernet 0/0 interface is plugged into a Cisco 2950 switch (ports 1 & 2) on the same VLAN.

R1, which has an IP address of 192.168.1.1 (/24), will be our DHCP server. It will be configured to hand out IP addresses in the range from 192.168.1.100 through 192.168.1.254. It will also hand out information identifying itself as the default gateway and DNS server. Our local domain name will be “ciscolab.local”.

Configure R1’s interface

R1# configure terminal
R1(config)# interface fastethernet 0/0
R1(config-if)# ip address 192.168.1.1 255.255.255.0
R1(config-if)# no shutdown
R1(config-if)# exit

Here we see the FastEthernet 0/0 interface coming up…

*Mar 1 00:15:46.306: %LINK-3-UPDOWN: Interface FastEthernet0/0, changed state to up
*Mar 1 00:15:47.308: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up

Exclude addresses from the DHCP pool

Let’s tell the router not to give out the ip addresses from 192.168.1.1 through .99.

R1(config)# ip dhcp excluded-address 192.168.1.1 192.168.1.99

Create the DHCP pool

R1(config)# ip dhcp pool DHCP_POOL
R1(dhcp-config)# network 192.168.1.0 255.255.255.0
R1(dhcp-config)# default-router 192.168.1.1
R1(dhcp-config)# dns-server 192.168.1.1
R1(dhcp-config)# domain-name ciscolab.local
R1(dhcp-config)# end
R1(config)#

Configure the DHCP client on R2

At this point, our work on R1 is done. Now let’s go over to R2, configure the FastEthernet 0/0 interface to use DHCP and bring it up.

R2# configure terminal
R2(config)# interface fastethernet 0/0
R2(config-if)# ip address dhcp
R2(config-if)# no shutdown

We see FastEthernet 0/0 come up.

*Mar 1 00:23:39.746: %LINK-3-UPDOWN: Interface FastEthernet0/0, changed state to up
*Mar 1 00:23:40.748: %LINKPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up

Shortly afterwards, we see that R2 has obtained an IP address.

*Mar 1 00:23:48.985: %DHCP-6-ADDRESS_ASSIGN: Interface FastEthernet0/0 assigned DHCP address 192.168.1.100, mask 255.255.255.0, hostname R2
R2(config-if)# end
R2# show ip interface brief
Interface       IP-Address    OK? Method Status                Protocol
FastEthernet0/0 192.168.1.100 YES DHCP   up                    up
FastEthernet0/0 unassigned    YES unset  administratively down down

Verify connectivity

R2#ping 192.168.1.1

Type escape sequence to abort.
Sending 5, 100-byte ICMP echoes to 192.168.1.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 4/11/16 ms

Success!

Video

You can see a video of the whole process in action here:

{ 4 comments… read them below or add one }

Leave a Comment

Previous post:

Next post: