Configuration Guide
Basic Configuration
ZTP Configuration
11 min
introduction introduction zero touch provisioning (ztp) refers to the automatic loading of initialization files (configuration files, upgrade files) on newly manufactured or blank devices when they are powered on this functionality enables devices to be deployed and configured without requiring on site manual configuration as a result, ztp reduces labor costs and enhances deployment efficiency principle explanation principle explanation as illustrated in the diagram, a device awaiting configuration is connected to a dhcp relay device via its service port or management port upon powering on, the device checks whether a ztp initialization process has been carried out if yes, it loads the system configuration files and starts the device if not, the device enters the ztp initialization process through dhcp during this process, the device operates as a dhcp client and sends dhcp request packets to the dhcp server to obtain an ip address and the path to the required upgrade files based on the configuration information carried in the received dhcp response packet, the device automatically retrieves version and configuration files from the specified file server it then proceeds to execute the upgrade command and reboot the device upon completion of the device reboot, automatic loading of both the version and configuration is achieved dhcp server used to assign temporary management ip addresses to devices and provide the file server address tftp/ftp server stores the configuration files, version images required for ztp initialization, and user logs after upgrades are completed dhcp relay when the device to be upgraded and the dhcp server are in different network segments, a relay device is needed to forward dhcp packets devices can carry their hardware model and serial number in the packets tftp/ftp servers can name version files based on hardware models and name configuration files based on serial numbers, enabling provision of different versions and independent configuration files for devices of various models and serial numbers the workflow of ztp is illustrated in the diagram below configuring the dhcp server configuring the dhcp server the dhcp server passes network configuration parameters to the device through the option field when the device to be configured is not on the same subnet as the dhcp server, a dhcp relay needs to be configured to forward dhcp interaction messages when the device enters the ztp process, both the management port and service port of the device will send dhcpv4 discover messages, carrying option 67 to request the path to the intermediate file required for provisioning dhcp option parameters description option number function option 1 sets the subnet mask for the ip address option 3 sets the gateway for the dhcp client option 6 sets the ip address of the dns server option 67 sets the path to the intermediate file such as ftp\ //ftpserver\ test\@192 168 0 10/ztp json configuring the file server configuring the file server the file server is used to store the files that need to be transferred during the ztp process, including intermediate files, image files, configuration files, and logs generally, a third party server is used as the file server, and during deployment, the network connectivity between the file server and the device must be ensured the file server supports tftp and ftp servers place the intermediate file and other provisioning files in the working directory of the file server and rename the files as specified image file the name should be the device type followed by bin for example, if the device type is cx204y 48gt m swp4, the image file name should be cx204y 48gt m swp4 bin configuration file the name should be the device serial number (sn) followed by bin for example, if the device sn is f020000a055, the configuration file name should be f020000a055 bin intermediate file the file must be named exactly ztp json logs logs generated by the device during the ztp process will be uploaded to the file server after the ztp process is completed or if it fails for some reason, to facilitate troubleshooting note the naming convention for image files and configuration files above is applicable when different types of devices have different version images and different devices load different configuration files if the devices undergoing ztp provisioning need to pull identical image and configuration files, you can also specify the same name as in the intermediate file preparing the configuration file preparing the configuration file ztp provisioning requires the pre preparation of provisioning files, including the configuration file and the intermediate file the configuration file is in json format, which the device loads to generate the configuration after startup the configuration file can be manually written or copied from another device to save the configuration file, execute the write command on the device the configuration file is saved in the /etc/sonic/ directory of the device, named in the format config db json then, export the configuration file using scp or other methods it is important to note that the configuration file must be written strictly in json format and comply with the device's requirements for the configuration file content it is recommended that users export the configuration file and modify it as needed, rather than writing the configuration file directly preparing the intermediate file preparing the intermediate file the intermediate file is used to inform the device about the paths of the version image and configuration file to be fetched, as well as the path where the log files generated during the ztp process need to be uploaded the file must be named ztp json { "ztp" { "configdb json" { "dynamic url" { "source" { "prefix" "ftp\ //ftpserver\ test\@192 168 0 10/ztp cfg/", "identifier" "serial number", "suffix" " json" }, "destination" "/etc/sonic/config db json" } }, "firmware" { "install" { "dynamic url" { "source" { "prefix" "ftp\ //ftpserver\ test\@192 168 0 10/ztp image/", "identifier" "product name", "suffix" " bin" } }, "set default" true } }, "upload log" { "dynamic upload url" { "destination" { "prefix" "ftp\ //ftpserver\ test\@192 168 0 10/ztp log/", "identifier" " serial number", "suffix" " log" } }, "reboot on success" true } } } field meanings field meaning configdb json prefix the absolute path of the configuration file identifier the configuration file name when the field content is serial number, it indicates that the field will be automatically filled with the device's sn code if there is no need to distinguish between different devices, a fixed configuration file name can be used suffix the file format, which must be json for configuration files firmware prefix the absolute path of the image file identifier the image file name when the field content is product name, it indicates that the field will be automatically filled with the device type if there is no need to distinguish between device types, a fixed name can be used suffix the file format, which must be bin for image files upload log prefix the specified path for uploading logs to the file server identifier the log file name suffix the log file format set default set the image as the default to be loaded at startup reboot on success automatically reboot the device after the ztp process is completed successfully configuration example configuration example network requirements network requirements a certain company has multiple switches that need to be deployed in bulk, upgraded, and configured to save on human resources and streamline the process, they plan to use zero touch provisioning for deployment procedure procedure configure the dhcp server and add an option field to configure the ftp server address option bootfile name ”ftp\ //ftpserver\ test\@192 168 0 10/ztp json create a ztp file in the /ftpboot directory of the ftp server, and provide directory information for the required files during the ztp process { "ztp" { "configdb json" { "dynamic url" { "source" { "prefix" "ftp\ //ftpserver\ test\@192 168 0 10/ztp cfg/", "identifier" "serial number", "suffix" " json" }, "destination" "/etc/sonic/config db json" } }, "firmware" { "install" { "dynamic url" { "source" { "prefix" "ftp\ //ftpserver\ test\@192 168 0 10/ztp image/", "identifier" "product name", "suffix" " bin" } }, "set default" true } }, "upload log" { "dynamic upload url" { "destination" { "prefix" "ftp\ //ftpserver\ test\@192 168 0 10/ztp log/", "identifier" " serial number", "suffix" " log" } }, "reboot on success" true } } } upload the required files to the directory specified in the ztp json file on the ftp server verify configuration verify configuration after device reboot, view device version and configuration sonic# show version sonic# show running config
