Chapter 7: Day 0 Provisioning and Zero-Touch Deployment

Learning Objectives

Section 1: Day 0 Provisioning Concepts — Knowledge Check

Before reading this section, answer these questions to assess your existing understanding.

Pre-Quiz — Section 1: Day 0 Provisioning Concepts

1. In the Day 0/1/2 framework, which activities fall within the Day 0 phase?

2. Which DHCP option is the primary trigger that causes an IOS XE device to initiate Zero-Touch Provisioning?

3. What single condition must be met for a Cisco IOS XE device to automatically enter ZTP or PnP mode?

4. What is the key architectural difference between ZTP and PnP provisioning?

5. Which business driver is best addressed by Day 0 automation's use of version-controlled templates?

1.1 The Day 0/1/2 Framework

Network automation practitioners divide the device lifecycle into three operational phases. Day 0 covers initial boot and onboarding with no existing configuration — assigning IP addresses, hostnames, AAA credentials, and management access. Day 1 handles post-onboarding service configuration such as routing protocols, VLANs, and QoS. Day 2 governs ongoing lifecycle management: drift correction, software upgrades, and telemetry.

PhaseTimingScopeExample Activities
Day 0Initial boot, no configOnboarding and baselineIP assignment, hostname, AAA, SSH, image verification
Day 1Post-onboarding, pre-productionService configurationRouting protocols, VLANs, QoS, security profiles
Day 2Ongoing operationsLifecycle managementDrift correction, upgrades, telemetry collection
flowchart TD A([Device Ships from Factory\nNo Configuration]) --> B subgraph D0["Day 0 — Onboarding"] B[Power On\nNo Startup Config] --> C[DHCP Discovery] C --> D{ZTP or PnP?} D -->|Option 67| E[ZTP: Download and Run\nPython Script] D -->|Option 43 / DNS| F[PnP: Register with\nCatalyst Center] E --> G[Base Config Applied\nHostname · Mgmt IP · AAA · SSH] F --> G end G --> H subgraph D1["Day 1 — Service Configuration"] H[Push Service Config\nVLANs · Routing · QoS · Security] end H --> I subgraph D2["Day 2 — Lifecycle Management"] I[Ongoing Operations\nDrift Correction · Upgrades · Telemetry] end style D0 fill:#e8f4f8,stroke:#2980b9 style D1 fill:#eafaf1,stroke:#27ae60 style D2 fill:#fef9e7,stroke:#f39c12

1.2 Business Case for Automated Provisioning

Scale: Enterprise refresh cycles routinely deploy hundreds of devices per quarter. Manual provisioning at this rate consumes engineering time that adds no architectural value. Consistency: Automation enforces a single, version-controlled template — two engineers configuring the same device type no longer produce subtly different results. Speed: A device provisioned via ZTP or PnP is fully configured within minutes of first power-on vs. thirty-to-sixty minutes manually. Auditability: Automated provisioning creates a complete record of what configuration was applied, when, and from which template version.

1.3 Provisioning Architecture Overview

Both ZTP and PnP share a common pattern: a device with no configuration reaches out to infrastructure that delivers configuration to it. ZTP is infrastructure-centric — the device downloads and executes a Python script from an HTTP/TFTP server with no external controller needed. PnP is controller-centric — the device discovers Cisco Catalyst Center and receives configuration through a managed workflow.

Key Points — Section 1

Section 2: IOS XE Zero-Touch Provisioning (ZTP)

Pre-Quiz — Section 2: IOS XE Zero-Touch Provisioning

1. In what environment does the ZTP Python script execute on an IOS XE device?

2. Which Python module pair is used to apply multi-line configuration to an IOS XE device from within a ZTP script?

3. What is the correct syntax for specifying DHCP Option 67 on an IOS DHCP pool to point to a ZTP script at 192.168.1.1?

4. What happens if a ZTP Python script completes successfully but never calls cli.executep("write memory")?

5. Since IOS XE 16.8, why does a booting device alternate its DHCP Client Identifier (Option 61) between its serial number and management MAC address?

2.1 How ZTP Works: The Complete Workflow

ZTP is triggered when an IOS XE device boots and finds no startup configuration. The device sends DHCP Discover messages on the management interface (Gi0) and all front-panel data ports simultaneously. If the DHCP response includes Option 67 (the bootfile-name option containing a URL), ZTP activates automatically. The device downloads the Python script from that URL via HTTP or TFTP, starts Guest Shell, and executes the script inside it.

Animation: ZTP Boot Sequence
1. Device boots — no startup-config detected
2. DHCP Discover sent on Gi0 + all ports
3. DHCP Offer received with Option 67 URL
4. Device downloads ztp.py via HTTP/TFTP
5. Guest Shell container starts automatically
6. ztp.py executes — cli.configurep() called
7. write memory — startup-config saved
Device fully configured — ready for Day 1
sequenceDiagram participant Dev as IOS XE Device participant DHCP as DHCP Server (Option 67) participant HTTP as HTTP Server (ztp.py) participant GS as Guest Shell Dev->>DHCP: DHCP Discover (Gi0 + all ports) DHCP-->>Dev: DHCP Offer — IP lease + Option 67 URL Note over Dev: Option 67 detected — ZTP activates Dev->>HTTP: GET /ztp.py HTTP-->>Dev: 200 OK — Python script payload Note over Dev: IOS XE initializes Guest Shell Dev->>GS: Start container, mount IOS XE CLI GS-->>Dev: Guest Shell ready Dev->>GS: Execute ztp.py GS->>GS: get_serial() via show version GS->>GS: cli.configurep(base_config) GS->>GS: cli.executep("write memory") GS-->>Dev: Script complete — startup-config written Note over Dev: Device ready for Day 1 automation

2.2 Guest Shell Execution Environment

Guest Shell is a CentOS-based Linux container embedded in IOS XE. It starts automatically during ZTP — no operator intervention is needed. It has network access through the device management interface, can make outbound HTTP/HTTPS calls, install Python packages, and exposes the IOS XE CLI through Python modules. Its isolation means a poorly written script cannot crash the switch OS. The ZTP script file (ztp.py) is typically hosted at /var/www/html/ on an Apache HTTP server.

2.3 Python CLI Modules

Module PairModePurpose
cli.cli / cli.clipExecRun show commands, returns string output
cli.execute / cli.executepExecRun exec-mode commands (e.g., write memory)
cli.configure / cli.configurepConfigApply configuration via configure terminal

2.4 DHCP Option 67 Configuration

Option 67 is the single required DHCP option for ZTP. On a Cisco IOS DHCP pool:

ip dhcp pool ZTP_POOL
 network 192.168.69.0 255.255.255.0
 default-router 192.168.69.1
 dns-server 8.8.8.8
 option 67 ascii http://192.168.69.1/ztp.py

On ISC DHCP (/etc/dhcp/dhcpd.conf), the equivalent is option bootfile-name "http://192.168.69.1/ztp.py";. Option 150 (TFTP Server Address) is supplementary and not required for ZTP to function.

2.5 ZTP Script Best Practices

A production ZTP script should: extract the serial number for dynamic hostname generation, configure SSH and disable Telnet, enable NETCONF/RESTCONF for subsequent Day 1 automation, use algorithm-type scrypt for password hashing, and always call cli.executep("write memory") to persist the configuration across reboots. Write scripts to be idempotent — safe to run multiple times without causing configuration damage.

Key Points — Section 2: IOS XE ZTP

Post-Quiz — Section 2: IOS XE Zero-Touch Provisioning

1. In what environment does the ZTP Python script execute on an IOS XE device?

2. Which Python module pair is used to apply multi-line configuration to an IOS XE device from within a ZTP script?

3. What is the correct syntax for specifying DHCP Option 67 on an IOS DHCP pool to point to a ZTP script at 192.168.1.1?

4. What happens if a ZTP Python script completes successfully but never calls cli.executep("write memory")?

5. Since IOS XE 16.8, why does a booting device alternate its DHCP Client Identifier (Option 61) between its serial number and management MAC address?

Section 3: Cisco Plug and Play (PnP)

Pre-Quiz — Section 3: Cisco Plug and Play (PnP)

1. What is the correct ASCII string format for DHCP Option 43 pointing a PnP device to Catalyst Center at 10.10.20.85 on HTTPS port 443?

2. In what order does a PnP-capable device attempt to discover Catalyst Center if DHCP Option 43 is not present?

3. What IOS XE command must be configured on an upstream switch to steer unconfigured devices into a specific management VLAN (e.g., VLAN 100) for PnP discovery?

4. Which DHCP option does a PnP-capable device include in its Discover message to signal that the server should return Option 43?

5. What PnP device state indicates that a device has connected to the network and established a link to Catalyst Center, but no site or template has been assigned to it yet?

3.1 PnP Architecture and Core Components

Cisco Plug and Play is a controller-driven provisioning solution. Instead of executing a locally downloaded script, an unconfigured device discovers and registers with Cisco Catalyst Center (formerly DNA Center), which orchestrates the entire onboarding workflow from a central management plane. Four components make up the solution: the on-device PnP Agent (embedded in firmware, no pre-installation needed), the PnP Server (Catalyst Center), the PnP Protocol (HTTPS-based communication), and optionally PnP Connect — Cisco's cloud redirect service at devicehelper.cisco.com.

3.2 The Four Discovery Methods

PriorityMethodMechanismRequirement
1DHCP Option 43Server returns controller IP in Option 43DHCP server configured with Option 43
2DNS LookupDevice resolves pnpserver.<domain>DNS A record pointing to Catalyst Center
3PnP Connect (Cloud)Contact devicehelper.cisco.comValid Cisco contract; device registered at software.cisco.com
4USB KeyBootstrap config on USB drivePhysical USB preparation

The DNS method is elegant at scale: add a single A record pnpserver.corp.example.com pointing to Catalyst Center and every new device in that domain finds its controller automatically — no DHCP modifications needed.

flowchart TD A([Device Boots - No Startup Config - PnP Agent Activates]) --> B B[Send DHCP Discover with Option 60 ciscopnp] --> C{Option 43 in DHCP response?} C -->|Yes| Z[Connect to Catalyst Center via Option 43 IP] C -->|No| D[Resolve pnpserver.domain via DHCP domain name] D --> E{DNS A record exists?} E -->|Yes| Z E -->|No| F[Contact devicehelper.cisco.com] F --> G{Device registered at software.cisco.com?} G -->|Yes| H[Cloud redirects to on-premises Catalyst Center] H --> Z G -->|No| I[Check for USB Key with bootstrap config] I --> J{USB config found?} J -->|Yes| K[Apply USB bootstrap configuration] J -->|No| L([Discovery Failed - Retry or Manual Intervention]) Z --> M([PnP Agent Registers with Catalyst Center]) style Z fill:#eafaf1,stroke:#27ae60 style L fill:#fdedec,stroke:#e74c3c

3.3 DHCP Option 43 Format

Option 60 in the device's DHCP Discover (value "ciscopnp") signals the server to return Option 43. The Option 43 ASCII string uses a structured format:

5A1N;B2;K4;I10.10.20.85;J443
FieldValueMeaning
5A1NProtocol versionPnP protocol identifier
B2Address type1 = FQDN, 2 = IPv4 address
K4Transport type4 = HTTPS, 5 = HTTP
I<IP>Controller addressIP or FQDN of Catalyst Center
J443Port80 = HTTP, 443 = HTTPS

3.4 PnP Device States

Animation: PnP Device State Transitions
Planned
Unclaimed
Onboarding
Provisioned
Error
Click Play to walk through PnP device states
stateDiagram-v2 [*] --> Planned : Serial pre-registered via REST API Planned --> Unclaimed : Device powers on and connects to network [*] --> Unclaimed : Device connects (not pre-registered) Unclaimed --> Onboarding : Operator claims device, assigns site and template Onboarding --> Provisioned : Day 0 config pushed, device applies and re-registers Provisioned --> [*] : Device moves to managed inventory Onboarding --> Error : Provisioning failure (template error, connectivity loss) Unclaimed --> Error : Discovery failure (DHCP/DNS/cloud unreachable) Error --> Unclaimed : Issue resolved, device retries

3.5 Critical Infrastructure Prerequisites

Two prerequisites are most commonly overlooked in PnP deployments:

Key Points — Section 3: Cisco PnP

Post-Quiz — Section 3: Cisco Plug and Play (PnP)

1. What is the correct ASCII string format for DHCP Option 43 pointing a PnP device to Catalyst Center at 10.10.20.85 on HTTPS port 443?

2. In what order does a PnP-capable device attempt to discover Catalyst Center if DHCP Option 43 is not present?

3. What IOS XE command must be configured on an upstream switch to steer unconfigured devices into a specific management VLAN (e.g., VLAN 100) for PnP discovery?

4. Which DHCP option does a PnP-capable device include in its Discover message to signal that the server should return Option 43?

5. What PnP device state indicates that a device has connected to the network and established a link to Catalyst Center, but no site or template has been assigned to it yet?

Section 4: Building Complete Provisioning Workflows

Pre-Quiz — Section 4: Complete Provisioning Workflows

1. Which scaling best practice is most important when rolling out 200 new switches across a campus in a single morning?

2. In a Jinja2 PnP template, how are per-device variable values such as hostname and management IP differentiated from static policy configuration?

3. A troubleshooting engineer finds a device that runs the ZTP script successfully but always loses its configuration after a reload. What is the most likely cause?

4. Which security measure is specifically recommended to prevent a malicious actor from replacing your ZTP configuration script during the provisioning process?

5. An organization uses ZTP to provision initial management connectivity at remote sites, then relies on a second mechanism to complete Day 1 service configuration. What is this approach called?

4.1 Infrastructure Bill of Materials

Minimum ZTP Infrastructure:

ComponentRoleExample
DHCP ServerIssues Option 67 to booting devicesISC DHCP on Linux, or IOS DHCP pool
HTTP ServerHosts ztp.pyApache on Ubuntu Server
Python ScriptConfigures the deviceCustom ztp.py per device role
Network ReachabilityDevice must reach DHCP/HTTP at bootDHCP relay or L2 adjacency

Minimum PnP Infrastructure:

ComponentRoleExample
Catalyst CenterPnP server and orchestratorPhysical or virtual appliance
DHCP ServerIssues Option 43 to booting devicesISC DHCP, IOS, or Windows DHCP
DNS ServerResolves pnpserver.<domain>BIND, Windows DNS, Infoblox
Network ReachabilityDevice must reach DHCP and Catalyst CenterDHCP relay on access uplinks

4.2 ZTP vs. PnP: Choosing the Right Tool

flowchart TD subgraph ZTP["ZTP Architecture — No Controller Required"] direction TB Z1[New IOS XE Device\nno config] -->|DHCP Discover| Z2[DHCP Server\nOption 67: URL] Z2 -->|IP lease + script URL| Z1 Z1 -->|GET /ztp.py| Z3[HTTP / TFTP Server] Z3 -->|Python script| Z1 Z1 --> Z4[Guest Shell\nExecutes ztp.py] Z4 --> Z5([Device Configured\nNo external controller]) end subgraph PNP["PnP Architecture — Controller-Driven"] direction TB P1[New IOS XE Device\nno config] -->|DHCP Discover\nOption 60: ciscopnp| P2[DHCP Server\nOption 43: CC IP] P2 -->|IP lease + CC address| P1 P1 -->|HTTPS registration| P3[Catalyst Center\nPnP Server] P3 -->|Day 0 template| P1 P3 <-->|REST API\nBulk pre-registration| P4[Automation Scripts] P1 --> P5([Device Provisioned\nManaged inventory]) end style ZTP fill:#e8f4f8,stroke:#2980b9 style PNP fill:#eafaf1,stroke:#27ae60

4.3 Scaling Best Practices

4.4 Common Troubleshooting

SymptomLikely CauseResolution
Device does not enter ZTPExisting startup-config presenterase startup-config + reload
DHCP received but no script downloadOption 67 URL unreachableVerify HTTP server running; check routing
Script runs but config not appliedPython CLI error in scriptTest interactively in Guest Shell
Script completes but config lost after reloadwrite memory not calledAdd cli.executep("write memory")
PnP device stuck in UnclaimedNo site/template assignedClaim device in Catalyst Center; check pre-registration

Key Points — Section 4: Workflows and Best Practices

Post-Quiz — Section 4: Complete Provisioning Workflows

1. Which scaling best practice is most important when rolling out 200 new switches across a campus in a single morning?

2. In a Jinja2 PnP template, how are per-device variable values such as hostname and management IP differentiated from static policy configuration?

3. A troubleshooting engineer finds a device that runs the ZTP script successfully but always loses its configuration after a reload. What is the most likely cause?

4. Which security measure is specifically recommended to prevent a malicious actor from replacing your ZTP configuration script during the provisioning process?

5. An organization uses ZTP to provision initial management connectivity at remote sites, then relies on a second mechanism to complete Day 1 service configuration. What is this approach called?

Post-Quiz — Section 1: Day 0 Provisioning Concepts

1. In the Day 0/1/2 framework, which activities fall within the Day 0 phase?

2. Which DHCP option is the primary trigger that causes an IOS XE device to initiate Zero-Touch Provisioning?

3. What single condition must be met for a Cisco IOS XE device to automatically enter ZTP or PnP mode?

4. What is the key architectural difference between ZTP and PnP provisioning?

5. Which business driver is best addressed by Day 0 automation's use of version-controlled templates?

Your Progress

Answer Explanations