Boot Using Zero Touch Provisioning
ZTP allows you to provision the network device with day 0 configurations and supports both management ports and data ports.
ZTP provides multiple options such as:
-
Automatically apply specific configuration in a large-scale environment.
-
Download and install specific IOS XR image.
-
Install specific application package or third-party applications automatically.
-
Deploy containers without manual intervention.
-
Upgrade or downgrade software versions effortlessly on thousands of network devices at a time.
ZTP helps you manage large-scale service provider infrastructures effortlessly. Following are the added benefits of using ZTP:
-
ZTP helps you to remotely provision a router anywhere in the network. This eliminates the need for an expert to deploy network devices and reduces IT cost.
-
Automated provisioning using ZTP removes delay, increases accuracy, provides better customer experience and is cost-effective.
By automating repeated tasks, ZTP allows network administrators to concentrate on more important stuff.
-
ZTP process helps you to quickly restore service. Rather than troubleshooting an issue on hand, you can reset a system to a well-known working status.
Prerequisites:
ZTP does not execute, if a username is already configured in the system.
ZTP is initiated in one of the following ways:
-
Automated Fresh Boot: When you boot the device, the ZTP process initiates automatically if the device does not have a prior configuration. During the process, the router receives the details of the configuration file from the DHCP server. Use this method for devices that has no pre-loaded configuration. For more information, see Fresh Boot Using DHCP.
You must define the configuration file or the bootscript that is downloaded from the DHCP server.
-
Configuration File: The first line of the file must contain !! IOS XR configuration'', to process the file as a configuration. If you are trying to bring up ten new nodes, you have to define ten configuration files. See Build your Configuration File.
-
ZTP Bootscript: Define the script to be executed on every boot. See Configure ZTP BootScript .
-
Manual Invocation using CLI: Use this method when you want to forcefully initiate ZTP on a fully configured device using CLI. See Invoke ZTP Manually through CLI.
-
Invocation using Reload Command: Use this method when you want to forcefully initiate ZTP on a fully configured device using the reload command. See Invoke ZTP Through Reload.
Fresh Boot Using DHCP
The ZTP process initiates when you boot the network device with an IOS XR image. The ZTP process starts only on a device without prior configuration.
This figure depicts the high-level workflow of the ZTP process:
-
ZTP sends DHCP request to fetch the ZTP configuration file or user script. To help the Bootstrap server uniquely identify the device, ZTP sends below DHCP option.
-
DHCP(v4/v6) client-id=Serial Number
-
DHCPv4 option 124: Vendor, Platform, Serial-Number
-
DHCPv6 option 16: Vendor, Platform, Serial-Number
The following is the default sequential flow of the ZTP process defined in the configuration file. You can modify this sequence in the configuration file, if required.
-
ZTP sends IPv4 DHCP request first on all the management ports. If the request fails, then ZTP sends IPv6 DHCP request on all the management ports.
-
ZTP sends IPv4 DHCP request first on all the data ports. If the request fails, then ZTP sends IPv6 DHCP request on all the data ports.
-
- DHCP server identifies the device and responds with DHCP response.
DHCP server should be configured to respond with DHCP response and supply script/config location with one of the following DHCP options:
-
DHCPv4 using BOOTP filename.
-
DHCPv4 using Option 67 (bootfile-name).
-
DHCPv6 using Option 59 (OPT_BOOTFILE_URL).
-
-
The network device downloads the file from the web server using the URL location provided in the DHCP response.
-
The device receives a configuration file or script file from the HTTP server.
Note
-
If the downloaded file content starts with !! IOS XR, it is considered as a configuration file.
-
If the downloaded file content starts with #! /bin/bash, #! /bin/sh, or #!/usr/bin/python, it is considered as a script file.
-
-
The device applies the configuration file or executes the script or binary in the default bash shell.
-
The Network device is now up and running.
Build your Configuration File
Based on the business need, you can use a configuration or script file to initiate the ZTP process.
The configuration file content starts with !! IOS XR.
The following is the sample configuration file. You can automate all the configurations. For more information on creating ZTP configuration file, refer ZTP Configuration Files Creation.
!! Building configuration
!! IOS XR Configuration 7.11.1.35I
!! Last configuration change at Fri Sep 15 17:18:53 2023 by cisco
!
hostname IOS_P2B_FLT
logging console debugging
username cisco
group root-lr
group cisco-support
secret 10 $6$4gjnzvvwDCz1z...$bovO.6uRYD9qsujiw6DNjTx6bngeDIVMvXxVbReal6bpd0SRo5qyfHk5S4D23r9hjntYtXnyQWNcrgbK0USB20
!
grpc
port 57400
!
line template vty
timestamp disable
exec-timeout 0 0
!
line template test
exec-timeout 0 0
!
line console
timeout login response 30
timestamp
exec-timeout 0 0
width 0
length 0
!
line default
timestamp disable
exec-timeout 0 0
length 0
absolute-timeout 0
session-timeout 0
!
vty-pool default 0 10 line-template default
fpd auto-upgrade enable
ntp
max-associations 99
!
call-home
service active
contact smart-licensing
profile CiscoTAC-1
active
destination transport-method email disable
destination transport-method http
!
!
netconf-yang agent
ssh
!
hw-module location 0/1/NXR0
mxponder-slice 0
trunk-rate 600G
client-rate 100GE
!
!
hw-module location 0/2/NXR0
mxponder-slice 0
trunk-rate 800G
client-port-rate 1 client-type 400GE
!
!
interface MgmtEth0/RP0/CPU0/0
description mgmt0
ipv4 address 10.105.57.64 255.255.255.0
!
interface MgmtEth0/RP0/CPU0/1
ipv4 address 10.127.60.44 255.255.255.0
ipv6 enable
!
controller Optics0/0/0/0
description optics0/0/0/0
pm 30-sec optics threshold opt min 2
fastpoll enable
perf-mon enable
!
controller Optics0/0/0/1
description optics0/0/0/1
fastpoll enable
!
controller Optics0/0/0/2
description optics0/0/0/2
perf-mon enable
!
controller Optics0/0/0/3
description optics0/0/0/3
!
controller Optics0/0/0/4
description optics0/0/0/4
!
controller Optics0/0/0/5
description optics0/0/0/5
!
controller Optics0/0/0/6
description optics0/0/0/6
!
controller Optics0/0/0/7
description optics0/0/0/7
!
controller Optics0/0/0/8
description optics0/0/0/8
!
controller Optics0/0/0/9
description optics0/0/0/9
pm 15-min optics report opt max-tca enable
pm 15-min optics threshold opt-dbm max -200
pm 30-sec optics report opr min-tca enable
pm 30-sec optics report opt max-tca enable
pm 30-sec optics threshold opr-dbm min 500
pm 30-sec optics threshold opt-dbm max -210
!
controller Optics0/0/0/10
description optics0/0/0/10
!
controller Optics0/0/0/11
description optics0/0/0/11
!
controller Optics0/0/0/12
description optics0/0/0/12
!
controller Optics0/0/0/13
description optics0/0/0/13
!
controller Optics0/1/0/0
description optics0/1/0/0
pm 15-min optics report opr min-tca enable
pm 15-min optics threshold opr-dbm min 200
pm 30-sec optics report opr min-tca enable
pm 30-sec optics threshold opr-dbm min 200
fastpoll enable
!
controller Optics0/1/0/1
description optics0/1/0/1
!
controller Optics0/1/0/2
description optics0/1/0/2
!
controller Optics0/1/0/3
description optics0/1/0/3
!
controller Optics0/1/0/4
description optics0/1/0/4
!
controller Optics0/1/0/5
description optics0/1/0/5
!
controller Optics0/1/0/6
description optics0/1/0/6
!
controller Optics0/1/0/7
description optics0/1/0/7
!
controller Optics0/1/0/8
description optics0/1/0/8
!
controller Optics0/1/0/9
description optics0/1/0/9
!
controller Optics0/1/0/10
description optics0/1/0/10
!
controller Optics0/1/0/11
description optics0/1/0/11
!
controller Optics0/1/0/12
description optics0/1/0/12
!
controller Optics0/1/0/13
description optics0/1/0/13
!
controller Optics0/2/0/0
description optics0/2/0/0
transmit-power -25
dwdm-carrier 100MHz-grid frequency 1923500
rx-low-threshold -120
rx-high-threshold 40
tx-low-threshold -101
tx-high-threshold 40
!
controller Optics0/2/0/1
description optics0/2/0/1
!
controller Optics0/2/0/2
description optics0/2/0/2
!
controller Optics0/2/0/3
description optics0/2/0/3
!
controller Optics0/2/0/4
description optics0/2/0/4
!
controller Optics0/2/0/5
description optics0/2/0/5
!
controller Optics0/2/0/6
description optics0/2/0/6
!
controller Optics0/2/0/7
description optics0/2/0/7
!
controller Optics0/3/0/0
description optics0/3/0/0
!
controller Optics0/3/0/1
description optics0/3/0/1
!
controller Optics0/3/0/2
description optics0/3/0/2
pm 30-sec optics report opr min-tca enable
pm 30-sec optics threshold opr-dbm min 200
!
controller Optics0/3/0/3
description optics0/3/0/3
!
controller Optics0/3/0/4
description optics0/3/0/4
!
controller Optics0/3/0/5
description optics0/3/0/5
!
controller Optics0/3/0/6
description optics0/3/0/6
!
controller Optics0/3/0/7
description optics0/3/0/7
!
controller Optics0/3/0/8
description optics0/3/0/8
!
controller Optics0/3/0/9
description optics0/3/0/9
!
controller Optics0/3/0/10
description optics0/3/0/10
!
controller Optics0/3/0/11
description optics0/3/0/11
!
controller Optics0/3/0/12
description optics0/3/0/12
!
controller Optics0/3/0/13
description optics0/3/0/13
!
interface PTP0/RP0/CPU0/0
shutdown
!
interface PTP0/RP0/CPU0/1
shutdown
!
router static
address-family ipv4 unicast
0.0.0.0/0 10.105.57.1
0.0.0.0/0 10.127.60.1
!
!
snmp-server traps sensor
snmp-server traps fru-ctrl
netconf agent tty
!
lldp
!
ains-soak hours 47 minutes 59
ssh timeout 120
ssh server rate-limit 600
ssh server session-limit 100
ssh server v2
ssh server vrf default
ssh server netconf vrf default
end
Configure ZTP BootScript
ZTP downloads and executes the script files. These script files include a programmatic approach to complete a task. For example, scripts created using IOS XR commands to perform patch upgrades. The first line of the file must contain #! /bin/bash or #! /bin/sh for ZTP to process the file as script.
You can either use the ZTP bash script or the ZTP configuration file.
To manually execute a script during every boot, use the following configuration:
Router#configure
Router(config)#ztp bootscript /disk0:/myscript
Router(config)#commit
To ensure that we have connectivity in the third-party namespace for applications to use, the above configuration waits for the first data plane interface to be configured and wait an extra minute for the management interface to be configured with an IP address. If the delay is not desired, use:
Router#configure
Router(config)#ztp bootscript preip /disk0:/myscript
Router(config)#commit
Note |
When the above command is first configured, you will be prompted if you wish to invoke it now. The prompt helps with testing. |
This is the example content of /disk0:/myscript:
host ncs1010_P1B_DT_08_ETH0 {
#hardware ethernet 68:9e:0b:b8:6f:5c ;
option dhcp-client-identifier "FCB2437B05N" ;
if exists user-class and option user-class = "iPXE" {
filename "http://10.33.0.51/P1B_DT_08/ncs1010-x64.iso";
} else {
filename "http://10.33.0.51/P1B_DT_08/startup.cfg";
}
fixed-address 10.33.0.19;
}
The following is the sample content of the ZTP bash script.
#! /bin/bash
#
# NCS1014 Demo Sample
# ZTP installation of config and day-0 SMU's
#
source ztp_helper
wget http://downloads.sourceforge.net/project/yourcode/application.tgz
#install the downloaded application.tgz
#Run XR CLI’s from the script
`xrcmd “show version”`
The following is the sample content of the ZTP configuration file.
Tue May 4 18:08:59.544 UTC
Building configuration...
IOS XR Configuration 7.11.1.35I
!! Last configuration change at Fri Sep 15 17:18:53 2023 by cisco
!
line console
exec-timeout 0 0
!
line default
exec-timeout 0 0
session-timeout 0
!
vty-pool default 0 20
alias alarms show alarms brief system active
interface MgmtEth0/RP0/CPU0/0
ipv4 address dhcp
no shut
!
interface MgmtEth0/RP0/CPU0/1
description noshut-interface-ztp
ipv4 address 10.127.60.160 255.255.255.0
no shut
!
interface PTP0/RP0/CPU0/0
description noshut-interface-ztp
no shut
!
interface PTP0/RP0/CPU0/1
description noshut-interface-ztp
no shut
end
Invoke ZTP Manually through CLI
Manual ZTP can be invoked through CLI commands. This manual way helps you to provision the router in stages. Ideal for testing out ZTP configuration without a reboot. If you want to invoke a ZTP on an interface (data ports or management ports), you need not bring up and configure the interface first. You can execute the ztp initiate command, even if the interface is down, so that the ZTP script brings it up and invoke dhclient. ZTP can run on all interfaces irrespective of whether the interfaces are up or not.
Use the ztp initiate, ztp terminate, and ztp clean commands to force ZTP to run on more interfaces.
-
ztp initiate—Invokes a new ZTP DHCP session. Logs can be found in the /disk0:/ztp/ztp.log location.
-
ztp terminate—Terminates current ZTP sessions.
-
ztp clean—Removes only the ZTP state files.
The log file ztp.log is saved in the /var/log/ztp.log folder, and a copy of log file is available in the /disk0:/ztp/ztp.log location using a soft link. However, executing ztp clean clears files saved on disk and not from the /var/log/ztp.log folder where current ZTP logs are saved. To get a log from current ZTP run, you must manually remove the ZTP log file from /var/log/ztp.log.
SUMMARY STEPS
- (optional) ztp clean
- ztp initiate
- (Optional) ztp terminate
DETAILED STEPS
Step 1 |
(optional) ztp clean Example:
Removes all the ZTP logs and saved settings. |
Step 2 |
ztp initiate Example:
Reboots the Cisco NCS 1014 system. Use the show logging command or see the /var/log/ztp.log to check progress. |
Step 3 |
(Optional) ztp terminate Example:
Terminates the ZTP process. |
Invoke ZTP Through Reload
SUMMARY STEPS
- configure
- commit replace
- ztp clean
- reload
DETAILED STEPS
Step 1 |
configure Example:
Enters the configuration mode. |
Step 2 |
commit replace Example:
Removes the entire running configuration. |
Step 3 |
ztp clean Example:
Removes all the ZTP logs and saved settings. |
Step 4 |
reload Example:
After the node comes up, you can see that the ZTP is initiated and the configuration has been restored successfully.
Reboots the Cisco NCS 1014 system. |
ZTP Logging
ZTP logs its operation on the flash file system in the /disk0:/ztp/ directory. ZTP logs all the transactions with the DHCP server and all the state transitions.
The following example displays the execution of a simple configuration script downloaded from a data interface using the command ztp initiate interface MgmtEth 0/RP0/CPU0/0 verbose. This script unshuts all the interfaces of the system and configures a load interval of 30 seconds on all of them.
2023-09-25 17:37:31,693 28136 [Engine ] DEB: ZAdmin, current state:active. Processing work: Sending standby sync message. done = False
2023-09-25 17:37:31,716 28136 [Engine ] DEB: ZAdmin, current state:active. Processing work: [privileged] getting engine status. done = False
2023-09-25 17:37:31,717 28136 [Engine ] DEB: ZAdmin, current state:active. Processing work: Fetching provisioning data. done = False
2023-09-25 17:37:31,718 28136 [Engine ] INF: ZAdmin, current state:active: state tag changed to fetch
2023-09-25 17:37:31,721 28136 [Xr ] INF: Downloading the file to /tmp/ztp.script
2023-09-25 17:37:31,948 28136 [ReportBootz ] INF: User script downloaded successfully. Provisioning in progress.
2023-09-25 17:37:31,950 28136 [Engine ] DEB: ZAdmin, current state:active. Processing work: Config device work for ZAdmin. done = False
2023-09-25 17:37:31,951 28136 [ZtpHelpers ] DEB: Executing: source /pkg/bin/ztp_helper.sh && echo -ne | xrcmd "show version"
2023-09-25 17:37:32,956 28136 [ZAdmin ] DEB: Proceeding to provision the router
2023-09-25 17:37:32,958 28136 [Engine ] DEB: ZAdmin, current state:active. Processing work: ZAdmin: Apply configuration. done = False
2023-09-25 17:37:32,959 28136 [Engine ] INF: ZAdmin, current state:active: state tag changed to provision
2023-09-25 17:37:32,975 28136 [Env ] DEB: No MTU configs detected
2023-09-25 17:37:32,977 28136 [Engine ] DEB: ZAdmin, current state:active. Processing work: ZAdmin: Apply configuration. done = False
2023-09-25 17:37:33,021 28136 [Xr ] DEB: Will apply the following config: /disk0:/ztp/customer/config.candidate
2023-09-25 17:37:33,022 28136 [Xr ] INF: Applying user configurations
2023-09-25 17:37:33,023 28136 [Configuration] INF: Provisioning via config replace
2023-09-25 17:38:14,445 28136 [Configuration] INF: Configuration has been applied
2023-09-25 17:38:14,447 28136 [Env ] DEB: cfg::createRefOnConfigCommit: called
2023-09-25 17:38:15,778 28136 [Env ] DEB: cfg:: Generating hash for File name: /disk0:/ztp/customer/config.inithash_tmp
2023-09-25 17:38:15,780 28136 [Env ] DEB: cfg::_generateCfgAndSaveHash:: HASH : 643013d9a43a3d2576012a24eb9745a8f960480d0053d06ed81146cb3c3d54c5, type : 1
2023-09-25 17:38:17,743 28136 [Env ] DEB: cfg::getRefOnConfigCommit: called
2023-09-25 17:38:17,818 28136 [Env ] DEB: cfg::getRefOnConfigCommit :: ret : data : 643013d9a43a3d2576012a24eb9745a8f960480d0053d06ed81146cb3c3d54c5, len: 64
2023-09-25 17:38:17,819 28136 [Env ] INF: Env::getConfigRefHashOnCommit: get data from tam : success:b'643013d9a43a3d2576012a24eb9745a8f960480d0053d06ed81146cb3c3d54c5'
2023-09-25 17:38:17,821 28136 [Engine ] DEB: ZAdmin, current state:active. Processing work: Sending standby sync message. done = False
2023-09-25 17:38:17,836 28136 [Engine ] DEB: ZAdmin, current state:active. Processing work: [privileged] getting engine status. done = False
2023-09-25 17:38:17,837 28136 [Engine ] DEB: ZAdmin, current state:active. Processing work: ZAdmin: Execute post-configuration script. done = False
2023-09-25 17:38:17,873 28136 [Env ] INF: Env::cleanup, success:True, exiting:False
2023-09-25 17:38:17,876 28136 [ZtpHelpers ] DEB: Executing: source /pkg/bin/ztp_helper.sh && echo -ne | xrcmd "show running-config"
2023-09-25 17:38:19,582 28136 [Env ] INF: Executing command ip netns exec vrf-default /sbin/dhclient -4 -cf /etc/dhcp/dhclient.conf.ztp -lf /var/lib/dhcp/dhclient.leases.ztp -sf /etc/dhcp/dhclient-script.ztp2 -r Mg0_RP0_CPU0_0 to release IP
2023-09-25 17:38:20,695 28136 [Xr ] INF: Removing linux route with ip 10.105.57.107
2023-09-25 17:38:20,731 28136 [Xr ] INF: Failed to remove default route to to_xr via 10.105.57.107 with error: Error: RTNETLINK answers: No such process encountered while executing command: ip netns exec vrf-default ip route del default dev to_xr src 10.105.57.107 metric 512
2023-09-25 17:38:20,736 28136 [Engine ] INF: ZAdmin, current state:active, exit code:success
2023-09-25 17:38:20,737 28136 [Engine ] INF: ZAdmin, current state:final, exit code:success: state changed to final
2023-09-25 17:38:22,846 28136 [Engine ] DEB: ZAdmin, current state:final, exit code:success. Processing work: Sending standby sync message. done = False
2023-09-25 17:38:22,847 28136 [Engine ] WAR: ZAdmin, current state:final, exit code:success: work is ignored: work=<desc='Sending standby sync message' done=False priv=False>
2023-09-25 17:38:22,848 28136 [Engine ] DEB: ZAdmin, current state:final, exit code:success. Processing work: [privileged] getting engine status. done = False
2023-09-25 17:38:27,853 28136 [__main__ ] DEB: Moved to final state
2023-09-25 17:38:27,854 28136 [__main__ ] DEB: ZTP completed successfully
2023-09-25 17:38:27,855 28136 [__main__ ] INF: Exiting SUCCESSFULLY
Generate Tech Support Information for ZTP
When you have a problem that you cannot resolve in the ztp process, contact the Cisco Systems technical support representative. To analyze a problem, your technical support representative needs certain information about the situation and the symptoms that you are experiencing. To speed up the resolution, collect the necessary data before you contact your representative.
Use the show tech-support ztp command to collect all debugging information of ztp process.
Example:
RP/0/RP0/CPU0:ios#show tech-support ztp
Thu Jul 28 08:33:27.531 UTC
++ Show tech start time: 2022-Jul-28.083327.UTC ++
Thu Jul 28 08:33:28 UTC 2022 Waiting for gathering to complete
..
Thu Jul 28 08:33:34 UTC 2022 Compressing show tech output
Show tech output available at 0/RP0/CPU0 : /harddisk:/showtech/showtech-R1-ZTP-2022-Jul-28.083327.UTC.tgz
++ Show tech end time: 2022-Jul-28.083334.UTC ++
RP/0/RP0/CPU0:ios#
In the above example, the tech support information is saved as .tgz file in the specified location. This information can be shared with the Cisco Technical Support representatives for troubleshooting the ztp process.