Using AI to Generate Cisco IOS DHCP Configuration Automatically

DHCP configuration is one of those tasks every network engineer knows well. It’s simple in theory—subnet a network, create pools, exclude reserved addresses—but in practice it’s repetitive, time-consuming, and prone to human error when done at scale.



Recently, I experimented with a well-defined AI prompt template to generate Cisco IOS-XR DHCP configurations automatically. The outcome was clean, consistent, and immediately usable in real environments. This article explains the approach, the inputs, and why this method works so well for DHCP use cases.


Why Automate DHCP Configuration?

Even experienced engineers can make mistakes when:

  • Subnetting large address blocks
  • Repeating DHCP pool creation across many subnets
  • Maintaining consistency in excluded IP ranges
  • Following strict configuration standards

Using AI for DHCP configuration helps with:

  • Speed – results in seconds
  • Consistency – uniform pool structure
  • Accuracy – correct subnet math and exclusions
  • Scalability – easy to repeat for large networks

The key is not just using AI—but using it with precise instructions.

The AI Instruction Model

The AI was instructed to behave like a Cisco IOS-XR network engineer and strictly follow these rules

The template includes two main components:

  1. The instruction set serves as the static component of the template. It outlines the procedures, formats, and any rules for the generation of the response.
  2. The variables are the dynamic components. They represent the specific, changeable data points that need to be operated on according to the instruction set in the template.

This approach allows an efficient and scalable way to handle a series of tasks that have a common structure but require different data inputs.

Instruction Template --

You are a Cisco network engineer specialized in Cisco IOSXR operating system.
You will subnet the provided [network] into [subnetworks_mask] subnets and provide DHCP pool configuration for each subnetwork.
Include dns-server in the DHCP pool configurations, use [dns] as the dns-server IP. If [dns] is not defined in the prompt use the IP  208.67.222.222 as the DNS server by default.
Create additional configuration for each pool that will exclude the first [excluded] IP addresses from the pool, provided that the pool is large enough.
Do not include lease time in the generated DHCP pool configuration unless otherwise specified in the input prompt.
The [network] into [subnetwork_mask] will be provided in the following prompts. To which you will only provide the list of generated subnetworks and the generated dhcp pools configuration.
If you can't create a working configuration due to missing, inconsistent or invalid input, report that in a format like this: "Can't Generate configuration: the reason".
Do not create DHCP pools for subnetworks with mask /30 or smaller.
IMPORTANT: do not provide descriptions, do not discuss the solution, do not provide step-by-step instructions. Return only the generated code.



ChatGPT Instruction -- 

Providing the asked inputs to the ChatGPT for generate the configuration -- 



Output after providing the information 


Generated configuration we got from ChatGPT will be like this. Which is good enough to save your time and help to get it done within 5 minutes.

Input Provided

Network : 10.20.0.0/22 Subnet mask : 255.255.255.128 (/25) Excluded IPs : 10 (first usable addresses) DNS server : Not specified default used

Default DNS server applied:

208.67.222.222

Generated Subnetworks

The /22 network was correctly divided into eight /25 subnetworks:

10.20.0.0/25 10.20.0.128/25 10.20.1.0/25 10.20.1.128/25 10.20.2.0/25 10.20.2.128/25 10.20.3.0/25 10.20.3.128/25

Each subnet is suitable for DHCP pool creation and meets the size requirement.

Sample Cisco IOS-XR DHCP Pool Configuration

Below is an example of one generated DHCP pool:

dhcp ipv4 pool NET_10_20_0_0_25 network 10.20.0.0 255.255.255.128 dns-server 208.67.222.222 excluded-address 10.20.0.1 10.20.0.10 !

The same structure was consistently applied to all subnetworks

  • Correct network and mask
  • First 10 usable IPs excluded
  • Default DNS server included
  • Clean and predictable pool naming
  • No lease time configured


Why This Works Well for DHCP Configuration

1. Consistency Across Subnets

Every DHCP pool follows the same structure, eliminating configuration drift.

2. Time Savings

Subnet calculation and DHCP pool creation that typically takes several minutes is reduced to seconds.

3. Reduced Human Error

The AI handles subnet math, address exclusion ranges, and formatting accurately.

4. Easy to Scale

This approach works just as well for:

  • Large address blocks
  • Multi-site environments
  • Lab and test networks
  • Enterprise and service provider DHCP designs

Practical Use Cases

  • Enterprise DHCP pool creation
  • Branch and campus network designs
  • Lab automation
  • Network documentation
  • Standardized DHCP deployments









Post a Comment

Previous Post Next Post