How to configure DHCP Server on Cisco IOS

Hi Hussein,

This is because the DHCP server will respond with unicast, take a look at the wireshark captures in this post:

https://networklessons.com/network-services/introduction-to-dhcp/

Rene

Hi Rene

How about reserving certain IP addresses and having the Dhcp allocate them automatically to specific hosts on the LAN

Thanks

Andrew

Hi Andrew,

Hereā€™s an example how to do this:

https://networklessons.com/network-services/dhcp-static-binding-on-cisco-ios/

Rene

Many thanks Rene

Hi,

I think you there is conflict between the diagram and the configuration, in the diagram it is written ā€œ.254ā€ as the default gateway, but the config states ā€œ.1ā€ as the default router !

1 Like

Nice explanation Rene.

You are welcome bhargavi

19 posts were merged into an existing topic: How to configure DHCP Server on Cisco IOS

If you have multiple pools configured on a server, which one will it take the address from?

Hello Chris

If you have an interface on a router with an IP address of 192.168.1.1/24 and a DHCP pool of 192.168.1.0 255.255.255.0 then that specific interface will function as the IP address of the DHCP server on the IOS device for that specific subnet. Why? Because the IP address of the interface is found within the range of the DHCP pool.

So lets say you have three interfaces on a router, each with the following IP addresses:

  1. 10.10.10.1/24
  2. 192.168.55.1/25
  3. 172.16.3.129/26

and three dhcp pools configured with the following ranges:

10.10.10.0 255.255.255.0
192.168.55.0 255.255.2555.128
172.16.3.128 255.255.225.192

then you can easily match up which DHCP pool will be offered from which interface. Now if you added a new DHCP pool with the following range:

10.255.255.0 255.255.255.0

then this address pool would not be offered at all, not until an active interface is configured with an IP address within the range of addresses.

I hope this has been helpful!

Laz

Reneā€™,

We were upgrading a customer network recently from a single router to dual router. They had over 200 VoIP phones that needed DHCP addresses. Splitting the pool wouldnā€™t work because if one router went down, youā€™d only have 100 IPs to lease. I did some digging and found a command the allowed us to run DHCP on the routers without any chance of duplicate IP assignments. That command is:

ip dhcp ping packets

What it does it this: Before it leases an IP, it will ping it 2x (by default). If thereā€™s no reply, then it will lease that IP. We set it to ping 3x just to be on the safe side. We have used this at two production sites with no issues. Just wanted to pass this along if you want to include this in your lesson here.

Hello Andy

Thanks for the info! Keep in mind that this ip dhcp ping feature is enabled by default on Cisco IOS DHCP servers. By adjusting this to 3 or more, you are indeed verifying that the address does not exist on the network. This should be applied with care as some devices such as Cisco IP phones, have a control plane policy to either not respond to pings, or rate limit them. Be sure that the devices on the network segment will indeed respond to such test pings from the DHCP server, otherwise you may still get duplicate addresses.

I hope this has been helpful!

Laz

Lazaros, big thanks for that info. I was not aware of those issues. Do you know if that is also true for Polycom phones? Thatā€™s what weā€™re working with at this customerā€™s locations.

What is this recommended way of handling DHCP when you have a dual router location and want to ensure that all phones can grab an IP if one router fails?

Thanks,

Andy

Hello Andy

Iā€™m not sure if this is true of Polycom phones, but it is indeed true of Cisco IP phones. If you ping them from a Cisco device such as a router or a switch. youā€™ll get something like this:

R1#ping 192.168.1.1 repeat 50
Type escape sequence to abort.
Sending 50, 100-byte ICMP Echos to 192.168.1.1, timeout is 2 seconds:
!!!!!!!!!!!!!.!!!!!!!!!!!!!.!!!!!!!!!!!!!.!!!!!!!!
Success rate is 94 percent (47/50), round-trip min/avg/max = 2/4/13 ms

If during a DHCP allocation procedure, it just happens that you coincide with one of those lost pings due to such a policy, you may find that you will indeed give out a duplicate IP address. For each device type, itā€™s a good idea to go to the manufacturer and determine if pings are hindered in any way, and if so, how you can remove or adjust that behaviour as needed.

In the event of a failure, DHCP is not a service that will have an immediate impact on the network. This is because of the fact that there is a lease time on IP addresses that is on the order of hours, days or even weeks. This means that if a DHCP server fails, you have a lot of time to get it back up again before it is needed to renew addresses. Just make sure you have a monitoring system in place to inform you of downed services, otherwise you may find out about your DHCP server failure when IPs are not being renewed. Such a configuration is usually more than sufficient for most implementations.

To provide a completely airtight solution, splitting the pool among backup servers is the best way to go. This would require you to have a DHCP pool twice as large (or three times or four times if you have more than one backup DHCP server) as the number of devices on the network. This way, a backup DHCP server would be able to function indefinitely without address limitations.

Now if this is not possible as in your case, on a network where there are few changes taking place (addition or removal of hosts), such as is the case with an IP telephony deployment, increase the lease time on the DHCP servers to several days or even a week. This will give you more leeway in the event of a DHCP server failure. If a server goes down, you should get it back up within the configured lease time.

For networks where users come and go very often, such as Wi-Fi networks, increasing the lease time is not an option, as this will quickly deplete the available IP addresses in the DHCP server(s). The only option here is to find a way to increase the range of IP addresses that can be given to users. If this is not possible due to IP address allocation issues, consider using a large range of private IP addresses behind a NAT device.

I hope this has been helpful!

Laz

Hi Rene, may I know what is the reason to configure netbios-node-type h-node under the ip dhcp pool? Thanks.

Regards,
Dan

Hello Dan

NetBIOS is a network service providing various services related to the session layer of the OSI model. In particular, one of the services it provides is the name service, which is used by some Windows operating systems to resolve the names of computers in Windows client-server networks.

Cisco devices can be used to provide this name service using the NetBIOS feature. It can be enabled using the netbios-name-server command under the DHCP configuration parameters. You must then indicate the node type, and this is where the command you mention is used. There are four node types, specifically h, m, b, and p. Each one describes the method by which name resolution will take place.

The order in which they gonna try these 3 methods determine the NETBIOS node type:

  1. h-node (hybrid): by default acts like a p-node and if WINS server unavailable then acts as a b-node
  2. m-mode(mixed): by default acts like a b-node and if no success then acts like a p-node
  3. b-node: uses broadcast only
  4. p-node(peer-to-peer):uses WINS only

You can find out more information about these features and how they work in the following documention. These are beyond the scope of current Cisco exams.

I hope this has been helpful!

Laz

Thanks Laz for the explanation, it help a lot. :smile:

1 Like

how to see the default-gateway address in the dhcp offer by the dhcp server ?
show ip dhcp pool
will not show that information

Hello Nicolas

It depends upon what you want to find out. If you have configured a Cisco device to act as the DHCP server, and you want to find out what default gateway has been configured for a particular DHCP pool, then you could take a look at the configuration and see what DHCP pools are created, and what default gateway is configured for each. For example, in the lesson, if you were to display the configuration file using show running-config, you would see including somewhere in the config, the following:

    ip dhcp pool MYPOOL
     network 192.168.12.0 255.255.255.0
     default-router 192.168.12.1
     dns-server 208.67.222.222
     option 150 ip 192.168.12.200

Here you can see that the default router that this server delivers to DHCP clients of this pool is 192.168.12.1. You are correct that the show ip dhcp pool command doesnā€™t show the default gateway, nor does it show other information such as excluded addresses, but it does tell you the number of excluded addresses.

Now if you want to see the configured default gateway received from the DHCP server from the hostā€™s point of view, you simply need to look at the IP configuration parameters it has received. On a Windows machine, you can do this using the ipconfig /all command on the command line.

On a Cisco IOS device configured as a DHCP client, you can see the learned default route in the routing table itself. For more info on how to configure a Cisco IOS device as a DHCP client, take a look at this lesson:

Additional ways to view the default gateway and other information found within DHCP messages, you can use the debug ip dhcp series of debug commands or take a look at captured DHCP messages using Wireshark.

I hope this has been helpful!

Laz

Hey All,

I have a question specifically relating to the DHCP revervations that you can make on IOS. Take for example a network 192.168.0.0/24 with a default router 192.168.0.1. Let us say you only wanted clients to get an address from .50 - .100 and no other addresses.

In most examples the DHCP excluded-address would be like this -

ip dhcp-ecluded address 192.168.0.1 192.168.1.49
ip dhcp-ecluded address 192.168.0.101 192.168.1.254

ip dhcp pool RFC1918-Pool
network 192.168.0.0 /24
default-router 192.168.0.1

However when I was checking Cisco documentation I could only find the following regarding information on reserved subnets:

ā€œThe IP address configured on the router interface is automatically excluded from the DHCP address pool. The DHCP server assumes that all other IP addresses in a DHCP address pool subnet are available for assigning to DHCP clients.ā€

Does this mean our exemptions should be as follows -

ip dhcp-ecluded address 192.168.0.0 192.168.1.49
ip dhcp-ecluded address 192.168.0.100 192.168.1.255

Or would Cisco IOS exclude those? I find the wording not particularly helpful on their documentation.