cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
311
Views
1
Helpful
2
Replies

Need moquery to find all the svi and routed subnets configure on L3out

Hi Guys,

I am gathering some info from one ACI Fabric, my end goal is to get the moqueries with grep filters to list out all the ip's configure on the l3outs. Rather it the routed interface or svi. Need Help

2 Replies 2

Marcel Zehnder
Spotlight
Spotlight

Hi

moquery -c l3extRsPathL3OutAtt -x rsp-subtree=full | grep addr | grep -v TC | awk '{print $3}' | sort | uniq

HTH

RedNectar
VIP
VIP

Hi @danial.tahir19911 ,

It seems to me that @Marcel Zehnder 's answer is correct - although I'll offer a refinement below, but first:

If your question has been answered, it is a great idea to mark the question as being answered.  This helps:

  1. others with a similar problem find the correct answer
  2. people who look for "unanswered" questions to answer finding this
  3. prevent your question from becoming a "dead thread"

I found @Marcel Zehnder suggestion gave me more than I needed:

admin@apic1:~> moquery -c l3extRsPathL3OutAtt -x rsp-subtree=full | grep addr | grep -v TC | awk '{print $3}' | sort | uniq
10.101.1.201/24
10.102.1.201/24
10.103.1.201/24
10.10.4.2/25
10.1.11.1/24
10.1.11.2
10.2.1.1/24

The  10.1.11.2 address is the address of a BGP peer that gets included in the output of  moquery -c l3extRsPathL3OutAtt -x rsp-subtree=full

# bgp.PeerP
addr : 10.1.11.2

On closer inspection, I'm not quite sure why the -x rsp-subtree=full was included.  I could only find IPs configured on the l3Outs under l3ext.RsPathL3OutAtt.addr

So my solution was to just simplify the moquery command to.

admin@apic1:~> moquery -c l3extRsPathL3OutAtt | grep addr | sort | uniq | awk '{print $3}'
10.101.1.201/24
10.102.1.201/24
10.103.1.201/24
10.10.4.2/25
10.1.11.1/24
10.2.1.1/24

But I actually found it more useful (for my purposes) to also include the VLAN used on each IP, (and I didn't care about sort order anyway - and I don't have any duplicates) so I modified it to

admin@apic1:~> moquery -c l3extRsPathL3OutAtt | egrep "addr |encap " | awk '{print $3}'
10.10.4.2/25
vlan-204
10.1.11.1/24
vlan-414
10.2.1.1/24
vlan-416
10.101.1.201/24
vlan-1411
10.102.1.201/24
vlan-1421
10.103.1.201/24
vlan-1431

What about icurl?

I know you asked for an moquery command, but I'm beginning to find that icurl is a better option, especially when combined with the power of the JSON query app - jq. I think the following is more useful and elegant than the moquery solution,

admin@apic1:~> icurl http://localhost/api/node/class/l3extRsPathL3OutAtt.json | jq '.imdata[].l3extRsPathL3OutAtt.attributes |.addr, .encap'
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  7087  100  7087    0     0   276k      0 --:--:-- --:--:-- --:--:--  276k
"10.10.4.2/25"
"vlan-204"
"10.1.11.1/24"
"vlan-414"
"10.2.1.1/24"
"vlan-416"
"10.101.1.201/24"
"vlan-1411"
"10.102.1.201/24"
"vlan-1421"
"10.103.1.201/24"
"vlan-1431"

Using jq, you can get really fancy

admin@apic1:~> icurl http://localhost/api/node/class/l3extRsPathL3OutAtt.json | jq '.imdata[].l3extRsPathL3OutAtt.attributes | {IP_addr: .addr, VLAN: .encap}'
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  5426  100  5426    0     0   240k      0 --:--:-- --:--:-- --:--:--  240k
{
  "IP_addr": "10.10.4.2/25",
  "VLAN": "vlan-204"
}
{
  "IP_addr": "10.1.11.1/24",
  "VLAN": "vlan-414"
}
{
  "IP_addr": "10.2.1.1/24",
  "VLAN": "vlan-416"
}
{
  "IP_addr": "10.101.1.201/24",
  "VLAN": "vlan-1411"
}
{
  "IP_addr": "10.102.1.201/24",
  "VLAN": "vlan-1421"
}
{
  "IP_addr": "10.103.1.201/24",
  "VLAN": "vlan-1431"
}

 

RedNectar aka Chris Welsh.
Forum Tips: 1. Paste images inline - don't attach. 2. Always mark helpful and correct answers, it helps others find what they need.

Save 25% on Day-2 Operations Add-On License