In the last lesson, you saw that NETCONF sends YANG data in XML.
Now you will see how NETCONF works.NETCONF is a protocol that reads and changes the configuration of a device.
It runs over SSH, on TCP port 830.
Figure 1 - NETCONF Runs over SSH
On Cisco IOS XE, one command enables NETCONF:
R1(config)#netconf-yangAnswer the question below
Which TCP port does NETCONF use?
A NETCONF session starts with a hello message.
Your script sends one, and the router sends one.
Figure 2 - Both Sides Send a Hello
Each hello lists capabilities.
A capability is a feature or a YANG model that the sender supports.Your script reads the capabilities to know which YANG models the router supports.
Answer the question below
Which message starts a NETCONF session?
Your script sends each request in an <rpc> message.
The router answers with an <rpc-reply> message.
Figure 3 - A Request and Its Reply
The request names one operation:
get-config reads the configuration.
get reads the configuration and the state data.
edit-config changes the configuration.
Answer the question below
Which operation changes the configuration?
This request reads the interfaces from the running configuration:
<rpc message-id="101" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"> <get-config> <source> <running/> </source> <filter type="subtree"> <interfaces xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces"/> </filter> </get-config> </rpc>The router sends this reply:
<rpc-reply message-id="101" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"> <data> <interfaces xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces"> <interface> <name>GigabitEthernet0/1</name> <description>WAN</description> <enabled>true</enabled> </interface> </interfaces> </data> </rpc-reply>Read the reply in three steps:
message-id is 101, the same value as in the request.
<data> holds the result.
The content follows the ietf-interfaces model.
After an edit-config, a successful reply contains <ok/>.
When the operation fails, the reply contains <rpc-error>.Answer the question below
Which tag holds the result of a get-config?
A datastore is a place where the device stores a configuration.
NETCONF defines three datastores:
running: the configuration that the device uses now.
startup: the configuration that the device loads when it starts.
candidate: a copy that you can change with no effect on the device.

Figure 4 - Changes Go from Candidate to Running
You send your changes to the candidate datastore with edit-config.
Then the commit operation copies the candidate to the running datastore.Not every device supports the candidate datastore.
The hello message tells you if the router supports it.Without the candidate datastore, edit-config changes the running datastore directly.
In the next lesson, you will see how RESTCONF works.
Answer the question below
Which operation applies the candidate configuration?