Recently I was tasked with replacing a Cisco switch that was running as a DHCP (Dynamic Host Configuration Protocol) server. Generally, people use a Windows server to run their DHCP server, but with more people moving to the cloud and maybe not having any servers on premises, running DHCP on a local switch is becoming a more popular option.
Here’s the background…
The client purchased a new Cisco 3650 switch to replace their old Cisco 3560 switch. DHCP on this Cisco switch was already set up to save the database to flash since there were no local servers on site. This was important, because if we were storing the DHCP database on some sort of network-based storage, we could have just pointed our new switch to that same location. This may or may not have worked, as we were upgrading switches and the DHCP database versions were different (note: our old switch was running version 3, our new switch was running version 6, and there were differences in the format of the files). To make this migration as clean as possible, I needed to find a way to migrate the DHCP database.
To prepare, let’s first set up the new switch.
- On your new switch, set up your DHCP server with the same set up and options as on your old switch.
- Connect to a device to your new switch and obtain a lease. This is necessary to build the DHCP database file with at least one record so we can check the format.
- On your new switch, transfer the DHCP database file to your machine. I typically use TFTP for this, but you may also be able to transfer to a USB drive.
Now that we have a copy of the new DHCP database, we can check the formatting and use this as a template for any data changes we need to do to match this format.
Migrating the DHCP database
Time to put the new switch into production and move the DHCP database.
- On the existing switch, run “show ip dhcp database” and verify it states “Agent information is up-to-date”. If it’s not up to date wait until it writes out the most current info. Optionally, you can adjust the write-delay on your “ip dhcp database” configure setting.
- On your old switch, shutdown the DHCP service by running “no service dhcp” from config mode.
- Transfer your existing DHCP database file from the old switch to your machine. Again, I just used TFTP, but you can use whatever method works for you.
- Edit the DHCP database file in a text editor to match the new format.
- On the new switch, shutdown DHCP by running the “no service dhcp” from config mode.
- Transfer your newly modified DHCP database file from your machine to the new switch. Copy this file over the DHCP database file on the new switch.
- On the new switch, start the DHCP service by running “service dhcp” from config mode.
- Verify bindings are loaded by running “show ip dhcp binding”. If they are not, you may have a problem with your DHCP database file format.
- Test DHCP.
If all went well, DHCP should be running and you will not have any issues with DHCP conflicts.
This way worked perfectly for me. You might find others that work better for your particular setup and situation. If this worked or didn’t work for you, or you found another way to migrate the database, please share it in the comments. If you need help with this, give us a call or send an email to email@example.com. We would be happy to assist you with any of your Cisco needs!