How to see advertised and received routes via BGP neighbours

bgp-advertised-and-received-routes

When you pass the show ip route command on a cisco router, you are presented with the routing table of the router. This table comprises of the best routes the router has chosen as the primary routes.

 

sh ip route
Codes: L -- local, C -- connected, S -- static, R -- RIP, M -- mobile, B -- BGP
D -- EIGRP, EX -- EIGRP external, O -- OSPF, IA -- OSPF inter area
N1 -- OSPF NSSA external type 1, N2 -- OSPF NSSA external type 2
E1 -- OSPF external type 1, E2 -- OSPF external type 2
i -- IS-IS, su -- IS-IS summary, L1 -- IS-IS level-1, L2 -- IS-IS level-2
ia -- IS-IS inter area, * -- candidate default, U -- per-user static route
o -- ODR, P -- periodic downloaded static route, H -- NHRP, l -- LISP
+ -- replicated route, % -- next hop override
Gateway of last resort not set
 
1.0.0.0/8 is variably subnetted, 2583 subnets, 14 masks
B 1.0.0.0/24 [20/7031] via 10.0.0.1, 2w0d
B 1.0.4.0/22 [20/137121] via 10.0.0.1, 2w1d
B 1.0.4.0/24 [20/137121] via 10.0.0.1, 2w1d
B 1.0.5.0/24 [20/137121] via 10.0.0.1, 2w1d
B 1.0.6.0/24 [20/137121] via 10.0.0.1, 2w1d
B 1.0.7.0/24 [20/137121] via 10.0.0.1, 2w1d
B 1.0.16.0/24 [200/0] via 10.0.0.1, 2w1d
B 1.0.64.0/18 [200/0] via 10.0.0.1, 2w1d
--More--

However, If you want to see the routes received by BGP neighbours only along with key attributes such as AS Path and local preference etc, you can view the BGP routing table by using the show ip bgp command.

 

sh ip bgp
BGP table version is 9501588, local router ID is 10.10.10.1
Status codes: s suppressed, d damped, h history, * valid, > best, i -- internal,
r RIB-failure, S Stale, m multipath, b backup-path, x best-external, f RT-Filter
Origin codes: i -- IGP, e -- EGP, ? -- incomplete
 
Network Next Hop Metric LocPrf Weight Path
*> 1.0.0.0/24 10.0.0.1 7031 4000 0 213964 13335 13335 i
*> 1.0.4.0/24 10.0.0.1 137121 4000 0 213964 4826 38803 56203 i
*> 1.0.4.0/22 10.0.0.1 137121 4000 0 213964 4826 38803 56203 i
*> 1.0.5.0/24 10.0.0.1 137121 4000 0 213964 4826 38803 56203 i
*> 1.0.6.0/24 10.0.0.1 137121 4000 0 213964 4826 38803 56203 i
*> 1.0.7.0/24 10.0.0.1 137121 4000 0 213964 4826 38803 56203 i
*>i1.0.16.0/24 10.0.0.2 0 4000 0 3356 2914 2519 i
*>i1.0.64.0/18 10.0.0.2 0 4000 0 3356 2516 7670 18144 i
--More--

Further to that, the show ip bgp summary command lists all BGP neighbours on the router.

 

sh ip bgp summary
BGP router identifier 10.10.10.1
BGP table version is 9501373, main routing table version 9501373
698513 network entries using 97791820 bytes of memory
1242345 path entries using 69571320 bytes of memory
295132/106926 BGP path/bestpath attribute entries using 37776896 bytes of memory
166524 BGP AS-PATH entries using 6137930 bytes of memory
72 BGP community entries using 1728 bytes of memory
149 BGP route-map cache entries using 5364 bytes of memory
0 BGP filter-list cache entries using 0 bytes of memory
BGP using 211285058 total bytes of memory
BGP activity 900150/201636 prefixes, 3945360/2703015 paths, scan interval 60 secs
 
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
10.20.20.1 4 65177 7783 8563 9501373 0 0 5d09h 0
10.30.30.1 4 65122 22040 237883 9501373 0 0 2w1d 0
10.40.40.1 4 65133 2740502 1522137 9501206 0 0 2w1d 693452

To view which BGP neighbour is advertising which prefixes to you, you can use the show ip bgp neighbor <neighbour ip address> advertised-routes command:

 

sh ip bgp neighbors 10.20.20.1 advertised-routes
BGP table version is 9505142, local router ID is 10.10.10.2
Status codes: s suppressed, d damped, h history, * valid, > best, i -- internal,
r RIB-failure, S Stale, m multipath, b backup-path, x best-external, f RT-Filter
Origin codes: i -- IGP, e -- EGP, ? -- incomplete
 
Network Next Hop Metric LocPrf Weight Path
*> 10.1.1.0/24 10.20.20.2 0 400 i
Total number of prefixes 1

To view what prefixes you are receiving from a given BGP neighbour, you can use the show ip bgp neighbor <neighbour ip address> received-routes command:

 

sh ip bgp neighbors 10.20.20.1 received-routes
BGP table version is 9505142, local router ID is 10.10.10.2
Status codes: s suppressed, d damped, h history, * valid, > best, i -- internal,
r RIB-failure, S Stale, m multipath, b backup-path, x best-external, f RT-Filter
Origin codes: i -- IGP, e -- EGP, ? -- incomplete
 
Network Next Hop Metric LocPrf Weight Path
*> 10.2.2.0/24 10.20.20.1 0 400 i
Total number of prefixes 1

It’s important to remember that the show ip bgp neighbor <neighbor-ip> <advertised/received>-routes command only shows you the attributes of the route BEFORE it was manipulated by a route map (if configured). This command can cause a lot of confusion sometimes if not used with this in mind.

The output of the command shows the routes AS they were received and AS they were advertised before a route map was applied to manipulate BGP attributes.

Got questions? Leave a comment! Let’s chat.

Rafay Rasool is a Network Specialist with over 10 years of experience designing, configuring and implementing core network solutions based predominantly but not limited to Juniper Routers, Switches and Firewalls along with other vendors such as Cisco, Huawei, Siemens, Aerohive, Ringmaster, Pulse etc for Internet Service Provider and Enterprise Networks.

Rafay is an avid supporter of network automation and likes to code and automate networking solutions.