Inleiding
In dit document worden de configuratie en levering van Zero Touch Provisioning (ZTP) op Cisco Catalyst 9000 Series-Switches beschreven.
Voorwaarden
Vereisten
Cisco raadt kennis van de volgende onderwerpen aan:
- DHCP-serverconfiguratie (Dynamic Host Configuration Protocol) op de switch
- Basisprincipes van Python code
- Basisprincipes van HTTP/TFTP-service
Vergunningseisen
- De Network Advantage- of Network Essentials-licentie moet actief zijn.
Ondersteunde platforms
- Catalyst 9300 serie switches met 16.5.1a versie
- Catalyst 9500 serie switches met 16.5.1a versie
- Catalyst 9400 serie switches met 16.6.2 versie
Opmerking: deze functie wordt niet ondersteund in C9600.
Gebruikte componenten
De informatie in dit document is gebaseerd op de volgende software- en hardware-versies:
- Cisco Catalyst 9300 switch op Cisco IOS® XE 17.6.4
- Cisco Catalyst 3850 switch fungeert als een DHCP-server met optionele 67-configuratie
- De eindhost die met de HTTP-service is geïnstalleerd, bevat een Python-bestand.
De informatie in dit document is gebaseerd op de apparaten in een specifieke laboratoriumomgeving. Alle apparaten die in dit document worden beschreven, hadden een opgeschoonde (standaard)configuratie. Als uw netwerk live is, moet u zorgen dat u de potentiële impact van elke opdracht begrijpt.
Achtergrondinformatie
Zero Touch Provisioning (ZTP) wordt gebruikt om netwerkapparaten nauwkeurig binnen enkele minuten en zonder enige handmatige tussenkomst te leveren.
Netwerkdiagram
Zero Touch Provisioning - Basisinstellingen en -stappen
ZTP-bewerking (gedetailleerde stappen)
ZTP automatiseert de configuratie van switches uit de Catalyst 9000-reeks zonder opstartconfiguratie wanneer deze in het bestaande netwerk wordt geïntroduceerd. Dit gebeurt zonder enige handmatige tussenkomst. Gedetailleerde stappen worden hier uitgelegd.
Stap 1. De nieuwe Switch aansluiten
Sluit een nieuwe switch aan op de bestaande infrastructuur en schakel het apparaat in. De switch wordt opgestart zonder opstartconfiguratie.
Stap 2. ZTP-initiatie
Het ZTP-proces wordt automatisch door de switch gestart.
Stap 3. DHCP-aanvraag
De switch verzendt het DHCP-detectiebericht.
Stap 4. DHCP-respons
DHCP-server reageert met een aanbod dat optie 67 bevat, met HTTP-server IP en URL.
Stap 5. HTTP-URL
De switch ontvangt het aanbod en krijgt een IP-adres voor zijn eigen communicatie. Het ontvangt ook het IP-adres van de HTTP-server en de volledige URL om het bestand ZTP.py te downloaden.
Stap 6. downloaden
De switch bereikt de HTTP-server en downloadt het ZTP.py bestand.
Stap 7. guestshell
De switch activeert de gastenschaal automatisch.
Stap 8. Configuraties implementeren
Switch voert het Python-bestand uit en de configuraties worden automatisch toegepast.
Stap 9. succes
De switch vernietigt de gastenschaal en het script execution is a success bericht wordt weergegeven.
Configuratie
HTTP-service instellen
Stap 1. HTTP-service installeren in End Host (voorbeeld Linux)
sudo apt update
sudo apt install apache2
Stap 2. Python-bestand maken ztp_http.py
Als er een machtigingsprobleem optreedt, gebruikt u dit chmod 777 om volledige toestemming voor het bestand te geven.
Het Python-bestand bevat de code die van deze taken is gemaakt:
1. Toon opdrachten.
2. Loopback-configuratie.
3. Verificatie van de configuratie.
Python-code:
#Importing cli module
import cli
print "\n\n Running show version \n\n"
cli.executep('show version')
print "\n\n Configure a Loopback Interface \n\n"
cli.configurep(["interface loop 25", "ip address 192.168.0.25 255.255.255.255", "end"])
print "\n\n Running show ip interface brief \n\n"
cli.executep('show ip int brief | i up')
print "\n\n ZTP is success \n\n"
Locatie van Python-bestand.
vm: /var/www/html$ ls -l ztp_http.py
-rwxrwxrwx 1 root root 346 Apr 04 14:14 ztp_http.py
Dit bestand moet worden opgeslagen onder /var/www/html in een Linux-systeem.
Stap 3. HTTP-service en luisterpoort verifiëren
Gebruik de opdracht service om te controleren of de HTTP-service is gestart en nu wordt uitgevoerd.
vm: /var/www/html$ sudo service apache2 status
Active: active (running)
Controleer met welke poort de HTTP-service op dit moment luistert.
vm: /var/www/html$ sudo netstat -anp | grep apache
tcp6 0 :::80 :::* LISTEN 1998/apache2 <<<< Listens at 80
Stap 4. Browserverificatie van poortnummer
Controleer of het bestand via de webbrowser kan worden gedownload.
1. Open elke browser binnen dezelfde machine (bijvoorbeeld Linux).
2. Voer deze URL in de zoekbalk in: localhost:80/ztp_http.py
3. Bestand wordt automatisch gedownload.
DHCP-service instellen
Stap 1. Configuratie van provisioninginterface (nieuw apparaat)
De nieuwe switch zal naar verwachting worden aangesloten op G1/0/1.
enable
configure terminal
interface g1/0/1
description New_9300_switch
switchport
switchport mode access
switchport access vlan 1
Stap 2. HTTP Server Connected Interface configureren
De HTTP-server (Linux) is rechtstreeks verbonden met de 3850-switch (bijvoorbeeld G1/0/2).
enable
configure terminal
interface g1/0/2
description Linux_is_connected_here
switchport
switchport mode access
switchport access vlan 1
Stap 3. DHCP-bereik configureren
Voorbeeld van DHCP-poolconfiguratie met optie 67.
enable
configure terminal
ip dhcp pool ZTP_Pool
network 10.0.0.0 255.255.255.0
default-router 10.0.0.1
option 67 ascii http://10.0.0.2:80/ztp_http.py
end
Verificatie
Er is momenteel geen verificatieprocedure beschikbaar voor deze configuratie.
Logboeken voor de werkconsole
No startup-config, starting autoinstall/pnp/ztp...
Autoinstall will terminate if any input is detected on console
--- System Configuration Dialog ---
Would you like to enter the initial configuration dialog? [yes/no]: <<<< Do not provide any input during this time.
Autoinstall trying DHCPv6 on Vlan1
Autoinstall trying DHCPv4 on Vlan1
Acquired IPv4 address 10.0.0.10 on Interface Vlan1
Received following DHCPv4 options:
bootfile : http://10.0.0.2:80/ztp_http.py
stop Autoip process
OK to enter CLI now...
pnp-discovery can be monitored without entering enable mode
Entering enable mode will stop pnp-discovery
Attempting bootfile http://10.0.0.2:80/ztp_http.py
Loading http://10.0.0.2:80/ztp_http.py
Loading http://10.0.0.2:80/ztp_http.py day0guestshell activated successfully
Current state is: ACTIVATED
day0guestshell started successfully
Current state is: RUNNING
Guestshell enabled successfully
Running show version <<<< show command executed
Cisco IOS XE Software, Version 17.06.04
Cisco IOS Software [Bengaluru], Catalyst L3 Switch Software (CAT9K_IOSXE), Version 17.6.4, RELEASE SOFTWARE (fc1)
<snipped>
Model Number : C9300L-48T-4X
System Serial Number : FOC2531LGM8
CLEI Code Number :
Switch Ports Model SW Version SW Image Mode
------ ----- ----- ---------- ---------- ----
* 1 53 C9300L-48T-4X 17.06.04 CAT9K_IOSXE BUNDLE
Configure a Loopback interface <<<< configuration
Line 1 SUCCESS: interface loop 25
Line 2 SUCCESS: ip address 192.168.0.25 255.255.255.255
Line 3 SUCCESS: end
Running show ip int brief <<<< Config Verification
Vlan1 10.0.0.10 YES DHCP up up
Vlan4094 192.168.2.1 YES manual up down
GigabitEthernet0/0 unassigned YES unset up up
GigabitEthernet1/0/2 unassigned YES unset up up
GigabitEthernet1/0/3 unassigned YES unset up up
Ap1/0/1 unassigned YES unset up up
Loopback25 192.168.0.25 YES other up up
ZTP is success
Guestshell destroyed successfully
Script execution success! <<<< Success
Problemen oplossen
Deze sectie bevat informatie waarmee u problemen met de configuratie kunt oplossen.
Veelvoorkomende problemen
Een andere DHCP-server is aanwezig in het netwerk
No startup-config, starting autoinstall/pnp/ztp...
Autoinstall will terminate if any input is detected on console
--- System Configuration Dialog ---
Would you like to enter the initial configuration dialog? [yes/no]:
Autoinstall trying DHCPv6 on Vlan1
Autoinstall trying DHCPv4 on Vlan1
Acquired IPv4 address 192.168.45.117 on Interface Vlan1 <<<< Gets Different IP from another DHCP server.
Received following DHCPv4 options:
hostname : Switch
stop Autoip process
OK to enter CLI now...
pnp-discovery can be monitored without entering enable mode
Entering enable mode will stop pnp-discovery
Guestshell destroyed successfully
stop Autoip process
% Please answer 'yes' or 'no'.
Would you like to enter the initial configuration dialog? [yes/no]: no
Python-codefout
--- System Configuration Dialog ---
Would you like to enter the initial configuration dialog? [yes/no]:
Autoinstall trying DHCPv6 on Vlan1
Autoinstall trying DHCPv4 on Vlan1
Acquired IPv4 address 10.106.37.69 on Interface Vlan1
Received following DHCPv4 options:
bootfile : http://10.106.37.59:80/ztp_http.py
stop Autoip process
OK to enter CLI now...
pnp-discovery can be monitored without entering enable mode
Entering enable mode will stop pnp-discovery
Attempting bootfile http://10.106.37.59:80/ztp_http.py
Loading http://10.106.37.59:80/ztp_http.py
Loading http://10.106.37.59:80/ztp_http.py day0guestshell activated successfully
Current state is: ACTIVATED
day0guestshell started successfully
Current state is: RUNNING
Guestshell enabled successfully
File "/bootflash/guest-share/downloaded_script.py", line 1
print "\n\n Running show version \n\n"
^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print("\n\n Running show version \n\n")? <<<< Code Error
Guestshell destroyed successfully
Script execution success!
HTTP-servicepoortnummer
De HTTP-service luistert op verschillende poorten, zoals 8080, maar de DHCP-configuratie voor optie 67 wijst op 80.
enable
configure terminal
ip dhcp excluded-address 10.0.0.2
ip dhcp pool ZTP_Pool
network 10.0.0.0 255.255.255.0
default-router 10.0.0.1
option 67 ascii http://10.0.0.2:80/ztp_http.py <<<< Change to 8080
IP-adres dupliceren
Controleer het bereik van DHCP en sluit het IP-adres uit dat is toegewezen aan de HTTP-server.
enable
configure terminal
ip dhcp excluded-address 10.0.0.2 <<<< Exclude HTTP server address.
ip dhcp pool ZTP_Pool
network 10.0.0.0 255.255.255.0
default-router 10.0.0.1
option 67 ascii http://10.0.0.2:80/ztp_http.py
HTTP-service controleren, stoppen en opnieuw starten
vm: /var/www/html$ sudo service apache2 stop
vm: /var/www/html$ sudo service apache2 start
vm: /var/www/html$ sudo service apache2 status
Pakketdetailmonsters
HTTP-uitwisselingsoverzicht:
10.0.0.10 10.0.0.2 HTTP 183 GET /http_ztp.py HTTP/1.1 <<<< HTTPGETrequest
10.0.0.2 10.0.0.10 HTTP 245 HTTP/1.1 200 OK (text/x-python) <<<< Response
HTTP-respons in detail:
Hypertext Transfer Protocol
HTTP/1.1 200 OK\r\n
Content-Type: text/x-python\r\n
Content-Length: 20\r\n
Date: Tue, 04 Apr 2023 12:24:02 GMT\r\n
Connection: keep-alive\r\n
Keep-Alive: timeout=5\r\n
\r\n
[HTTP response 1/2]
[Time since request: 0.204568243 seconds]
[Request in frame: 21]
[Next request in frame: 25]
[Next response in frame: 26]
[Request URI: http://10.0.0.2:80/http_ztp.py] >>>> URL