# Monitoring BGP Routes with Matching AS-Paths and Regular Expressions for Multiple Regular Expressions

#### Purpose

Display information about BGP routes whose AS-path matches the specified regular expression elements. Accepts one or more regular expression elements. Report whether the indirect next hop of a route is unreachable; if not, display the IGP cost to the indirect next hop.

Regular expressions match numbers for which the specified path is a substring—for example, if you specify 20, 200 matches because 20 is a substring of 200. You can disallow substring matching by using the underscore (_) metacharacter to constrain matching to the specified pattern, for example, _20_.

The show ip bgp regexp and show bgp ipv6 regexp commands display similar information.

#### Action

To display information about routes whose AS-path matches the specified regular expression element:

    host1#show ip bgp regexp ^200
    Local router ID 192.168.1.232, local AS 100
      6 paths, 3 distinct prefixes (324 bytes used)
      3 paths selected for route table installation
      7 path attribute entries (872 bytes used)

    Prefix        Next-hop  MED  CalPrf  Weight  AS-path
    10.99.1.2/32  10.1.1.2       100     100     200
    10.99.1.3/32  10.1.1.2       100     100     200 10
    10.99.1.4/32  10.1.1.2       100     100     200 10 20

| Note: For single regular expressions without any spaces in them, you can use either show ip bgp regexp or show ip bgp quote-regexp with the same results.

To display information about routes whose AS-path matches the specified regular expression and also has spaces within the regular expression element:

    host1#show ip bgp regexp 10 20
    Local router ID 192.168.1.232, local AS 100
      6 paths, 3 distinct prefixes (324 bytes used)
      3 paths selected for route table installation
      7 path attribute entries (872 bytes used)

    Prefix         Next-hop   MED   CalPrf  Weight  AS-path
    10.99.1.4/32   10.1.1.2         100     100     200 10 20

The show ip bgp regexp command accepts multiple strings as arguments. If you try to apply output filtering, the command interprets the filter information as a regular expression and fails. To display information about routes whose AS-path matches the specified regular expression with output filtering:

    host1#show ip bgp regexp ^200 | begin Prefix
    % invalid regular expression

#### Meaning

Table 46 lists the show ip bgp regexp command output fields.

Table 46: show ip bgp regexp Output Fields

Field Name | Field Description
--- | ---
Local router ID | BGP router ID of the local router
local AS | Local autonomous system number
paths | Total number of routes stored in the BGP routing table. If several peers have advertised a route to the same prefix, all routes are included in this count.
distinct prefixes | Number of routes to unique prefixes stored in the BGP routing table. If several peers have advertised a route to the same prefix, only the best route is included in this count.
paths selected for route table installation | Number of routes in the BGP routing table that have been inserted into the IP routing table
path attribute entries | Number of distinct path attributes stored in BGP's internal path attributes table. If BGP receives two routes for different prefixes but with identical path attributes, BGP will create only one entry in its internal path attribute table and share it between the two routes to conserve memory.
Prefix | Prefix for the routing table entry
Next hop IP address | IP address of the next router that is used when a packet is forwarded to the destination network
MED | Multiexit discriminator for the route
CalPrf | Calculated preference for the route
Weight | Weight of the route
AS path | Autonomous system path

#### Related Documentation

- Monitoring BGP Routes with Matching AS-Paths and Regular Expressions for Single Regular Expressions
- show bgp ipv6 regexp
- show ip bgp regexp