COMP347 Unit 8 – Network Management and Network Operations
After completing this extended tutorial, you should be able to:
Network automation is the use of software, scripts, and APIs to perform network configuration, monitoring, and management tasks with minimal human intervention. It is a critical enabler for modern, scalable, and agile network operations. This tutorial provides a comprehensive, in‑depth exploration of network automation, focusing on the key protocols and interfaces: NETCONF, RESTCONF, and REST APIs. We begin with the fundamentals: drivers for automation (scale, speed, consistency), the distinction between imperative (scripting) and declarative (intent‑based) approaches, and the importance of idempotency.
We then dive into NETCONF (RFC 6241), a network configuration protocol that uses XML and YANG for structured data, supporting transactional changes, candidate configurations, and rollback. We cover its operations (get, get‑config, edit‑config, copy‑config, delete‑config, lock, unlock, commit, etc.) and illustrate with examples. RESTCONF (RFC 8040) is presented as a RESTful alternative to NETCONF, using HTTP/JSON and YANG, making it easier for web‑friendly applications. We also discuss vendor‑specific REST APIs (e.g., Cisco, Juniper) that offer similar capabilities. The role of YANG models is emphasized throughout, as they provide the data structure for both protocols.
We explore automation tools (Ansible, Terraform, Python scripts), and how to integrate them with CI/CD pipelines. Security considerations (authentication, authorization, encryption) are addressed. Case studies illustrate successful automation implementations, from cloud provider networks to enterprise campus environments. The quiz, exercises, and homework are designed to build both theoretical and practical skills.
Network automation is the practice of using software to perform networking tasks that were traditionally done manually via CLI. Key drivers:
Automation can be applied to provisioning, configuration, compliance, troubleshooting, and reporting.
NETCONF (Network Configuration Protocol) is defined in RFC 6241. It uses an SSH‑based transport (or sometimes TLS) and XML encoding. It provides:
Example of an edit‑config RPC:
<rpc message-id="101">
<edit-config>
<target>
<running/>
</target>
<config>
<interfaces xmlns="urn:example:interfaces">
<interface>
<name>eth0</name>
<enabled>true</enabled>
</interface>
</interfaces>
</config>
</edit-config>
</rpc>
NETCONF also supports notifications (event‑driven messages) and is widely implemented in modern devices.
RESTCONF (RFC 8040) is a RESTful protocol that uses HTTP methods (GET, POST, PUT, PATCH, DELETE) to interact with YANG‑defined data. It uses JSON or XML encoding, typically over HTTPS. It provides:
Example: To get the system hostname:
GET /restconf/data/system/hostname
Response (JSON):
{
"system:hostname": "router1"
}
YANG (RFC 7950) is the data modeling language used by both NETCONF and RESTCONF. It defines the structure of configuration and state data. In automation, YANG models:
Automation tools like Ansible can use YANG models (via `yang` modules) to validate configurations before applying.
Many vendors provide proprietary REST APIs (e.g., Cisco DNA Center, Juniper Mist, Arista CloudVision). These APIs often use JSON over HTTPS and offer a higher‑level abstraction than NETCONF/RESTCONF, often catering to specific use cases (e.g., intent‑based networking). They are important for automation because:
When selecting an API, consider: coverage, stability, rate limits, and authentication mechanisms (OAuth, API keys).
Choice depends on team skills, device types, and integration needs.
Applying DevOps principles to networking involves:
This reduces lead time for changes and improves reliability.
All answers are hidden; click Show Answer to reveal.
Define network automation and list its main drivers.
Explain the principle of idempotency in automation.
What is the difference between declarative and imperative automation?
Which protocol is defined in RFC 6241?
What transport protocol does NETCONF typically use?
Name three NETCONF operations.
What is a candidate configuration in NETCONF?
What is the primary advantage of NETCONF over CLI scripting?
Which protocol is defined in RFC 8040?
What transport protocol does RESTCONF use?
Name the HTTP methods used by RESTCONF and their purposes.
What data encoding formats does RESTCONF support?
How does RESTCONF handle the concept of a candidate configuration?
What is YANG and why is it important for automation?
What is the role of OpenConfig in network automation?
List three automation tools mentioned in the tutorial.
What is the benefit of storing automation code in version control (Git)?
Explain the concept of Infrastructure as Code (IaC) in networking.
What is a CI/CD pipeline in the context of network automation?
How can you secure an automation API?
What is the difference between NETCONF and RESTCONF in terms of state management?
What is the purpose of the `validate` operation in NETCONF?
How does RESTCONF handle YANG lists and containers in URLs?
What is the role of a YANG module in NETCONF/RESTCONF?
What is the purpose of the `lock` operation in NETCONF?
Can RESTCONF use XML as well as JSON?
What is the default TCP port for NETCONF over SSH?
What is the purpose of an Ansible playbook?
How can you test automation changes without affecting production?
What is the advantage of using Python with `ncclient` over Ansible for NETCONF?
Explain the concept of "state" vs. "configuration" in YANG models.
How does RESTCONF represent a YANG leaf‑list?
What is the purpose of a "commit" operation in NETCONF?
What is the role of a "notification" in NETCONF?
How can you authenticate to a RESTCONF server?
What is the main advantage of using declarative tools like Terraform over script‑based automation?
What is a "data store" in the context of NETCONF?
How does RESTCONF support the retrieval of operational state data?
What are the benefits of using a network automation platform like Cisco NSO?
Explain the term "drift" in the context of automation.
What is the purpose of a "dry‑run" in automation?
How can you use Git branches in network automation?
What is the role of a "webhook" in automation?
Why is monitoring important after an automated change?
What is the difference between `edit-config` and `copy-config` in NETCONF?
How can you ensure that automation scripts are idempotent when using NETCONF?
Sample solutions are hidden – click to reveal.
Write a NETCONF RPC (XML) to retrieve the running configuration of a device.
<rpc message-id="101">
<get-config>
<source>
<running/>
</source>
</get-config>
</rpc>
Write a RESTCONF GET request to retrieve the interface list (using JSON). Specify the URL and expected response.
URL: GET /restconf/data/interfaces
Response: JSON object containing a list of interfaces with their attributes.
Explain the steps to perform a configuration change using NETCONF with a candidate datastore.
Write a Python snippet using `ncclient` to connect to a NETCONF device and retrieve the hostname.
from ncclient import manager
with manager.connect(host='10.0.0.1', port=830, username='user', password='pass', hostkey_verify=False) as m:
result = m.get_config('running', filter=('subtree', ' '))
print(result)
Explain the difference between using `edit-config` with `operation="replace"` vs. `operation="merge"`.
Write an Ansible playbook to enable an interface on a Cisco router using the `ios_config` module.
- name: Enable interface
hosts: routers
tasks:
- name: Set interface up
ios_config:
lines:
- no shutdown
parents: interface GigabitEthernet0/1
How can you use Terraform to manage a network device via RESTCONF? (Conceptual)
Explain the security measures you would implement for a RESTCONF API exposed on the internet.
What is the purpose of a `lock` in NETCONF and when would you use it?
Write a NETCONF RPC to delete a specific interface configuration.
<rpc>
<edit-config>
<target><candidate/></target>
<config>
<interfaces xmlns="urn:example:interfaces">
<interface operation="delete">
<name>eth0</name>
</interface>
</interfaces>
</config>
</edit-config>
</rpc>
How can you test a NETCONF RPC without affecting the device?
Describe the steps to integrate network automation with a CI/CD pipeline using GitLab CI.
Explain the concept of "configuration drift" and how automation can prevent it.
Write a Python script using `requests` to GET the system hostname from a RESTCONF server.
import requests
url = "https://device/restconf/data/system/hostname"
headers = {"Accept": "application/yang-data+json"}
auth = ("user", "pass")
response = requests.get(url, headers=headers, auth=auth, verify=False)
print(response.json())
What is the role of YANG in NETCONF? How would you define a new data model?
Explain the difference between HTTP PATCH and PUT in RESTCONF.
How would you handle authentication in an automated script that uses both CLI and API methods?
Design a high‑level automation architecture for a global enterprise with 1000 devices. Include components for configuration deployment, compliance, and monitoring.
What is the purpose of the `capabilities` exchange in NETCONF?
Write an Ansible task to retrieve and print the running config of a device using the `ios_command` module.
- name: Show running config
ios_command:
commands: show running-config
register: result
- debug: var=result.stdout_lines
Explain how you can use YANG models in Ansible to validate configs before deployment.
What are the advantages of using RESTCONF over NETCONF for cloud‑native applications?
Write a NETCONF RPC to perform a `commit` operation.
<rpc message-id="102">
<commit/>
</rpc>
How can you implement a rollback in NETCONF if a commit fails?
Sample answers are hidden; use them to guide your study.
Write a detailed comparison of NETCONF and RESTCONF, including their architectures, transport, data encoding, operations, and use cases. Provide examples of when to use each.
NETCONF is session‑based, uses SSH, XML, and supports candidate/commit. RESTCONF is HTTP‑based, uses JSON/XML, and is simpler for web applications. Use NETCONF for complex, transactional changes; RESTCONF for lightweight automation.
Design an automation solution for provisioning a new branch office network (router, switch, firewall) using Ansible and RESTCONF. Include a network topology, variable definitions, and playbook structure.
Topology: Edge router, core switch, firewall. Use group vars for site‑specific data. Playbook: tasks to configure each device using appropriate modules (ios_config, etc.). Use YANG models where possible.
Research and explain the YANG data models used by OpenConfig for BGP. Show how you would use NETCONF to retrieve BGP neighbors.
OpenConfig BGP model: `/bgp/neighbors/neighbor`. Use `get` with filter to retrieve the subtree.
Implement a Python script using `ncclient` to modify the SNMP community string on a device using a candidate configuration, validate, and commit.
Script outline: connect, lock candidate, edit‑config (replace community), validate, commit, unlock. Handle exceptions and rollback.
Explain the role of `git` in network automation and describe a typical workflow for implementing a change (from code to production).
Workflow: developer creates branch, edits code, opens pull request, peer review, merge to main, CI/CD pipeline triggers automated testing and deployment to staging, then to production after approval.
Analyze the security implications of exposing a RESTCONF API to a management network. What measures would you implement to secure it?
Use TLS, client certificates, RBAC, IP whitelisting, audit logging, and rate limiting. Also, use strong authentication tokens and rotate them.
Write a detailed guide on how to use Terraform to manage a network device (e.g., a router) with RESTCONF, including provider configuration and resource definitions.
Use the `restconf` provider. Define resources with paths and payloads matching YANG. Example: `resource "restconf_data" "hostname" { path = "/system/hostname" content = "router1" }`
Describe the process of implementing a CI/CD pipeline for network configurations using GitLab CI, including stages for linting, validation, dry‑run, and deployment.
.gitlab-ci.yml defines jobs: lint (using yang‑tools), validate (syntax), dry‑run (against lab), deploy‑staging (apply to staging), deploy‑prod (manual job with approval).
Explain how you can use `pyang` to validate a YANG module before using it in automation.
Compare and contrast Ansible and Terraform for network automation. In what scenarios would you choose one over the other?
Design a monitoring feedback loop that automatically triggers a rollback if a configuration change causes a drop in service health.
Write a research paper on the evolution from CLI to NETCONF/RESTCONF and the impact on network engineering roles.
Explain the concept of "service abstraction" in network automation and how it can be implemented using YANG models and APIs.
Design a configuration compliance check using RESTCONF to verify that all interfaces have a description set.
Discuss the challenges of automating network devices from multiple vendors and how YANG and OpenConfig can address them.
Write a case study on a company that successfully implemented network automation, including the tools used, the challenges faced, and the outcomes.
Explain the role of NETCONF notifications in an automation system. Provide an example of a notification that could trigger an automated response.
Analyze the impact of network automation on network security: both the benefits (e.g., consistent policies, faster patching) and the risks (e.g., misconfigured automation, API exposure).
This extended tutorial has provided a comprehensive exploration of network automation, focusing on NETCONF, RESTCONF, and REST APIs. We covered the drivers and principles of automation (idempotency, declarative vs. imperative), and dove deep into the NETCONF and RESTCONF protocols, their operations, and their use of YANG data models. We also examined vendor‑specific REST APIs, automation tools (Ansible, Terraform, Python), and the integration of automation into CI/CD pipelines. Security considerations and best practices were discussed, along with case studies illustrating real‑world implementations.
Network automation is a critical skill for modern network professionals, enabling scale, speed, and consistency. The quiz, exercises, and homework assignments are designed to build both theoretical knowledge and practical experience. In the next tutorial, we will explore SDN Management and Programmable Networks, extending automation concepts to software‑defined architectures.
COMP347 Unit 8 – Extended Tutorial 10 • TrustOpen University • Last updated: August 2026