Description

The following steps shows how to retrieve switch information using netconf.

Symptoms

You want to get switch information using netconf.

Solution

Enable the netconf service on the Juniper Networks EX/QFX series switches:

system {
    services {        
        netconf {
            ssh;
        }

    
From the netconf client establish an SSH connection to the switch using the following format:
ssh user@deviceip -s netconf 

For example:
~$ ssh [email protected] -s netconf
Local password:

The following messages and prompt will be displayed:

<!-- No zombies were killed during the creation of this user interface -->
<!-- user root, class super-user -->
<hello xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
  <capabilities>
    <capability>urn:ietf:params:netconf:base:1.0</capability>
    <capability>urn:ietf:params:netconf:capability:candidate:1.0</capability>
    <capability>urn:ietf:params:netconf:capability:confirmed-commit:1.0</capability>
    <capability>urn:ietf:params:netconf:capability:validate:1.0</capability>
    <capability>urn:ietf:params:netconf:capability:url:1.0?scheme=http,ftp,file</capability>
    <capability>urn:ietf:params:xml:ns:netconf:base:1.0</capability>
    <capability>urn:ietf:params:xml:ns:netconf:capability:candidate:1.0</capability>
    <capability>urn:ietf:params:xml:ns:netconf:capability:confirmed-commit:1.0</capability>
    <capability>urn:ietf:params:xml:ns:netconf:capability:validate:1.0</capability>
    <capability>urn:ietf:params:xml:ns:netconf:capability:url:1.0?scheme=http,ftp,file</capability>
    <capability>urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring</capability>
    <capability>http://xml.juniper.net/netconf/junos/1.0</capability>
    <capability>http://xml.juniper.net/dmi/system/1.0</capability>
  </capabilities>
  <session-id>20051</session-id>
</hello>
]]>]]>

Here is where you can type or paste the RPC requests, the following is an example to get the ARP table entries:

<rpc>
   <get-arp-table-information/>
</rpc>
]]>]]

And the result will be the following:


]]>]]><rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:junos="http://xml.juniper.net/junos/21.4R0/junos">
<arp-table-information xmlns="http://xml.juniper.net/junos/21.4R0/junos-arp" junos:style="normal">
<arp-table-entry>
<mac-address>
00:00:5e:00:01:0f
</mac-address>
<ip-address>
192.168.10.25
</ip-address>
<hostname>
192.168.10.25
</hostname>
<interface-name>
me0.0
</interface-name>
<arp-table-entry-flags>
<none/>
</arp-table-entry-flags>
</arp-table-entry>
<arp-table-entry>
<mac-address>
00:31:46:22:83:f4
</mac-address>
<ip-address>
192.168.10.1
</ip-address>
<hostname>
192.168.10.1
</hostname>
<interface-name>
me0.0
</interface-name>
<arp-table-entry-flags>
<none/>
</arp-table-entry-flags>
</arp-table-entry>
<arp-table-entry>
<mac-address>
02:00:00:00:00:0b
</mac-address>
<ip-address>
128.0.0.5
</ip-address>
<hostname>
re1
</hostname>
<interface-name>
bme0.0
</interface-name>
<arp-table-entry-flags>
<permanent/>
</arp-table-entry-flags>
</arp-table-entry>
<arp-table-entry>
<mac-address>
02:00:00:00:00:0b
</mac-address>
<ip-address>
128.0.0.6
</ip-address>
<hostname>
backup
</hostname>
<interface-name>
bme0.0
</interface-name>
<arp-table-entry-flags>
<permanent/>
</arp-table-entry-flags>
</arp-table-entry>
<arp-table-entry>
<mac-address>
02:00:00:00:00:0b
</mac-address>
<ip-address>
128.0.0.17
</ip-address>
<hostname>
fpc1
</hostname>
<interface-name>
bme0.0
</interface-name>
<arp-table-entry-flags>
<permanent/>
</arp-table-entry-flags>
</arp-table-entry>
<arp-entry-count>
5
</arp-entry-count>
</arp-table-information>
</rpc-reply>
]]>


Refer to the following Juniper TechLibrary for more information:

https://www.juniper.net/documentation/us/en/software/junos/netconf/topics/task/netconf-requesting-operational-information.html

Modification History

05-05-2023 KB created