Hands-On Lab: Configuring RESTCONF

This hands-on lab enables RESTCONF on a router and interacts with it using standard HTTP methods (GET, PATCH) to read and modify interface configuration, contrasting its familiar REST-based approach against the SSH-based NETCONF session covered in the previous lab.

RESTCONF ConfigurationHTTP GET and PATCH MethodsJSON Payload Structure

~3 دقیقه مطالعه · آخرین به‌روزرسانی ۴ مهر ۱۴۰۵

Lab Objective

Enable RESTCONF on a router, retrieve interface configuration using a standard HTTP GET request, modify the interface description using an HTTP PATCH request, and verify the change through the CLI, comparing the overall workflow to NETCONF's approach from the previous lab.

Lab Purpose

NETCONF, covered in the previous lab, uses SSH transport and XML-formatted RPCs, requiring a NETCONF-aware client library. RESTCONF exposes the same underlying YANG-modeled configuration data through a standard HTTPS-based REST API using familiar HTTP verbs, making it accessible from any tool capable of making a basic HTTP request, including curl or a simple script with no specialized NETCONF library.

Lab Topology

R1 ---- Gi0/0: 192.168.255.1/24

Management station: 192.168.255.100,
using curl for RESTCONF interaction

Task 1: Enable RESTCONF on R1

Enable the RESTCONF service alongside the NETCONF service already configured in the previous lab.

Task 2: Retrieve Interface Configuration via HTTP GET

From the management station, issue a GET request to the RESTCONF API for the interface's configuration, requesting JSON format.

Task 3: Modify the Interface Description via HTTP PATCH

Issue a PATCH request updating the interface's description, sending a JSON payload.

Task 4: Verify the Change Through the CLI

Confirm the new description is visible through the traditional CLI.

Task 5: Compare the RESTCONF Workflow Against NETCONF

Note the differences in transport, request format, and tooling required between the two approaches.

Solution and Verification

R1(config)# restconf

-- RESTCONF and NETCONF, covered in the
-- previous lab, can run simultaneously,
-- since both simply expose the same
-- underlying YANG data model through
-- different transport and formatting
-- mechanisms

ManagementStation> curl -k -u admin:password \
  -H "Accept: application/yang-data+json" \
  https://192.168.255.1/restconf/data/ietf-interfaces:interfaces/interface=GigabitEthernet0%2F0

{
  "ietf-interfaces:interface": {
    "name": "GigabitEthernet0/0",
    "description": "",
    "enabled": true
  }
}
-- A plain HTTP GET request, authenticated
-- with basic credentials, returns the
-- exact same interface data NETCONF's
-- get-config RPC provided -- but reachable
-- with a tool as simple as curl

ManagementStation> curl -k -u admin:password -X PATCH \
  -H "Content-Type: application/yang-data+json" \
  -d '{"ietf-interfaces:interface":{"description":"Configured via RESTCONF"}}' \
  https://192.168.255.1/restconf/data/ietf-interfaces:interfaces/interface=GigabitEthernet0%2F0

-- HTTP 204 No Content
-- A 204 response confirms the PATCH was
-- accepted and applied -- the standard
-- HTTP status code for a successful
-- update with no response body needed

R1# show running-config interface gigabitethernet0/0

interface GigabitEthernet0/0
 description Configured via RESTCONF
 ip address 192.168.255.1 255.255.255.0
-- The description set via a simple curl
-- PATCH request is fully visible and
-- effective through the CLI

-- Comparison summary:

NETCONF: SSH transport, XML payloads,
         requires a NETCONF client library
         or specialized tool

RESTCONF: HTTPS transport, JSON (or XML)
          payloads, works with any standard
          HTTP client including curl,
          Postman, or basic scripting
          libraries in virtually any
          programming language

Key Takeaway

RESTCONF and NETCONF expose the identical underlying YANG data model, but RESTCONF's use of standard HTTPS and familiar HTTP verbs (GET, POST, PUT, PATCH, DELETE) makes it significantly more approachable for developers already comfortable with REST APIs, requiring no specialized client library the way NETCONF's SSH-based XML-RPC approach does — the choice between them typically comes down to what the automation toolchain in use already expects, rather than one being definitively superior to the other.

نوشته و پژوهش‌شده توسط دکتر شاهین صیامی

مقالات مرتبط

Hands-On Lab: Final Comprehensive CCNP Troubleshooting Challenge (BGP, DMVPN, and QoS Integration)

This hands-on lab presents a complex multi-layer failure across an integrated BGP-over-DMVPN topology combined with QoS marking, requiring systematic diagnosis of a route reflector misconfiguration, an NHRP registration failure, and an incorrectly applied QoS policy simultaneously affecting the same network.

ادامه

Hands-On Lab: Configuring BGP over DMVPN

This hands-on lab runs iBGP as the routing protocol across the same DMVPN hub-and-spoke topology used in the two previous labs, configuring the hub as a route reflector so spokes learn each other's routes without a full iBGP mesh, combining two previously separate concepts into one integrated design.

ادامه

Hands-On Lab: Configuring OSPF over DMVPN

This hands-on lab runs OSPF as the dynamic routing protocol across the same DMVPN hub-and-spoke topology, configuring the tunnel interface as an OSPF point-to-multipoint network type to correctly handle the hub-and-spoke adjacency pattern without requiring the broadcast network type's DR/BDR election.

ادامه

Hands-On Lab: Configuring EIGRP over DMVPN

This hands-on lab runs EIGRP as the dynamic routing protocol across the DMVPN hub-and-spoke topology built in earlier labs, verifying neighbor relationships form correctly across the multipoint tunnel and routes propagate without requiring per-spoke static configuration on the hub.

ادامه

Hands-On Lab: Configuring HSRP MD5 Authentication

This hands-on lab configures MD5 authentication on an HSRP group, verifying two routers with matching authentication strings form a normal active/standby relationship while a router with a mismatched string is excluded from the group entirely.

ادامه

Hands-On Lab: Configuring Cisco Umbrella-Style DNS Security via DNS Forwarding Redirection

This hands-on lab configures a router to redirect all client DNS queries toward a security-focused DNS resolver using DNS forwarding interception, approximating cloud-delivered DNS security enforcement without requiring per-client configuration changes.

ادامه