Thursday, May 30, 2019

[Cisco] I wrote a script to easily convert DHCP leases to reservations

Hey, everyone!

As the title indicates, I wrote a Python script that allows you to easily convert a DHCP lease to a reservation on a Cisco IOS device.

I created this script because the manual process of having to create an entirely new DHCP pool for a single host a little inconvenient.

The script is available on my github page.

Here's how it works:


1. Open a command prompt/terminal and run cisco-dhcp-res.py

2. Enter the IP of the device hosting the DHCP pool and credentials to SSH to it.

Enter IP of device hosting DHCP: 10.6.1.1 Username: admin Password: ****** 

3. Select the existing DHCP pool of the target lease to be converted:

Current DHCP pools: Workstations Servers Access_Points Select the DHCP pool for the target lease to convert (case-sensitive): Servers 

Note: This step of selecting the existing DHCP pool is to obtain settings (default-router, domain-name, DHCP options) that will be applied to the reservation pool.

4. Select a lease to convert from a list of current leases.

IP address Client-ID/ Lease expiration Type Hardware address 10.1.1.16 0100.1234.ed33.c4 May 29 2019 05:32 PM Automatic 10.1.1.17 0100.1234.d620.de May 28 2019 09:16 PM Automatic 10.1.1.18 0100.1234.a67f.80 May 29 2019 04:38 PM Automatic Enter the IP of the lease to convert to reservation: 10.1.1.18 

The script will then confirm the creation of your DHCP reservation.

Your DHCP reservation has been created: 10.1.1.68 0140.017a.7072.e4 Infinite Manual 

Please let me know what you think. I hope this is useful to at least one person :)

Thanks!



No comments:

Post a Comment