In this lab we'll start off with the simple topology of 2 routers
router 1 and router 2
what we'll do here, is configure router 2 as the DHCP server
and we'll configure router 1 as the DHCP client in this topology.
No configuration has been done on this routers.
At the moment as an example, on router 2, sh ip int brief
shows me that all the interfaces are currently down
no IP addresses has been configured.
So the first thing I’m gonna do is go on to the FastEthernet interface
and configure an IP address of 10.1.1.2/24 mask.
I'll no shut that interface and now I'll configure the router as the DHCP server.
So to configure the DHCP server, the first thing you need to do is type ip dhcp
that gives you a range of options but the one that we're looking for is pool
so pool, and then we specify a name such as clients, as an example.
This is just the name, to uniquely identify the pool that you're creating
and that’s because you can have multiple pools configured on a router.
Network, we need to specify the network that devices will be allocated addresses from
now it's important that the IP address that DHCP requests are being received on.
Which in this example a F0/0 be in the same subnet as the network.
Otherwise the router is not gonna allocate addresses from the pool.
So this interface is configured with an IP address of 10.1.1.2
and we are configuring a network of 10.1.1.0/24
there are many options available in the pool.
We’ve already configured the network and mask.
Next option, you'll probably want to configure is default gateway or default router.
I’m gonna set that to router 2.
You'd also want to specify options such as DNS server.
In this example, I'll configure the router as DNS server
but typically what your going to do here
is configure a real DNS server somewhere in your topology.
So I'll just configure a single DNS server being the local router.
You can specify how long addresses are allocated to hosts, the default is 1 day
I’m gonna specify lease time of 7 days.
Now for devices such as IP phones, you can specify different DHCP option codes.
150 is TFTP and I’m gonna specify an IP address of a TFTP server.
Now in the real implementation, your IP telephones will get their configuration
typically from a Cisco Unified Communications Manager
or from a Cisco Unified Communications Manager's express router.
So this would be the IP address of the Cisco communications manager.
In our example once again, I’m just gonna set that to the local router.
Now to stop conflicts, an allocation of addresses that belong to servers and routers
Use the command ip dhcp excluded-address
and you specify a range of addresses to exclude from allocation to devices.
Now my router has an IP address of 10.1.1.2
I don’t want the router to allocate its own IP address to host devices.
So I’m going to set the exclusion range to include the router's IP address
and some extra IP addresses here, that would typically be determined
by how many servers or other devices are going to have IP addresses statically configured.
sh run will show me my configuration.
So it’s quite a simple config, I’ve got my exclusion range
I’ve created a pool called clients.
Clients will be allocated addresses in this IP address subnet.
Default router is router 2, the local router.
DNS server is set to that and option 150 is set to that as well.
Once again typically, this will be set to servers in your live network.
I’ve set the lease to 7 days, the default is 1 day.
show ip dhcp gives me different options, including pool.
This can be useful because sometimes you can make a typing mistake
and you may exclude all of your addresses.
But notice here, total addresses is 254, lease addresses is 0
no addresses have been leased, address range is in this range.
Let’s look at bindings, of any address has been allocated
at the moment no addresses has been allocated.
So let’s go to the client
I’m gonna change the MAC address of this client, to something very simple
so that we can read it in the output
so MAC address is gonna be A,B,C
IP address is gonna be set to DHCP
so the PC will request an IP address from the server
when I type no shut show debug
lets run a debug so we can see what’s happening
debug ip dhcp server and we have different options
I’m gonna go for packet, which shows me lots of detail.
So debug ip dhcp server packet now when I hit no shut
we should start seeing requests from the client, to the DHCP server and there we go
we've got a DHCP discover message, received from the client on interface FastEthernet 0/0
The DHCP server will allocate an address without class information
we didn’t configure a name or class for this device.
The DHCP servers offering an address to the client, offering it this IP address
and then sending the reply to the MAC address of the PC that we configured, so that MAC address.
The client then requests that IP address from the DHCP server
DHCP server sents back an acknowledgement.
So sh ip int brief FastEthernet 0/0 on router 1
has been allocated to this address through DHCP
sh ip route the router has learnt about the gateway of last resort
because we've configured a default gateway or default router in the DHCP pool.
So router 1 has learnt about that network
and a static default router has been added to the routing table.
It’s a simple as that to configure a basic DHCP server on the Cisco router
and allocate addresses to client devices.
to actually view the messages sent between the client and the server.