cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
997
Views
25
Helpful
6
Replies

Activate DHCP Service on cisco Switch only when main DHCP Server is down

rabiejenniat
Level 1
Level 1

Hello Dear Community,

 

i have crated a small test topology where i have a main DHCP Server connected to a Switch(

WS-C2960-24TT), on the same Switch there are 4 devices connected and are set to ask DHCP for IP address.

what i am trying to reach:

1- i would like the 4 connected devices to get their IP addresses from the main DHCP Server as long as it is online, but at the same time the Switch should be on stand-by so that it takes over the role as DHCP only when the main DHCP Server is down

2- some specific devices should always get the same IP address whether it's from the main DHCP Server or the Switch.

 

What i have tried:

i configured the DHCP Service on the Switch and created a reservation for a specific MAC-Address, i created dedicated pool, with a single IP address, for each reservation.

 

The problem:

when the DHCP Service on the Switch is activated it takes over the role of DHCP even though the main DHCP Server is still available .

 

i have done a lot of research but i couldn't find a solution, i hope there is one, at least if not on packet tracer then in real life!

 

thank you for any help

 

 

6 Replies 6

Jon Marshall
Hall of Fame
Hall of Fame

 

If you want redundant DHCP servers it is usually best to use the same type of devices ie. two windows servers, two switches etc. 

 

Also generally speaking the first DHCP server to respond will be used and that is probably going to be the switch in this case. 

 

A common setup is two DHCP servers and you split each scope between each server so each server hands out half the scope and you have enough IPs in half the scope for all the clients, that way you have redundancy. 

 

Trying to activate a DHCP server when another has gone down is not really a recommended way of doing things. 

 

Jon

Thank you for replying,

 

i know it is not best practice and i have thought about setting up two DHCP servers and split the scope or configuring DHCP-Failover but i am looking for an unusal/cost cutting solution with minimum hardware requirements!

since logically speaking the first DHCP server to respond will be used does this mean it is not possible?

 

Rj

I agree with the points made by @Jon Marshall and agree that switch as backup server for DHCP is not a preferable approach. But the original poster asks about how to have the switch be used for DHCP only when the primary DHCP server is not active and I will try to address that question. Perhaps some type of EEM script could be used. Probably one EEM script to detect when the primary DHCP is not in service and to activate DHCP on the switch and a second EEM script to detect when the primary DHCP is back in service and to stop DHCP on the switch would accomplish the objective.

 

But having made that suggestion let me also acknowledge several difficulties with it:

- what would the logic be for EEM to detect that the primary DHCP has just gone down and that the switch should activate? And what would be the logic to detect that the primary DHCP has become active and that DHCP on the switch should be stopped?

- when DHCP is activated on the switch it would not know what addresses had been assigned by the primary DHCP and were active in the network. So the switch would begin to assign addresses, probably starting at the beginning of the pool. The result is likely to be address conflicts between the device whose IP was assigned by the primary server and the device whose IP ass assigned by the switch.

 

Bottom line: I do not believe that there is a really satisfactory solution to have the switch provide DHCP only when the primary DHCP server is out of service. 

HTH

Rick

Thank you for your reply,

 

an EEM script sounds exactly like what i'm asking for, i have a small question consedring the address conflicts between the device whose IP was assigned by the primary server and the device whose IP was assigned by the switch, (please correct me if i'm wrong) the devices with reserved IP addresses would not be part of the address conflict, this leaves us with the devices that don't need a specific IP address to be assigned to them, wouldn't they wait until their leases are over to ask the switch for a new IP address?

 

Rj

 

The main problem would be your DHCP server has handed out an IP to a client and then that DHCP server fails. 

 

A device boots up and is handed the same IP from the newly active server because that server does not know which IPs are in use and now you have conflicts. 

 

I am all in favour of automating things where possible but honestly some things should not really be scripted especially something with as many potential issues as this. 

 

Jon

Rj asks "(please correct me if i'm wrong) the devices with reserved IP addresses would not be part of the address conflict" and I agree that assuming that both servers excluded those IP addresses from the pool and that both servers configured the same static reservations that the devices with reserved addresses would not be part of the conflict. But as Jon correctly points out any device that boots up (and I think any device whose existing lease is about to expire) would face potential address conflicts with devices whose addresses were assigned by the primary server.

 

A possible approach to solving the address conflict issue would be to divide your address pool so that you wind up with 2 non overlapping pools, one to be used by the primary server and one used by the switch. Or if you do not want to divide the existing pool then allocate additional addresses to create the second pool.

HTH

Rick
Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community:

Innovations in Cisco Full Stack Observability - A new webinar from Cisco