Cisco CCNA Preparation · lesson 36 of 36 · 25 min
Why Network Programmability?
Traditional network management relies on CLI — an engineer SSHs into each device and types commands. This does not scale: a change affecting 500 devices requires 500 SSH sessions. Network programmability uses APIs, automation tools, and data models to manage networks programmatically — making changes consistently, quickly, and at scale.
The CCNA exam covers: Python basics for networking, REST APIs, NETCONF, YANG data models, and configuration management tools (Ansible, Puppet, Chef).
Python Basics for Networking
Python is the dominant language for network automation. The Netmiko and Paramiko libraries handle SSH connections to network devices. NAPALM provides a vendor-neutral abstraction layer. Nornir is a framework for running tasks against many devices in parallel.
REST APIs
A REST API (Representational State Transfer) uses standard HTTP methods to interact with network systems. DNA Center, Cisco Meraki, and many other platforms expose REST APIs.
Data formats
REST APIs typically use JSON (JavaScript Object Notation) for data exchange — lightweight, human-readable, easy to parse in Python. Some APIs also support XML. NETCONF uses XML exclusively.
NETCONF and YANG
NETCONF (Network Configuration Protocol, RFC 6241) is a protocol for managing network device configurations. It uses XML over SSH (port 830). It supports transactions (commit/rollback), candidate configurations, and locking — making it safer than CLI for automated changes.
YANG (Yet Another Next Generation, RFC 6020) is a data modelling language that defines the structure of configuration and state data. YANG models describe what data a device supports and how it is organised. NETCONF uses YANG models to validate configurations before applying them.
Configuration Management Tools
Ansible for networking
Ansible is the most widely used tool for network automation because it is agentless — no software needs to be installed on network devices. It connects via SSH or API. Playbooks are written in YAML and are human-readable. Cisco provides Ansible modules for IOS, IOS-XE, NX-OS, and DNA Center.
Knowledge Check — 10 Questions
Network Programmability
What Python library is most commonly used to SSH into network devices and send CLI commands?
- Requests
- Netmiko
- Flask
- Scapy
Answer: Netmiko
Netmiko is a multi-vendor SSH library built on Paramiko. It simplifies connecting to Cisco, Juniper, Arista, and other devices to send commands and parse output.
Which HTTP method is used to retrieve data from a REST API?
- POST
- PUT
- GET
- DELETE
Answer: GET
GET retrieves data without modifying it. POST creates new resources. PUT replaces resources. DELETE removes resources. PATCH partially updates resources.
What data format do most REST APIs use for request and response bodies?
- XML only
- CSV
- JSON
- YAML
Answer: JSON
JSON (JavaScript Object Notation) is the dominant data format for REST APIs — lightweight, human-readable, and easy to parse in Python with the json library.
What port does NETCONF use?
- 22 (SSH)
- 443 (HTTPS)
- 830 (SSH)
- 161 (SNMP)
Answer: 830 (SSH)
NETCONF runs over SSH on port 830. It uses XML for data encoding and supports transactions (commit/rollback) for safe automated configuration changes.
What is YANG?
- A Python library for network automation
- A data modelling language that defines the structure of network device configuration and state data
- A REST API framework
- A Cisco proprietary protocol
Answer: A data modelling language that defines the structure of network device configuration and state data
YANG (RFC 6020) defines data models for network devices. NETCONF uses YANG models to validate configurations. Think of YANG as the schema that describes what data a device supports.
What is the key advantage of Ansible over Puppet and Chef for network automation?
- Ansible is faster
- Ansible is agentless — no software needs to be installed on network devices
- Ansible supports more vendors
- Ansible uses Python natively
Answer: Ansible is agentless — no software needs to be installed on network devices
Ansible connects via SSH or API — no agent required on managed devices. This is critical for network devices (routers, switches) that cannot run arbitrary software.
What does the NETCONF edit-config operation do?
- Retrieves the current configuration
- Modifies configuration in a datastore
- Validates configuration against YANG models
- Locks the datastore
Answer: Modifies configuration in a datastore
edit-config modifies configuration in the running, candidate, or startup datastore. Combined with commit (for candidate), it provides transactional configuration management.
What language are Ansible playbooks written in?
- Python
- Ruby
- YAML
- JSON
Answer: YAML
Ansible playbooks are written in YAML — human-readable, structured, and easy to version control. Tasks in playbooks call Ansible modules (including Cisco IOS modules).
The Python library _____ provides a vendor-neutral API for retrieving facts and pushing configurations to multi-vendor network devices.
Answer: NAPALM
NAPALM (Network Automation and Programmability Abstraction Layer with Multivendor support) abstracts vendor differences — the same Python code works for Cisco IOS, Junos, EOS, and NX-OS.
What is the main benefit of using APIs and automation for network management compared to manual CLI?
- APIs are more secure than SSH
- Automation enables consistent, scalable changes across hundreds of devices without manual per-device CLI
- APIs eliminate the need for network engineers
- Automation only works with Cisco devices
Answer: Automation enables consistent, scalable changes across hundreds of devices without manual per-device CLI
Manual CLI does not scale. Automation applies changes consistently to hundreds of devices simultaneously, reduces human error, and enables version-controlled infrastructure as code.
Previous lesson: Cisco DNA Center: intent-based networking, assurance, policy, provisioning
Back to Cisco CCNA Preparation