Arista EOS Zero-Touch Provisioning (ZTP): A Practical Guide - 夜莺博客

Arista EOS Zero-Touch Provisioning (ZTP): A Practical Guide

Zero-Touch Provisioning (ZTP) is how Arista EOS switches deploy themselves: plug a new switch into the network, and it automatically discovers a provisioning server, downloads its configuration (and even a new EOS image), and comes up ready for production - no console session, no USB stick. For teams deploying dozens of leaf switches, ZTP turns hours of rack-and-config work into minutes. This guide explains how EOS ZTP works, what your DHCP server must provide, what the provisioning script does, and how to disable ZTP on devices you want to configure manually.

How EOS ZTP Works

When an EOS switch boots without a startup configuration, it enters ZTP mode and acts as a DHCP client. The provisioning flow is:

  1. The switch sends DHCP requests on all front-panel interfaces.
  2. The DHCP server responds with a bootfile (DHCP option 67) or TFTP server (option 66).
  3. The switch downloads the bootfile - a shell script - via TFTP/HTTP/FTP.
  4. The script runs locally with root privileges; typical scripts fetch a startup-config and/or an EOS image, install them, and reboot.

DHCP Server Configuration (ISC DHCP)

subnet 10.0.0.0 netmask 255.255.255.0 {
    range 10.0.0.100 10.0.0.200;
    option routers 10.0.0.1;
    option bootfile-name "http://10.0.0.5/ztp/ztp-script.sh";
    option tftp-server-name "10.0.0.5";
    option domain-name-servers 10.0.0.5;
}

Use the HTTP URL in bootfile-name - EOS ZTP scripts support http://, tftp:// and ftp:// URLs. You can also use a per-host statement to give each switch its own script based on MAC address.

A Minimal ZTP Script

#!/bin/bash
# This script runs on the switch during ZTP
HOSTNAME=$(hostname)
echo "ZTP: provisioning $HOSTNAME"

# Download the startup configuration
curl -s -o /tmp/startup-config     "http://10.0.0.5/configs/${HOSTNAME}.conf" || exit 1

# Download a specific EOS image if needed
curl -s -o /tmp/eos.swi     "http://10.0.0.5/images/EOS-4.30.0F.swi" || exit 1

# Load the configuration into the running config
FastCli -p 15 -c "copy /tmp/startup-config running-config"
FastCli -p 15 -c "copy running-config startup-config"

# Install the image and reboot
FastCli -p 15 -c "install source /tmp/eos.swi"
sleep 5
FastCli -p 15 -c "reload now"

Notes: FastCli is the CLI automation tool available during ZTP; the script must be executable (chmod +x) on your HTTP server. Keep the script idempotent - it can run more than once.

Verifying and Disabling ZTP

switch# show ztp status
switch(config)# no ztp
switch(config)# write memory

show ztp status displays the ZTP state (active/completed). Once a switch has a saved startup configuration, ZTP does not run on the next boot. To disable ZTP explicitly, use no ztp in config mode and save. You can also abort an in-progress ZTP by answering the on-console prompt, or by configuring the switch manually during the ZTP window.

Best Practices

  • Version the ZTP scripts and configs - every deployment reproduces from the same tree (GitOps).
  • Name configs by serial number or MAC (show version / show inventory) for per-device uniqueness.
  • Combine with DHCP option 125 or per-host reservations to steer different switch models to different image versions.
  • Always test the script on a lab switch before racking a fleet - a broken ZTP script strands the switch at an empty prompt.

Related: SONiC install via ONIE and Ansible network automation.

原文链接:https://www.arista.com/en/support/toi/eos-4-24-2f/15231-ztp-zero-touch-provisioning