networktocode / ntc-templates

TextFSM templates for parsing show commands of network devices
https://ntc-templates.readthedocs.io/
Other
1.1k stars 718 forks source link

cisco_ios BGP neighbor advertised and received routes request. #663

Closed delhipnr closed 4 years ago

delhipnr commented 4 years ago

Hi,

I am requesting a new feature in ntc_template "cisco_ios" family. Can you please check if there is a way to get the routes that we are advertising to a specific neighbor within or without a VRF? I am sending both commands output from device a cisco testing router with vrf (name is "part" it could be anything) and without VRF.

This is what we are receiving from a BGP neighbor in a specific VRF(part).

R1#show ip bgp vpnv4 vrf part neighbors 10.10.13.3 routes
BGP table version is 17, local router ID is 1.1.1.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,
              x best-external, a additional-path, c RIB-compressed,
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found

     Network          Next Hop            Metric LocPrf Weight Path
Route Distinguisher: 100:100 (default for vrf part)
 *>  1.1.1.1/32       10.10.13.3               0             0 65001 ?
 *>  1.1.1.2/32       10.10.13.3               0             0 65001 ?
 *>  1.1.1.3/32       10.10.13.3               0             0 65001 ?
 r>  10.10.13.0/24    10.10.13.3               0             0 65001 ?
 *>  192.168.254.0    10.10.13.3               0             0 65001 ?

Total number of prefixes 5

This is what we are sending to a BGP neighbor in a specific VRF(part).

R1#show ip bgp vpnv4 vrf part neighbors 10.10.13.3 advertised-routes
BGP table version is 17, local router ID is 1.1.1.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,
              x best-external, a additional-path, c RIB-compressed,
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found

     Network          Next Hop            Metric LocPrf Weight Path
Route Distinguisher: 100:100 (default for vrf part)
 *>  11.11.11.11/32   0.0.0.0                  0         32768 i
 *>  11.11.11.12/32   0.0.0.0                  0         32768 i
 *>  11.11.11.13/32   0.0.0.0                  0         32768 i
 *>  11.11.11.14/32   0.0.0.0                  0         32768 i
 *>  11.11.11.15/32   0.0.0.0                  0         32768 i

Total number of prefixes 5
R1#

This is what we are receiving from a BGP neighbor.

R1#show ip bgp neighbors 10.0.14.4 routes
BGP table version is 9, local router ID is 1.1.1.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,
              x best-external, a additional-path, c RIB-compressed,
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found

     Network          Next Hop            Metric LocPrf Weight Path
 *>  1.1.1.4/32       10.0.14.4                0             0 65001 ?
 *   10.0.14.0/24     10.0.14.4                0             0 65001 ?
 *>  10.10.14.0/24    10.0.14.4                0             0 65001 ?
 *>  44.0.0.1/32      10.0.14.4                0             0 65001 ?
 *>  44.0.0.2/32      10.0.14.4                0             0 65001 ?
 *>  44.0.0.3/32      10.0.14.4                0             0 65001 ?
 *>  44.0.0.4/32      10.0.14.4                0             0 65001 ?

Total number of prefixes 7
R1#

This is what we are sending to a BGP neighbor.

R1#show ip bgp neighbors 10.0.14.4 advertised-routes
BGP table version is 9, local router ID is 1.1.1.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,
              x best-external, a additional-path, c RIB-compressed,
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found

     Network          Next Hop            Metric LocPrf Weight Path
 *>  1.1.1.1/32       0.0.0.0                  0         32768 ?
 *>  10.0.14.0/24     0.0.0.0                  0         32768 ?

Total number of prefixes 2
R1#

I do remember in the "cisco_ios" module "show ip route summary" command does work for any VRF table to. for example, input data for ntc_teamplate is "show ip route vrf part summary" from cisco device and ntc_command "show ip route summary" works perfectly.

If id talk about BGP neighbors the only difference is it has an additional line before printing the route table, have a look at this.

Network          Next Hop            Metric LocPrf Weight Path
Route Distinguisher: 100:100 (default for vrf part)
 *>  1.1.1.1/32       10.10.13.3               0             0 65001 ?

if I do put VRF into it, it says "Route Distinguisher: 100:100 (default for vrf part)" a new additional line. if you can do this in a similar way and keep blank in case of without VRF then a single command can work for it.

Also, it is not about to below command as most of the production deployment doesn't allow soft-reconfiguration please do consider only "routes", not "received-routes".

R1#show ip bgp neighbors 10.0.14.4 received-routes
% Inbound soft reconfiguration not enabled on 10.0.14.4
R1#

Thank You.

delhipnr commented 4 years ago

I Just want to check on it. Please correct me if i am not requesting NEW FEATURES in correct forum, Or if i need to do any additional exercise 😁

FragmentedPacket commented 4 years ago

@delhipnr We typically don't add in the new features and definitely not within any sort of time frame.

I suggest you take a stab at it as it appears you do notice the only difference between the two appears to be the Route Distinguisher line.

If you need help we can definitely offer the help, but looks like you're already on your way.

FragmentedPacket commented 4 years ago

@delhipnr I submitted a PR for this. Does this work as you'd expect?