Skip to content

Instantly share code, notes, and snippets.

@steele-ntwrk
Last active October 30, 2021 05:24
Show Gist options
  • Select an option

  • Save steele-ntwrk/6abce6e73972d9f58d82151d401e87b3 to your computer and use it in GitHub Desktop.

Select an option

Save steele-ntwrk/6abce6e73972d9f58d82151d401e87b3 to your computer and use it in GitHub Desktop.
NETCONF

NETCONF

NETCONF was developed in 2006 in RFC 4741 and its sole purposed was to replace SNMP. Although it wasn't effective until YANG data models were introducted in 2010 and NETCONF was revised in RFC6241.

NETCONF is a network protocol used to transmit data from network devices to another system and vice versea, it's built on top of ssh however uses port TCP 830 and uses XML Encoding Data format.

3 Key things it can do is:

  1. GET Opertaional State

  2. GET Configuration State

  3. Edit Configuration State

Message Composed of the compotents

  • Transport = TCP/SSH 830
  • Message = <rpc> is a message id and is expecte don return
  • Operation Type = <get> <get-config> <edit-config>
  • Content = Data Payload i.e YANG data model

NETCONF Communcation Process

  1. Connect to device and say hello
  2. Server returns capabilites
  3. Determin model to use
  4. Compose Operation i.e
  5. Send Message
  6. Client Recieves devices
  7. Client Processes data.

Using NETCONF

Insturcutions on setting up NETCONF on a IOS-XE device and using NETCONF

Configuring

enable 
conf t
hostname blah
ip domain name byu.edu.au
##Set authentication##
crypto key generate rsa 1024
ip ssh version 2
line vty 0 4
transport input ssh
## Configure IP Connectivity
netconf ssh
netconf-yang

Basic Python Script to connect

from ncclient import manager
from netconf_router import router

config_template = open(
    "D:/Documents/Git Hub Project/CBT-Nuggets-DevNet-1/netconf-editconfig.xml").read()

netconf_config = config_template.format(
    interface_name="GigabitEthernet2", interface_desc="Hello World"
)

with manager.connect(host=router["host"], port=router["port"], username=router["username"], password=router["password"],
                     hostkey_verify=False) as m:
    device_reply = m.edit_config(netconf_config, target="running")
    print(device_reply)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment