BGP regular expressions - use of 4-Byte ASNs
When using 4-byte AS number in your BGP implementations to refer to a BGP autonomous system, then the regular expressions that are used for BGP must conform to the format that has been configured in the local router. For example, the default notation is ASplain. In such a situation, you must use the decimal number between 0 and 4294967295 in your regular expressions.
If you have configured the device to use ASdot notation, then you must use that notation in your regular expressions. Refer to the following example. The BGP table of a router R1 shows the use of ASplain notation for the ASNs:
R1#show ip bgp | begin Network Network Next Hop Metric LocPrf Weight Path *> 1.1.1.1/32 192.168.12.2 0 0 12000013 i
To see what regular expression will match this, we try the following show commands:
R1#show ip bgp regexp ^183.6925$
R1#show ip bgp regexp ^12000013$ BGP table version is 2, local router ID is 192.168.12.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, t secondary path, 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 192.168.12.2 0 0 12000013 i
Note that the first show command tries to display the prefixes that correspond to the ASdot notation of the AS, but there are no results. When using the ASplain notation, we get a result.
Below we have changed the notation to ASdot, and have displayed the BGP table once again. You can see that the AS number is displayed as ASdot.
R1(config)#router bgp 12000012 R1(config-router)#bgp asnotation dot R1(config-router)#exit R1(config)#exit R1#show ip bgp | begin Network Network Next Hop Metric LocPrf Weight Path *> 1.1.1.1/32 192.168.12.2 0 0 183.6925 i R1#
Now let’s try to show the prefixes with the appropriate regular expression:
R1#show ip bgp regexp ^12000013$
R1#show ip bgp regexp ^183.6925$ BGP table version is 2, local router ID is 192.168.12.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, t secondary path, 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 192.168.12.2 0 0 183.6925 i R1#
Using the ASplain notation nothing shows up, but using the configured ASdot notation, it shows up.
So the format you should use in your regular expressions for the ASNs should match the configured format in the local router.
Links
https://networklessons.com/bgp/bgp-4-byte-number https://networklessons.com/bgp/bgp-regular-expressions-examples