Professional Documents
Culture Documents
BGP - Checking BGP Rejected and received prefix
BGP - Checking BGP Rejected and received prefix
Router1-
interface fastethernet 0/0
ip address 192.168.1.1 255.255.255.252
!
interface Loopback0
ip address 1.1.1.1 255.255.255.255
!
router bgp 100
neighbor 192.168.1.2 remote-as 200
neighbor 192.168.1.2 route-map REJECT in
neighbor 192.168.1.2 soft-reconfiguration inbound
network 1.1.1.1 mask 255.255.255.255
!
route-map REJECT deny 10
match ip address 10
!
route-map REJECT permit 20
!
access-list 10 permit host 4.4.4.4
!
Router2-
interface fastethernet 0/0
ip address 192.168.1.2 255.255.255.252
!
interface Loopback0
ip address 2.2.2.2 255.255.255.255
!
interface Loopback1
ip address 3.3.3.3 255.255.255.255
!
interface Loopback2
ip address 4.4.4.4 255.255.255.255
!
router bgp 200
neighbor 192.168.1.1 remote-as 100
neighbor 192.168.1.1 soft-reconfiguration inbound
network 2.2.2.2 mask 255.255.255.255
network 3.3.3.3 mask 255.255.255.255
network 4.4.4.4 mask 255.255.255.255
!
When the BGP session is established, the BGP peers exchange the routes. Since Router1 is
configured with an inbound route-map that rejects 4.4.4.4/32 prefix, it is not stored in its BGP
table.
Router1 BGP output
Router1#show ip bgp summary
BGP router identifier 1.1.1.1, local AS number 100
BGP table version is 5, main routing table version 5
4 network entries using 468 bytes of memory
4 path entries using 208 bytes of memory
3/3 BGP path/bestpath attribute entries using 372 bytes of memory
1 BGP AS-PATH entries using 24 bytes of memory
0 BGP route-map cache entries using 0 bytes of memory
0 BGP filter-list cache entries using 0 bytes of memory
BGP using 1072 total bytes of memory
1 received paths for inbound soft reconfiguration
BGP activity 12/8 prefixes, 12/8 paths, scan interval 60 secs
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
192.168.1.2 4 200 19 17 0 0 0 00:00:21 2
Router1# show ip bgp
BGP table version is 5, 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
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*> 1.1.1.1/32 0.0.0.0 0 32768 i
*> 2.2.2.2/32 192.168.1.2 0 0 200 i
*> 3.3.3.3/32 192.168.1.2 0 0 200 i
As it can be seen that Router1 does not install 4.4.4.4/32 in its BGP table. To view all BGP
received-routes (both accepted and rejected), the show ip bgp neighbors 192.168.1.2
received-routes command.
show ip bgp neighbor 192.168.1.2 received-routes
Router1#show ip bgp neighbors 192.168.1.2 received-routes
BGP table version is 5, 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
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*> 2.2.2.2/32 192.168.1.2 0 0 200 i
*> 3.3.3.3/32 192.168.1.2 0 0 200 i
* 4.4.4.4/32 192.168.1.2 0 0 200 i
Total number of prefixes 3
The accepted and stored BGP routes can be viewed using show ip bgp neighbor
192.168.1.2 routes command.
show ip bgp neighbor 192.168.1.2 routes
Router1# show ip bgp neighbors 192.168.1.2 routes
BGP table version is 5, 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
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*> 2.2.2.2/32 192.168.1.2 0 0 200 i
*> 3.3.3.3/32 192.168.1.2 0 0 200 i
Total number of prefixes 2
Obviously, since the number of routes are less here, it is easy to compare the two outputs.
But it would be really difficult to compare if a BGP peer receives hundreds or even
thousands of routes. An EEM applet or a TCL script can be implemented to perform the
difference and present the output in a readable form.
EEM applet
event manager applet BGP_REJECTED_ROUTES
event none
action 1.0 cli command "show ip bgp neighbors 192.168.1.2 received-routes | redirect
tftp://10.210.3.216/received-routes.txt"
action 2.0 cli command "show ip bgp neighbors 192.168.1.2 routes | redirect
tftp://10.210.3.216/routes.txt"
action 3.0 cli command "show archive config differences tftp://10.210.3.216/received-
routes.txt tftp://10.210.3.216/routes.txt"
action 4.0 puts $_cli_result
!
Since there is no event described (event none), this EEM will be triggered using event
manager run BGP_REJECTED_ROUTES command from Exec-mode. The disadvantage
here is that the BGP neighbor is configured manually, and since an EEM applet cannot
accept user-input, a TCL script is required which can accept specific BGP neighbor IP
address.