Zero-Touch Provisioning for Cisco IOS

Vincent Bernat

The of­fi­cial doc­u­men­ta­tion to au­to­mat­i­cally up­grade1 and con­fig­ure on first boot a Cisco switch run­ning on IOS, like a Cisco Cat­a­lyst 2960-X Se­ries switch, is scarce on de­tails. This note ex­plains how to con­fig­ure the ISC DHCP Server for this purpose.


When boot­ing for the first time, Cisco IOS sends a DHCP dis­cover re­quest on all ports:

Dynamic Host Configuration Protocol (Discover)
    Message type: Boot Request (1)
    Hardware type: Ethernet (0x01)
    Hardware address length: 6
    Hops: 0
    Transaction ID: 0x0000117c
    Seconds elapsed: 0
    Bootp flags: 0x8000, Broadcast flag (Broadcast)
    Client IP address: 0.0.0.0
    Your (client) IP address: 0.0.0.0
    Next server IP address: 0.0.0.0
    Relay agent IP address: 0.0.0.0
    Client MAC address: Cisco_6c:12:c0 (b4:14:89:6c:12:c0)
    Client hardware address padding: 00000000000000000000
    Server host name not given
    Boot file name not given
    Magic cookie: DHCP
    Option: (53) DHCP Message Type (Discover)
    Option: (57) Maximum DHCP Message Size
    Option: (61) Client identifier
        Length: 25
        Type: 0
        Client Identifier: cisco-b414.896c.12c0-Vl1
    Option: (55) Parameter Request List
        Length: 12
        Parameter Request List Item: (1) Subnet Mask
        Parameter Request List Item: (66) TFTP Server Name
        Parameter Request List Item: (6) Domain Name Server
        Parameter Request List Item: (15) Domain Name
        Parameter Request List Item: (44) NetBIOS over TCP/IP Name Server
        Parameter Request List Item: (3) Router
        Parameter Request List Item: (67) Bootfile name
        Parameter Request List Item: (12) Host Name
        Parameter Request List Item: (33) Static Route
        Parameter Request List Item: (150) TFTP Server Address
        Parameter Request List Item: (43) Vendor-Specific Information
        Parameter Request List Item: (125) V-I Vendor-specific Information
    Option: (255) End

It re­quests sev­eral op­tions, in­clud­ing the Boot­file name op­tion 67, the TFTP server ad­dress op­tion 150, and the Ven­dor-Iden­ti­fy­ing Ven­dor-Spe­cific In­for­ma­tion Op­tion 125—or VIVSO. Op­tion 67 pro­vides the name of the con­fig­u­ra­tion file lo­cated on the TFTP server iden­ti­fied by op­tion 150. Op­tion 125 in­cludes the name of the file de­scrib­ing the Cisco IOS im­age to use to up­grade the switch. This file only con­tains the name of the tar­ball em­bed­ding the image.2

Con­fig­ur­ing the ISC DHCP Server to an­swer with the TFTP server ad­dress and the name of the con­fig­u­ra­tion file is sim­ple enough:

filename "ob2-p2.example.com";
option tftp-server-address 172.16.15.253;

How­ever, if you want to also pro­vide the im­age for up­grade, you have to spec­ify a hexa­dec­i­mal-en­coded string:3

option vivso 00:00:00:09:24:05:22:63:32:39:36:30:2d:6c:61:6e:62:61:73:65:6b:39:2d:74:61:72:2e:31:35:30:2d:32:2e:53:45:31:31:2e:74:78:74;

Hav­ing a large hexa­dec­i­mal-en­coded string in­side a con­fig­u­ra­tion file is quite un­sat­is­fy­ing. In­stead, the ISC DHCP Server al­lows you to ex­press this in­for­ma­tion in a more read­able way us­ing the option space statement:

# Create option space for Cisco and encapsulate it in VIVSO/vendor space
option space cisco code width 1 length width 1;
option cisco.auto-update-image code 5 = text;
option vendor.cisco code 9 = encapsulate cisco;

# Image description for Cisco IOS ZTP
option cisco.auto-update-image = "c2960-lanbasek9-tar.150-2.SE11.txt";

# Workaround for VIVSO option 125 not being sent
option vendor.iana code 0 = string;
option vendor.iana = 01:01:01;

With­out the work­around men­tioned in the last block, the ISC DHCP Server would not send back op­tion 125. With such a con­fig­u­ra­tion, it re­turns the fol­low­ing an­swer, in­clud­ing a harm­less ad­di­tional en­ter­prise 0 en­cap­su­lated into op­tion 125:

Dynamic Host Configuration Protocol (Offer)
    Message type: Boot Reply (2)
    Hardware type: Ethernet (0x01)
    Hardware address length: 6
    Hops: 0
    Transaction ID: 0x0000117c
    Seconds elapsed: 0
    Bootp flags: 0x8000, Broadcast flag (Broadcast)
    Client IP address: 0.0.0.0
    Your (client) IP address: 172.16.15.6
    Next server IP address: 0.0.0.0
    Relay agent IP address: 0.0.0.0
    Client MAC address: Cisco_6c:12:c0 (b4:14:89:6c:12:c0)
    Client hardware address padding: 00000000000000000000
    Server host name not given
    Boot file name: ob2-p2.example.com
    Magic cookie: DHCP
    Option: (53) DHCP Message Type (Offer)
    Option: (54) DHCP Server Identifier (172.16.15.252)
    Option: (51) IP Address Lease Time
    Option: (1) Subnet Mask (255.255.248.0)
    Option: (6) Domain Name Server
    Option: (3) Router
    Option: (150) TFTP Server Address (172.16.15.252)
    Option: (125) V-I Vendor-specific Information
        Length: 49
        Enterprise: Reserved (0)
        Enterprise: ciscoSystems (9)
            Length: 36
            Option 125 Suboption: 5
                Length: 34
                Data: 63323936302d6c616e626173656b392d7461722e3135302d…
    Option: (255) End

On the same topic, do not over­ride op­tion 43 “VSIO.” See “Zero-Touch Pro­vi­sion­ing for Ju­niper devices.”