The following examples introduce configuring and monitoring Input BGP Policy Accounting with destination lookup classification. They also describe the Output BGP Policy Accounting with source lookup classification using both source and destination lookups based on BGP community-list criteria. These correspond to Examples 2 and 3 in Table 8-1, where the objective could be to apply source- and destination-sensitive billing or to generate the core traffic matrix of an ISP core network. Referring to Figure 8-3, the configuration and show commands detailed in the following sections are executed on Router A.
In Router B, the BGP routing updates from ISP 1 and ISP 2 are marked with BGP community of 100:190 and 100:198, respectively. However, the detailed configuration of this prerequisite is beyond the scope of this example.
Specify communities in community lists that classify traffic for accounting:
ip community-list 20 permit 100:190 ip community-list 30 permit 100:198
Define a route-map to match community lists, and set appropriate bucket numbers:
route-map set_bucket permit 10 match community 20 set traffic-index 2 ! route-map set_bucket permit 20 match community 30 set traffic-index 3 !
Use the table-map command under BGP to modify the bucket number when the IP routing table is updated with routes learned from BGP:
router bgp 100 table-map set_bucket network ... neighbor ... ! ip bgp-community new-format
Enable the BGP policy accounting feature on the customer-facing interface of Router A:
interface POS7/0 ip address ... bgp-policy accounting input bgp-policy accounting output source
To inspect which prefix is assigned to which bucket and which community (or communities), use the show ip cef and show ip bgp commands:
Router#show ip cef 198.162.5.0 detail 198.162.5.0/24, version 21, cached adjacency to POS7/2 0 packets, 0 bytes, traffic_index 3 via 10.1.1.1, 0 dependencies, recursive next hop 10.1.1.1, POS7/2 via 10.1.1.0/30 valid cached adjacency Router#show ip bgp 198.162.5.0 BGP routing table entry for 198.162.5.0/24, version 2 Paths: (1 available, best #1) Not advertised to any peer 100 10.1.1.1 from 10.1.1.1 (32.32.32.32) Origin IGP, metric 0, localpref 100, valid, external, best Community: 192:198
To look at per-interface traffic statistics, use the show cef interface policy-statistics command:
LC-Slot7#show cef interface policy-statistics input POS7/0 is up (if_number 8) Bucket Packets Bytes 1 0 0 2 20 2000 3 50 5000 4 0 0 5 0 0 6 0 0 7 0 0 8 0 0 LC-Slot7#show cef interface policy-statistics output Bucket Packets Bytes 1 0 0 2 40 200000 3 100 500000 4 0 0 5 0 0 6 0 0 7 0 0 8 0 0
The corresponding MIB table shows the identical entries. The router is accessed with SNMP2c (SNMP version 2c), the read community string is public, and the SNMP tool net-snmp is used. Note that only the relevant entries of the cbpAcctTable are shown in the following MIB table—only buckets 2 and 3, and only the POS/7 interface that corresponds to the ifIndex 19:
SERVER % snmpwalk -c public -v 2c <router> cbpAcctTable cbpAcctInPacketCount.19.2 = Counter64: 20 cbpAcctInPacketCount.19.3 = Counter64: 50 cbpAcctInOctetCount.19.2 = Counter64: 2000 cbpAcctInOctetCount.19.3 = Counter64: 5000 cbpAcctOutPacketCount.19.2 = Counter64: 40 cbpAcctOutPacketCount.19.3 = Counter64: 100 cbpAcctOutOctetCount.19.2 = Counter64: 200000 cbpAcctOutOctetCount.19.3 = Counter64: 500000