SSH Client
A simple SSH connection can also be used as a client application to interact with the NetConf server. Here are the steps to establish a connection and perform a get operation.
Establish a Connection
ssh -s ocnos@10.12.28.43 -p 830 netconf
Send Client Help Message to NetConf Server
Copy and paste this message in the session and perform operations without the Enter key:
<?xml version="1.0" encoding="UTF-8"?>
<hello xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<capabilities>
<capability>urn:ietf:params:netconf:base:1.0</capability>
</capabilities>
</hello>]]>]]>
Note: Only base 1.0 capability is used here though server supports both base 1.0 and 1.1 capabilities. Because the later one mandates the XML encoding type "chunked framing" (RFC 6242, section 4.1), which is not user friendly.
Perform the get operation:
<?xml version="1.0" encoding="UTF-8"?>
<rpc message-id="1" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<get xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"/>
</rpc>]]>]]>
Perform get-config operation:
<rpc message-id="102"
xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<get-config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<source>
<running/>
</source>
</get-config>
</rpc>]]>]]>
Perform edit-config operation:
<rpc message-id="101" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<edit-config>
<target>
<candidate/>
</target>
<config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<ospfv2 xmlns="http://www.ipinfusion.com/yang/ocnos/ipi-ospf">
<processes>
<process>
<ospf-id>20</ospf-id>
<config>
<ospf-id>20</ospf-id>
<shutdown/>
<vrf-name>default</vrf-name>
</config>
</process>
</processes>
</ospfv2>
</config>
</edit-config>
</rpc>]]>]]>
 
Perform commit operation:
<rpc message-id="101" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<commit/>
</rpc>]]>]]>
Perform get-schema operation:
<rpc message-id="101"
xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<get>
<filter type="subtree">
<netconf-state xmlns=
"urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring">
<schemas/>
</netconf-state>
</filter>
</get>
</rpc>]]>]]>
Perform copy-config operation:
<rpc message-id="101"
xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<copy-config>
<target>
<url>file://ZebOS.conf</url>
</target>
<source>
<running/>
</source>
</copy-config>
</rpc>]]>]]>