Friday, May 8, 2015

400-101: BGP, Part IV:II


3.7g Implement and troubleshoot AS path manipulations


3.7g(iii) Regexp


Regular expressions use special character definitions to search and find character patterns. Within the scope of BGP, regular expressions can be used in show commands and as-path access-lists to match BGP prefixes based on the information contained in the AS_PATH attribute.

The character definitions in IOS:

Some commonly used regular expressions:
+-------------+---------------------------+
| EXPRESSION  | MEANING                   |
|-------------+---------------------------|
| .*          | Anything                  |
|-------------+---------------------------|
| ^$          | Locally originated routes |
|-------------+---------------------------|
| ^100_       | Learned from AS 100       |
|-------------+---------------------------|
| _100$       | Originated in AS 100      |
|-------------+---------------------------|
| _100_       | Any instance of AS 100    |
|-------------+---------------------------|
| ^[0-9]+$    | Directly connected ASes   |
+-------------+---------------------------+



Example: Permit only locally originated routes on R2. Ignore the private AS stuff, using an example from a previous post.

 +----------+     +--------+     +--------+
 |          |     |        |     |        |
 | AS 65001 | --- | AS 200 | --- | AS 300 |
 |    R1    |     |   R2   |     |   R3   |
 +----------+     +--------+     +--------+



R2#
interface FastEthernet0/1
 ip address 155.1.23.2 255.255.255.0
!
interface Loopback200
 ip address 200.2.2.2 255.255.255.0
!
interface Loopback201
 ip address 200.22.22.2 255.255.255.0
!
ip as-path access-list 1 permit ^$
!
route-map LOCAL-ONLY permit 10
 match as-path 1
!
router bgp 200
 no synchronization
 bgp log-neighbor-changes
 network 200.2.2.0
 network 200.22.22.0
 neighbor 155.1.12.1 remote-as 65001
 neighbor 155.1.23.3 remote-as 300
 neighbor 155.1.23.3 remove-private-as
 neighbor 155.1.23.3 route-map LOCAL-ONLY out
 no auto-summary



R2 is originating two routes: 200.2.2.0/24 and 200.22.22.0/24. R2 is also learning routes from R1.

R2#show ip bgp
BGP table version is 9, local router ID is 150.1.2.2
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
*> 100.1.1.0/24     155.1.12.1               0             0 65001 i
*> 100.11.11.0/24   155.1.12.1               0             0 65001 i
*> 150.1.1.1/32     155.1.12.1               0             0 65001 i
*> 200.2.2.0        0.0.0.0                  0         32768 i
*> 200.22.22.0      0.0.0.0                  0         32768 i



Regular expression can also be applied to show commands to filter the output. The show ip bgp regexp ^$ displays locally originated routes.

R2#show ip bgp regexp ^$
BGP table version is 9, local router ID is 150.1.2.2
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
*> 200.2.2.0        0.0.0.0                  0         32768 i
*> 200.22.22.0      0.0.0.0                  0         32768 i



However, only the locally originated routes are propaged to R3.

R2#show ip bgp neighbors 155.1.23.3 advertised-routes
BGP table version is 9, local router ID is 150.1.2.2
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
*> 200.2.2.0        0.0.0.0                  0         32768 i
*> 200.22.22.0      0.0.0.0                  0         32768 i

Total number of prefixes 2

400-101: BGP, Part IV

3.7g Implement and troubleshoot AS path manipulations


3.7g(i) Local AS, allow AS in, remove private AS


 

1. local-as


The local-AS feature allows the router to appear to be a member of a second AS, in addition to its real AS. This feature can only be used for true eBGP peers, not between two peers in different confederation sub-AS.

The local-as does not replace the normal AS number advertised to its peers. Rather, it prepends the local-as to the actual AS, resulting in the AS_PATH length of two. Routes advertised to neighbors with local-as will appear to arrive via the specified AS, but will still be known to have originated in the actual AS.

Let's look at an example. R1 and R2 are in AS 100, R3 is in AS 300. However, R2 is configured to peer with R3 using AS 200.

 +--------+     +------------+     +--------+
 |        |     |            |     |        |
 | AS 100 | --- | AS 100/200 | --- | AS 300 |
 |   R1   |     |     R2     |     |   R3   |
 +--------+     +------------+     +--------+



Configuration.

R1#
interface FastEthernet0/0
 ip address 10.1.12.1 255.255.255.0
!
router bgp 100
 no synchronization
 bgp log-neighbor-changes
 network 192.168.10.0
 neighbor 10.1.12.2 remote-as 100
 no auto-summary



R2#
interface FastEthernet0/0
 ip address 10.1.12.2 255.255.255.0
!
interface FastEthernet0/1
 ip address 10.1.23.2 255.255.255.0
!
router bgp 100
 no synchronization
 bgp log-neighbor-changes
 neighbor 10.1.12.1 remote-as 100
 neighbor 10.1.23.3 remote-as 300
 neighbor 10.1.23.3 local-as 200
 no auto-summary



R3#
interface FastEthernet0/1
 ip address 10.1.23.3 255.255.255.0
!
router bgp 300
 no synchronization
 bgp log-neighbor-changes
 neighbor 10.1.23.2 remote-as 200
 no auto-summary



From R3's perspective, R2 is peering from AS 200. Although, the BGP process on R2 is AS 100 (router bgp 100).

R3#show ip bgp summary
BGP router identifier 10.1.23.3, local AS number 300
BGP table version is 6, main routing table version 6
1 network entries using 120 bytes of memory
1 path entries using 52 bytes of memory
2/1 BGP path/bestpath attribute entries using 248 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 444 total bytes of memory
BGP activity 3/2 prefixes, 3/2 paths, scan interval 60 secs

Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
10.1.23.2       4   200      98      95        6    0    0 00:04:47        1



Pay attention to the AS_PATH in the learned prefix.

R3#show ip bgp
BGP table version is 6, local router ID is 150.1.3.3
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
*> 192.168.10.0     10.1.23.2                              0 200 100 i



 

2. allowas-in


EBGP loop prevention is based on the AS_PATH attribute. If the local AS number is seen in the AS_PATH of the NLRI, that UPDATE is not accepted. What if there is a situation where the BGP AS is split in two (as demonstrated below)? 

 +--------+     +--------+     +--------+
 |        |     |        |     |        |
 | AS 100 | --- | AS 200 | --- | AS 100 |
 |   R1   |     |   R2   |     |   R3   |
 +--------+     +--------+     +--------+



Configuration.

R1#
interface FastEthernet0/0
 ip address 10.1.12.1 255.255.255.0
!
router bgp 100
 no synchronization
 bgp log-neighbor-changes
 network 172.16.16.0 mask 255.255.255.0
 network 172.16.17.0 mask 255.255.255.0
 network 192.168.10.0
 network 192.168.11.0
 neighbor 10.1.12.2 remote-as 200
 no auto-summary



R2#
interface FastEthernet0/0
 ip address 10.1.12.2 255.255.255.0
!
interface FastEthernet0/1
 ip address 10.1.23.2 255.255.255.0
!
router bgp 200
 no synchronization
 bgp log-neighbor-changes
 neighbor 10.1.12.1 remote-as 100
 neighbor 10.1.23.3 remote-as 100
 no auto-summary



R3#
interface FastEthernet0/1
 ip address 10.1.23.3 255.255.255.0
!
router bgp 100
 no synchronization
 bgp log-neighbor-changes
 neighbor 10.1.23.2 remote-as 200
 no auto-summary



R1 is advertising four routes: 192.168.10.0/24, 192.168.11.0/24, 172.16.16.0/24, and 172.16.17.0/24.

R1#show ip bgp
BGP table version is 5, local router ID is 10.1.12.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
*> 172.16.16.0/24   0.0.0.0                  0         32768 i
*> 172.16.17.0/24   0.0.0.0                  0         32768 i
*> 192.168.10.0     0.0.0.0                  0         32768 i
*> 192.168.11.0     0.0.0.0                  0         32768 i



Normally, the routes from R1 to R3 (via R2) would get rejected because AS 100 would be listed in the AS_PATH.

R3# debug ip bgp updates
*Mar  1 02:52:42.303: BGP(0): 10.1.23.2 rcv UPDATE about 192.168.11.0/24 -- DENIED due to: AS-PATH contains our own AS;
*Mar  1 02:52:42.307: BGP(0): 10.1.23.2 rcv UPDATE about 192.168.10.0/24 -- DENIED due to: AS-PATH contains our own AS;
*Mar  1 02:52:42.307: BGP(0): 10.1.23.2 rcv UPDATE about 172.16.17.0/24 -- DENIED due to: AS-PATH contains our own AS;
*Mar  1 02:52:42.311: BGP(0): 10.1.23.2 rcv UPDATE about 172.16.16.0/24 -- DENIED due to: AS-PATH contains our own AS;



To allow the UPDATES to be received, neighbor x.x.x.x allowas-in must be configured on R3.

R3#
router bgp 100
 no synchronization
 bgp log-neighbor-changes
 neighbor 10.1.23.2 remote-as 200
 neighbor 10.1.23.2 allowas-in
 no auto-summary



The routes are now installed into R3's BGP table, regardless of the AS_PATH containing R3's AS number (100).

R3#show ip bgp
BGP table version is 5, local router ID is 10.1.23.3
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
*> 172.16.16.0/24   10.1.23.2                              0 200 100 i
*> 172.16.17.0/24   10.1.23.2                              0 200 100 i
*> 192.168.10.0     10.1.23.2                              0 200 100 i
*> 192.168.11.0     10.1.23.2                              0 200 100 i



 

3. remove-private-as


IANA has reserved a private AS number space (64512 to 65535) to converse public AS numbers (1 to 64511). The private AS numbers cannot be leaked into the global BGP table because they are not unique (EBGP uses the AS_PATH for loop prevention). The remove-private-as command strips off the private AS numbers out of the AS_PATH list before the routes are propagated to a BGP peer.

A private AS is commonly allocated when a customer connects to one ISP (single-homed or dual-homed connection). A private AS number cannot be used when the customer connects to multiple ISPs. When a private AS number is allocated to the customer, the BGP updates from the customer will have the private AS number in the AS_PATH list. The ISP should not propagate the AS_PATH with the private AS number. The neighbor x.x.x.x remove-private-as command removes the private AS number from outbound updates.

The following conditions apply:
  • Only used with eBGP peers.
  • If the update has only private AS numbers in the AS_PATH, BGP removes these numbers.
  • If the AS_PATH includes both private and public AS numbers, BGP doesn't remove the private AS numbers. This situation is considered a configuration error.
  • If the AS_PATH contains the AS number of the eBGP neighbor, BGP does not remove the private AS number.
  • If the AS_PATH contains confederations, BGP removes the private AS numbers only if they come after the confederation portion of the AS_PATH.

Example.

 +----------+     +--------+     +--------+
 |          |     |        |     |        |
 | AS 65001 | --- | AS 200 | --- | AS 300 |
 |    R1    |     |   R2   |     |   R3   |
 +----------+     +--------+     +--------+


Simple scenario: R1 is advertising its Loopback0. R2 will remove the private AS number before propagating the route to R3.


R1#
interface FastEthernet0/0
 ip address 155.1.12.1 255.255.255.0
!
interface Loopback0
 ip address 150.1.1.1 255.255.255.255
!
router bgp 65001
 no synchronization
 bgp log-neighbor-changes
 network 150.1.1.1 mask 255.255.255.255
 neighbor 155.1.12.2 remote-as 200
 no auto-summary



R2#
interface FastEthernet0/0
 ip address 155.1.12.2 255.255.255.0
!
interface FastEthernet0/1
 ip address 155.1.23.2 255.255.255.0
!
router bgp 200
 no synchronization
 bgp log-neighbor-changes
 neighbor 155.1.12.1 remote-as 65001
 neighbor 155.1.23.3 remote-as 300
 no auto-summary



R3#
interface FastEthernet0/1
 ip address 155.1.23.3 255.255.255.0
!
router bgp 300
 no synchronization
 bgp log-neighbor-changes
 neighbor 155.1.23.2 remote-as 200
 no auto-summary



Before the private AS is removed, R3 can see it in the AS_PATH of the 155.1.1.1/32 route.

R3#show ip bgp
BGP table version is 5, local router ID is 150.1.23.3
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
*> 150.1.1.1/32     155.1.23.2                             0 200 65001 i



Applying the configuration

R2#
router bgp 200
 neighbor 155.1.23.3 remove-private-as



Verification. Only AS 200 is listed in the AS_PATH.

R3#show ip bgp
BGP table version is 6, local router ID is 150.1.23.3
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
*> 150.1.1.1/32     155.1.23.2                             0 200 i

Thursday, May 7, 2015

400-101: BGP, Part III:II

3.7.d Implement, Optimize and Troubleshoot Routing Policies


3.7.d (ii) Conditional Advertisement


It is practically impossible to affect incoming traffic flows with 100% accuracy using BGP path attributes. There are methods to influence inbound routing like AS prepending or MED but traffic might still enter the AS over either link. BGP Conditional Advertisement allows the router to advertise a route only when certain conditions are met.

Conditional advertisement has two forms: advertisement of some prefixes when some other prefixes do not exist and advertisement of some prefixes when they do exist. The prefixes to be advertised are defined by a special route map called advertise-map. The condition is defined by a route map called non-exist-map for conditions that do not exist or by a route map called exist-map for conditions that do exist.

A common application for conditional advertisement is to force inbound and outbound traffic over one link and failover to the backup route only when the primary link fails.

                +--------+
                |        |
                | AS 200 |
                |        |
 +--------+     +--------+
 |        |    /
 | AS 100 | --<
 |        |    \
 +--------+     +--------+
                |        |
                | AS 300 |
                |        |
                +--------+



Let's say R1 in AS 100 uses its connection to R3 in AS 300 (directly connected network 198.51.100.0/24) as its primary link. R1's connection to R2 in AS 200 (directly connected network 192.0.2.0/24) is strictly a backup connection. R1 has a local route 203.0.113.0/24 that should be advertised to R2 only if R3 is down. This can be accomplished with BGP conditional advertisement.

In other words:
  • If 198.51.100.0/24 exists in R1's BGP table, then do not advertise 203.0.113.0/24 to R2.
  • If 198.51.100.0/24 does not exist in R1's BGP table, then advertise the 203.0.113.0/24 to R2.

Configuration.

R1#
interface Loopback0
 ip address 203.0.113.0 255.255.255.0
!
interface FastEthernet0/0
 ip address 198.51.100.1 255.255.255.0
!
interface FastEthernet0/1
 ip address 192.0.2.1 255.255.255.0
!
ip prefix-list R1-LOCAL seq 10 permit 203.0.113.0/24
!
ip prefix-list R1-R3-NET seq 10 permit 198.51.100.0/24
!
route-map ADV-ROUTE permit 10
 match ip address prefix-list R1-LOCAL
!
route-map NON-EXIST-R1-R3 permit 10
 match ip address prefix-list R1-R3-NET
!
router bgp 100
 network 203.0.113.0 mask 255.255.255.0
 network 198.51.100.0 mask 255.255.255.0
 neighbor 192.0.2.2 remote-as 200
 neighbor 192.0.2.2 advertise-map ADV-ROUTE non-exist-map NON-EXIST-R1-R3
 neighbor 198.51.100.3 remote-as 30
0

R2#
interface FastEthernet0/0
 ip address 192.0.2.2 255.255.255.0
!
router bgp 200
 neighbor 192.0.2.1 remote-as 100


R3#
interface FastEthernet0/0
 ip address 198.51.100.3 255.255.255.0
!
router bgp 300
 neighbor 198.51.100.1 remote-as 100



Using the primary link under normal conditions.

R1#show ip bgp neigh 198.51.100.3 advertised-routes
BGP table version is 5, local router ID is 203.0.113.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
*> 198.51.100.0     0.0.0.0                  0         32768 i
*> 203.0.113.0      0.0.0.0                  0         32768 i

Total number of prefixes 2



Note that 203.0.113.0/24 is not advertised to R2.

R1#show ip bgp neigh 192.0.2.2 advertised-routes
BGP table version is 5, local router ID is 203.0.113.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
*> 198.51.100.0     0.0.0.0                  0         32768 i

Total number of prefixes 1



After the link between R1 and R3 is shutdown, 203.0.113.0/24 is advertised to R2.

R1#show ip bgp neighbors 192.0.2.2 advertised-routes
BGP table version is 7, local router ID is 203.0.113.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
*> 203.0.113.0      0.0.0.0                  0         32768 i

Total number of prefixes 1


Naturally, 198.51.100.0/24 is no longer advertised because it does not exist in R1's BGP table.

 

3.7.d(iii) Outbound Route Filtering (ORF)


The BGP ORF feature is a routing policy optimization to filter out unwanted updates at the source. ORF is enabled through the advertisement of ORF capabilities. This indicates that the BGP speaker will accept an inbound prefix-list from a neighbor and apply it locally as an outbound filter.

ORF can be configured with send and/or receive ORF capabilities. The local peer advertises the ORF capability in send mode. The remote peer receives the ORF capability in receive mode and applies the filter as an outbound policy.

R1 is advertising the following networks to R3.

R1#show ip bgp neighbors 150.1.3.3 advertised-routes
BGP table version is 8, local router ID is 150.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
*> 192.0.2.0        0.0.0.0                  0         32768 i
*> 198.51.100.0     0.0.0.0                  0         32768 i
*> 203.0.113.0      0.0.0.0                  0         32768 i

Total number of prefixes 3


R3 has the following inbound filters applied.

ip prefix-list ORF-DENY seq 5 deny 203.0.113.0/24
ip prefix-list ORF-DENY seq 10 permit 0.0.0.0/0 le 32
!
router bgp 200
 no synchronization
 neighbor 150.1.1.1 remote-as 100
 neighbor 150.1.1.1 ebgp-multihop 2
 neighbor 150.1.1.1 update-source Loopback0
 neighbor 150.1.1.1 prefix-list ORF-DENY in
 no auto-summary



It is unnecessary to send 203.0.113.0/24 to R3 because the route is denied as soon as it is received.

*BGP(0): 150.1.1.1 rcvd 203.0.113.0/24 -- DENIED due to: distribute/prefix-list;


R3's BGP table (excluding locally originated routes).

R3#show ip bgp | exclude 0.0.0.0
BGP table version is 19, local router ID is 150.1.3.3
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
*> 192.0.2.0        150.1.1.1                0             0 100 i
*> 198.51.100.0     150.1.1.1                0             0 100 i



To enable the ORF feature, R1 must be configured with the ORF receive capability and R3 with the ORF send capability.

R1#
router bgp 100
 neighbor 150.1.3.3 capability orf prefix-list receive


R3#
router bgp 200
 neighbor 150.1.1.1 prefix-list ORF-DENY in
 neighbor 150.1.1.1 capability orf prefix-list send



R3's inbound routing policy is now applied outbound on R1.

R1#show ip bgp neighbors 150.1.3.3 advertised-routes
BGP table version is 20, local router ID is 150.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
*> 192.0.2.0        0.0.0.0                  0         32768 i
*> 198.51.100.0     0.0.0.0                  0         32768 i

Total number of prefixes 2


With the full Internet routing table consisting of hundreds of thousands of routes, the benefit of minimized resource utilization due to ORF is clear. Although the same end result is achieved, ORF is much more efficient as compared to traditional inbound route filtering.

3.7.d (iv) Communities, extended communities


A community is a group of prefixes that share some common property and can be assigned the BGP community attribute. The BGP Community attribute is an optional transitive attribute of variable length. The attribute is a four-octect value, with the AS number typically encoded in the first two octects followed by a unique two-byte value.

BGP communities themselves do not affect the BGP best path selection but they can be used as flags to mark a set of routes. The community and extended communities attributes can trigger routing decisions, such as acceptance, rejection, preference, or redistribution. A prefix can have more than one community attributes. A BGP speaker can act on one, some or all the attributes. A router can also add or modify the community attributes before advertising to other peers.

BGP Community Attribute
++++++++++++++++++++++++++++++++++++++++
| Autonomous System Number (2 octects) |
++++++++++++++++++++++++++++++++++++++++
| Value (2 octets)                     |
++++++++++++++++++++++++++++++++++++++++


Communities can be defined in decimal or hexadecimal. Some community ranges are reserved and some values are used for specific purposes. For example, 0 to 65,535 (0x00000000 to 0x0000FFFF) and 4,294,967,041 to 4,294,967,295 (0xFFFF0000 to 0xFFFFFFFF) has been reserved by IANA.

Specific-purpose community attributes include:
  • INTERNET (0): The default community. By default, all routes belong to this community and all routes in this category are advertised freely.
  • NO_EXPORT (4,294,967,041 or 0xFFFFFF01): Routes with this COMMUNITY attribute must not be advertised outside of the local AS or confederation.
  • NO_ADVERTISE (4,294,967,042 or 0xFFFFFF02): Routes with this COMMUNITY attribute must not be advertised to any peer.
  • LOCAL_AS (4,294,967,043 or 0xFFFFFF03): Routes with this COMMUNITY attribute must not be advertised to any eBGP or external confederation peer (referred to as NO_EXPORT-SUBCONFED in RFC 1997).

The 4-octet community value does not provide enough expansion and flexibility to accommodate VPN requirements. This lead to the creation of extended communities. An extended community is an 8-octet value that is also divided into two main sections. The first 2 octets of the community encode a type field while the last 6 octets carry a unique set of data in a format defined by the type field. Extended communities provide a larger range for grouping or categorizing communities.

BGP Extended Community Attribute
++++++++++++++++++++++++++++++++++++++++++++++++++
| I | T | Type High (4 bits) | Type Low (8 bits) |
++++++++++++++++++++++++++++++++++++++++++++++++++
|                                                |
|                                                |
|              Value (6 octets)                  |
|                                                |
|                                                |
++++++++++++++++++++++++++++++++++++++++++++++++++


I = IANA or IETF
T = transitive or non-transitive

The Route Target extended community is in popular use wihin MPLS VPNs.The Route Target Community identifies one or more routers that may receive a set of routes (that carry this Community) carried by BGP.

BGP communities are not propagated by default. The neighbor x.x.x.x send-community [standard | extended | both] is required.

Let's look at an example. R1 in AS 100 has the following routes: 192.168.10.0/24, 192.168.11.0/24, 172.16.16.0/24, and 172.16.17.0/24. R1 is going to advertise the 172.16.16.0/24 and 172.16.17.0/24 networks with a community attribute NO_EXPORT to prevent AS 200 from propagating those routes further to AS 300.

 +--------+     +--------+     +--------+
 |        |     |        |     |        |
 | AS 100 | --- | AS 200 | --- | AS 300 |
 |        |     |        |     |        |
 +--------+     +--------+     +--------+


The configuration.

ip prefix-list 172-NETS seq 5 permit 172.16.16.0/24
ip prefix-list 172-NETS seq 10 permit 172.16.17.0/24
!
!
!
route-map NO-EXPORT permit 10
 match ip address prefix-list 172-NETS
 set community no-export
!
route-map NO-EXPORT permit 20
!
router bgp 100
 no synchronization
 bgp log-neighbor-changes
 network 172.16.16.0 mask 255.255.255.0
 network 172.16.17.0 mask 255.255.255.0
 network 192.168.10.0
 network 192.168.11.0
 neighbor 10.1.12.2 remote-as 200
 neighbor 10.1.12.2 send-community both
 neighbor 10.1.12.2 route-map NO-EXPORT out
 no auto-summary


R2 and R3 have only basic BGP configuration for peering.

Packet capture of the BGP UPDATE as sent from R1 to R2.

Border Gateway Protocol - UPDATE message
 Path Attributes
  Path Attribute - COMMUNITIES: NO_EXPORT
   Flags: 0xc0: Optional, Transitive, Complete
    Type Code: COMMUNITIES (8)
    Length: 4
     Communities: NO_EXPORT
       Community Well-known: NO_EXPORT (0xffffff01)

 Network Layer Reachability Information (NLRI)
  172.16.16.0/24
    NLRI prefix length: 24
    NLRI prefix: 172.16.16.0 (172.16.16.0)
  172.16.17.0/24
    NLRI prefix length: 24
    NLRI prefix: 172.16.17.0 (172.16.17.0)



R2 receives all the advertised routes.

R2#show ip bgp
BGP table version is 7, local router ID is 150.1.2.2
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
*> 172.16.16.0/24   10.1.12.1                0             0 100 i
*> 172.16.17.0/24   10.1.12.1                0             0 100 i
*> 192.168.10.0     10.1.12.1                0             0 100 i
*> 192.168.11.0     10.1.12.1                0             0 100 i



However, R2 does not advertise the NO_EXPORT routes to R3.

R2#show ip bgp 172.16.16.0 255.255.255.0
BGP routing table entry for 172.16.16.0/24, version 6
Paths: (1 available, best #1, table Default-IP-Routing-Table, not advertised to EBGP peer)
  Not advertised to any peer
  100
    10.1.12.1 from 10.1.12.1 (192.168.11.1)
      Origin IGP, metric 0, localpref 100, valid, external, best
      Community: no-export



R2#show ip bgp neighbor 10.1.23.3 advertised-routes
BGP table version is 7, local router ID is 150.1.2.2
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
*> 192.168.10.0     10.1.12.1                0             0 100 i
*> 192.168.11.0     10.1.12.1                0             0 100 i

Total number of prefixes 2



3.7.d(v) Multi-homing


Multihoming is connecting your network to two different ISPs. Multihoming provides redundancy by offering a backup route in case of a link failure and network optimization by selecting the ISP which offers the best path to a resource.

When running BGP with multiple ISPs, there is a risk that the local AS becomes a transit AS. Internet traffic could then pass through the AS and potentially consume all bandwidth and CPU resources. One method to guarantee that the local AS will not become a transit AS is to allow only locally generated routes to be advertised to both ISP - filtering the Internet routes going from one ISP to the other. This can be done with an outbound policy that permits only routes from the local AS.

Regular expressions use character definitions to match patterns. For example, ^ = start of string and $=end of string. Together with numbers, these characters can be used to match locally originated BGP routes or routes that were advertised through a particular AS (included in the AS_PATH). This is accomplished by ^$ (locally originated route; empty AS_PATH) and ^100$ (only AS 100 in the AS_PATH), respectively.


ip as-path access-list 10 permit ^$
!
route-map LOCAL-ONLY permit 10
 match as-path 10
!
router bgp 300
 neighbor 1.1.1.1 remote-as 100
 neighbor 1.1.1.1 route-map LOCAL-ONLY out
 neighbor 2.2.2.2 remote-as 200
 neighbor 2.2.2.2 route-map LOCAL-ONLY out



Further, the configuration can be narrowed down to receive only directly connected routes from each ISP.

ip as-path access-list 20 permit ^100$
!
route-map AS-100-ONLY permit 10
 match as-path 20
!
ip as-path access-list 30 permit ^200$
!
route-map AS-200-ONLY permit 10
 match as-path 30
!
router bgp 300
 neighbor 1.1.1.1 remote-as 100
 neighbor 1.1.1.1 route-map LOCAL-ONLY out
 neighbor 1.1.1.1 route-map AS-100-ONLY in
 neighbor 2.2.2.2 remote-as 200
 neighbor 2.2.2.2 route-map LOCAL-ONLY out
 neighbor 2.2.2.2 route-map AS-200-ONLY in


In addition to the BGP configuration, a default route is required. There are three main methods to advertise the default route:
  1. Allowing the default route in the inbound policy.
  2. Using an IGP.
  3. Installing a static default route.
Since this document talks about BGP, let's look at the first option. The default route is added in the inbound policy.

ip as-path access-list 20 permit ^100$
!
ip as-path access-list 30 permit ^200$
!
ip prefix-list DEFAULT-ROUTE seq 10 permit 0.0.0.0/0
!
route-map AS-100-ONLY permit 10
 match as-path 20
route-map AS-100-ONLY permit 20
 match ip address prefix-list DEFAULT-ROUTE
!
route-map AS-200-ONLY permit 10
 match as-path 30
route-map AS-200-ONLY permit 20
 match ip address prefix-list DEFAULT-ROUTE
!
router bgp 300
 neighbor 1.1.1.1 remote-as 100
 neighbor 1.1.1.1 route-map LOCAL-ONLY out
 neighbor 1.1.1.1 route-map AS-100-ONLY in
 neighbor 2.2.2.2 remote-as 200
 neighbor 2.2.2.2 route-map LOCAL-ONLY out
 neighbor 2.2.2.2 route-map AS-200-ONLY in

Sunday, May 3, 2015

400-101: BGP, Part III:I

3.7.d Implement, Optimize and Troubleshoot Routing Policies


3.7d(i) Attribute Manipulation


The BGP Path attributes can be manipulated to influence the BGP best path decision. In short, the BGP best path selection process is based on the following items:

  1. Largest WEIGHT attribute.
  2. Largest LOCAL_PREF attribute.
  3. Locally originated routes (Next hop 0.0.0.0 in the BGP RIB).
  4. Shortest AS_PATH attribute.
  5. Best route ORIGIN attribute: IGP, EGP, INCOMPLETE.
  6. Lowest MED attribute.
  7. EBGP routes are preferred over IBGP routes (and also have lower administrative distance).
  8. The oldest route first (older routes are more stable).
  9. The path that originated from the router with the lowest BGP router ID.
  10. If the router is a route reflector, the lowest CLUSTER_ID attribute length.
  11. Routes received from the peer with the lowest IP address.

The BGP path attributes can be altered in a number of ways to modify BGP routing on a Cisco router—using route maps, attribute maps, prefix lists, AS path access lists, regular expressions, and more.

More information about the BGP path attributes: On The Table: BGP Path Attributes.

Let's look at some common ways to manipulate the BGP path attributes.

 

Manipulating the WEIGHT

  • WEIGHT is a Cisco proprietary attribute.
  • Only locally significant. Not advertised to any BGP peers.
  • WEIGHT values range from 0 to 65,535.
  • Paths that the router originates have a WEIGHT of 32,768 by default, and other paths have a WEIGHT of 0.
  • A higher WEIGHT is preferred.

Per neighbor.
router bgp 100
 neighbor 1.1.1.1 weight 100



Selectively per route(s). Note: private IP addresses are normally filtered in BGP (only used as an example here).

ip prefix-list RFC1918 seq 10 permit 10.0.0.0/8
ip prefix-list RFC1918 seq 20 permit 172.16.0.0/12
ip prefix-list RFC1918 seq 20 permit 192.168.0.0/16
!
route-map WEIGHT-100 permit 10
 match ip address prefix-list RFC1918
 set weight 100
route-map WEIGHT-100 permit 20
!
router bgp 100
 neighbor 1.1.1.1 route-map WEIGHT-100 in



Manipulating the LOCAL PREFERENCE

  • The concept is similar to WEIGHT.
  • Range 0-4294967295.
  • Advertised within the local AS.
  • A higher local preference value is preferred.

 Apply a local preference of 200 to RFC 1918 defined private IP address ranges. Note: private IP addresses are normally filtered in BGP (only used as an example here).

ip prefix-list RFC1918 seq 10 permit 10.0.0.0/8
ip prefix-list RFC1918 seq 20 permit 172.16.0.0/12
ip prefix-list RFC1918 seq 30 permit 192.168.0.0/16
!
route-map LP-200 permit 10
 match ip address prefix-list RFC1918
 set local-preference 200
route-map LP-200 permit 20

router bgp 100
 neighbor 150.1.2.2 route-map LP-200 out


The result.
R2#show ip bgp
BGP table version is 28, local router ID is 150.1.2.2
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
*>i10.0.0.0         150.1.3.3                0    200      0 i
*>i172.16.0.0/12    150.1.3.3                0    200      0 i
*>i192.0.2.0        150.1.3.3                0    100      0 100 i
*>i192.168.0.0/16   150.1.3.3                0    200      0 i
*>i198.51.100.0     150.1.3.3                0    100      0 100 i
*>i203.0.113.0      150.1.3.3                0    100      0 100 i



Manipulating the AS_PATH

  • The local AS number is prepended into the AS_PATH attribute when the route is advertised to external BGP peers.
  • The AS_PATH attribute is a common tie breaker for Internet routes. By default, a route received from two ISPs and the preceding attributes unmodified, the AS_PATH length is the deciding factor.
  • A shorter AS_PATH length is preferred.
  • Multiple AS numbers can be manually forced into the AS_PATH, making the length longer and the route less preferred for inbound traffic.

Before manipulation.
R2#show ip bgp
BGP table version is 4, local router ID is 150.1.2.2
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
*> 192.0.2.0        150.1.1.1                0             0 100 i
*> 198.51.100.0     150.1.1.1                0             0 100 i
*> 203.0.113.0      150.1.1.1                0             0 100 i



The configuration. Prepend {100 100} into the AS_PATH for RFC 5737 defined public subnets.

ip prefix-list RFC5737 seq 10 permit 192.0.2.0/24
ip prefix-list RFC5737 seq 20 permit 198.51.100.0/24
ip prefix-list RFC5737 seq 30 permit 203.0.113.0/24
!
route-map AS-ADD permit 10
 match ip prefix-list RFC5737
 set as-path 100 100
route-map AS-ADD permit 20
!
router bgp 100
 no synchronization
 neighbor 150.1.2.2 remote-as 200
 neighbor 150.1.2.2 update-source Loopback0
 neighbor 150.1.2.2 ebgp-multihop 2
 neighbor 150.1.2.2 route-map AS-ADD out
 network 192.0.2.0
 network 198.51.100.0
 network 203.0.113.0
 no auto-summary


After manipulation.
R2#show ip bgp
BGP table version is 7, local router ID is 150.1.2.2
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
*> 192.0.2.0        150.1.1.1                0             0 100 100 100 i
*> 198.51.100.0     150.1.1.1                0             0 100 100 100 i
*> 203.0.113.0      150.1.1.1                0             0 100 100 100 i


 

Manipulating the MED

  • The MED attribute is advertised to external peers to influence incoming traffic.
  • The neighbor AS propagates the MED within its local AS but does not advertise it outside the AS.
  • A lower MED is preferred.
  • The MED attribute is commonly referred to as the BGP metric.

Adding to the configuration from the previous example. Advertise the routes to BGP neighbor 150.1.2.2 with a MED of 50.

route-map AS-ADD permit 10
 match ip address prefix-list RFC5737
 set metric 50
 set as-path prepend 100 100
!
router bgp 100
 neighbor 150.1.2.2 route-map AS-ADD out


Add R3 to AS 200. Do not manipulate any attributes.

router bgp 100
 neighbor 150.1.3.3 remote-as 200
 neighbor 150.1.3.3 ebgp-multihop 2
 neighbor 150.1.3.3 update-source Loopback0


The result. R2 learns the routes from both R1 (EBGP) and R3 (IBGP; next-hop-self).

R2#show ip bgp
BGP table version is 22, local router ID is 150.1.2.2
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
*>i192.0.2.0        150.1.3.3                0    100      0 100 i
*                   150.1.1.1               50             0 100 100 100 i
*>i198.51.100.0     150.1.3.3                0    100      0 100 i
*                   150.1.1.1               50             0 100 100 100 i
*>i203.0.113.0      150.1.3.3                0    100      0 100 i
*                   150.1.1.1               50             0 100 100 100 i

400-101: BGP, Part II

3.7.b Implement and Troubleshoot IBGP and EBGP

 

3.7b(i) EBGP, IBGP


The main difference between internal BGP (IBGP) and external BGP (EBGP) happens in BGP peering (neighbor x.x.x.x remote-as <asn>). IBGP is run between neighbors within the same autonomous system, EBGP is needed between peers in different autonomous systems.

Key behavioral differences between IBGP and EBGP:
  • Administrative distance: 20 for EBGP, 200 for IBGP.
  • By default, EBGP peers have TTL=1, which means the neighbors are assumed to be directly connected.
  • IBGP peers have a default TTL=255.
  • The next-hop is not changed when a route is advertised to an IBGP peer.
  • The next-hop is updated for each EBGP peer.
  • Loop prevention in IBGP: fully meshed neighbors or route reflectors (routes learned from IBGP are not advertised to other IBGP peers, exception route reflectors). The local AS is not included in the AS_PATH attribute when advertising to IBGP peers.
  • Loop prevention in EBGP: the AS_PATH attribute. When a route advertisement is sent out to an external peer, the AS number is written into the AS_PATH attribute. If a BGP speaker receives a route with its own AS in the AS_PATH, the update is silently discarded.


3.7b(ii) The 4-byte AS number


Similar to IPv4, the public AS number space is being allocated quickly. The 2-byte space provides the AS number range 0-65535, of which IANA reserves 64512-65534 for private purposes. Much like IPv6 was introduced to solve the IPv4 depletion problem, the 4-byte AS number has been created to solve the 2-byte AS number depletion problem. The 4-byte AS number format provides over four billion AS numbers. The 2-byte and the 4-byte AS numbers are interoperable. The 2-byte ASNs can be represented in the low-order bits, the high-order values set to 0.

Three ways of representing the 4-byte ASN:
  • asplain is a simple decimal representation of the ASN (0-4294967295).
  • asdot+ breaks the ASN in half into high-order and low-order values (16 bits each). Examples: 65535 = 0.65535, 65536 = 1.0.
  • asdot is a mixture of asplain and asdot+. Anything in the 2-byte AS number range is written in asplain and anything above that is written as asdot+.  

The asplain notation is the Cisco IOS default notation. However, Cisco IOS will support asdot via a configuration option.

 router bgp 1.1
  bgp asnotation dot


The use of the 4-byte ASN is agreed upon BGP Capabilities Advertisement during the initial session negotiation. If the neighbor does not support the new format, BGP uses a reserved 2-byte ASN 23456, called AS_TRANS. Rather than adding its own 4-byte AS number to the AS_PATH, BGP prepends the AS_TRANS. The router also adds a new attribute AS4_PATH, which carries a list of the real AS numbers (both 4-byte and 2-byte). The AS4_PATH is an optional transitive attribute.

Border Gateway Protocol - UPDATE Message

Path Attribute - AS4_PATH: 655361 2621441

Flags: 0xc0: Optional, Transitive, Complete
Type Code: AS4_PATH (17)
Length: 10
AS Path segment: 655361 2621441
Segment type: AS_SEQUENCE (2)
Segment length (number of ASN): 2
AS4: 655361
AS4: 2621441


Path Attribute - AS_PATH: 23456 23456
Flags: 0x40: Well-known, Transitive, Complete
Type Code: AS_PATH (2)
Length: 6
AS Path segment: 23456 23456
Segment type: AS_SEQUENCE (2)
Segment length (number of ASN): 2
AS2: 23456
AS2: 23456


When needed, the AGGREGATOR attribute is modified similarly. The BGP speaker replaces the 4-byte AS number with AS_TRANS and puts the real AS number in a new optional transitive attribute called AS4_AGGREGATOR.


3.7b(iii) Private AS


As briefly mentioned in the previous section, IANA has reserved 1023 AS numbers for private use (64512-65534 inclusive). Private AS numbers operate identically to private IP addresses, they cannot leak into the global routing table. A router should strip off private AS numbers before propagating NLRI to an eBGP peer. To remove the private AS number, use the neighbor x.x.x.x remove-private-as command.

Example:

R1#
router bgp 65001
 neighbor 172.16.0.2 remote-as 2

R2#
router bgp 2
 neighbor 172.16.0.1 remote-as 65001
 neighbor 192.168.0.3 remote-as 3
 neighbor 192.168.0.3 remove-private-as

R3#
router bgp 1
 neighbor 192.168.0.2 remote-as 2


A few conditions that apply:
  • You can only use this solution with external BGP (eBGP) peers.
  • If the update has only private AS numbers in the AS_PATH, BGP removes these numbers.
  • If the AS_PATH includes both private and public AS numbers, BGP doesn't remove the private AS numbers. This situation is considered a configuration error.
  • If the AS_PATH contains the AS number of the eBGP neighbor, BGP does not remove the private AS number.
  • If the AS_PATH contains confederations, BGP removes the private AS numbers only if they come after the confederation portion of the AS_PATH.

Saturday, May 2, 2015

400-101: BGP, Part I

3.7a Describe, Implement and Troubleshoot Peer Relationships


3.7a(i) Peer-group, template

 

Peer Group

  • BGP peer groups reduce CPU utilization and simplify BGP syntax.
  • The routing table is checked only once and the updates are replicated to all peer group members instead of doing it individually for each peer.
  • You can group BGP neighbors that share the same outbound policies.
  • The policies are applied to the group rather than individual peers.
  • The outbound update policy must be identical between the peers but the inbound update policy can be customized for any member of a peer group.

Example:

router bgp 100
 neighbor IBGP peer-group
 neighbor IBGP remote-as 100
 neighbor IBGP update-source Loopback0
 neighbor 1.1.1.1 peer-group IBGP
 neighbor 2.2.2.2 peer-group IBGP
 neighbor 3.3.3.3 peer-group IBGP


Without the peer group the AS number and source interface would have been specified individually for each peer.


Template

  • An optimization of BGP peer groups.
  • Uses the concept of inheritance to apply policies.
  • Two types of peer templates: peer session templates and peer policy templates.
  • Peer session templates are used to group and apply general BGP session establishment configuration.
  • Peer policy templates are used to group and apply NLRI advertisement policies.
  • A peer template can directly or indirectly inherit the configuration from another peer template.
  • A directly inherited template will overwrite any indirectly inherited statements that are duplicated in the directly inherited template.
  • A BGP neighbor can directly inherit only one session template and indirectly inherit up to seven additional session templates.

Example (peer session template):

-- WITHOUT INHERITANCE --

router bgp 100
 template peer-session IBGP
  remote-as 100
  update-source Loopback0
 exit-peer-session
!
 neighbor 1.1.1.1 inherit peer-session IBGP
 neighbor 2.2.2.2 inherit peer-session IBGP
 neighbor 3.3.3.3 inherit peer-session IBGP


-- WITH INHERITANCE --

router bgp 100
 template IBGP
  remote-as 100
  inherit peer-session UPDATE-SOURCE
 exit-peer-session
!
 template UPDATE-SOURCE
  update-source Loopback0
 exit-peer-session
!
 neighbor 1.1.1.1 inherit peer-session IBGP
 neihgbor 2.2.2.2 inherit peer-session IBGP
 neighbor 3.3.3.3 inherit peer-session IBGP



Example (peer policy template):

ip prefix-list DENY-PRIVATE-IP seq 10 deny 10.0.0.0/8
ip prefix-list DENY-PRIVATE-IP seq 20 deny 172.16.0.0/12
ip prefix-list DENY-PRIVATE-IP seq 30 deny 192.168.0.0/16
ip prefix-list DENY-PRIVATE-IP seq 40 permit 0.0.0.0/0 le 32
!
router bgp 100
 template peer-policy IBGP-POLICY
  inherit peer-policy FILTER-PRIVATE 10
  inherit peer-policy NEXT-HOP-SELF 20
 exit-peer-policy
!
 template peer-policy FILTER-PRIVATE
  prefix-list DENY-PRIVATE-IP out
 exit-peer-policy
!
 template peer-policy NEXT-HOP-SELF
  next-hop-self
 exit-peer-policy
!
neighbor 1.1.1.1 inherit peer-policy IBGP-POLICY
neighbor 2.2.2.2 inherit peer-policy IBGP-POLICY
neighbor 3.3.3.3 inherit peer-policy IBGP-POLICY


Inherited peer policy templates are configured with sequence numbers like route-maps.


3.7a(ii) Active, Passive

  • BGP is essentially a standard TCP based protocol, which means that it is client and server based. 
  • Normally, the role of client and server are negotiated dynamically during BGP session establishment (lower BGP RID becomes the server).  
  • The neighbor x.x.x.x transport connection mode {active | passive} command can be used to manually set the client (active) and server (passive) roles.

Example:

R1#
router bgp 100
 neighbor 150.1.2.2 remote-as 100
 neighbor 150.1.2.2 update-source Loopback0

R2#
router bgp 100
 neighbor 150.1.1.1 remote-as 100
 neighbor 150.1.1.1 update-source Loopback0


By default, R1 becomes the server (TCP port 179) because of the lower BGP RID 150.1.1.1.

R1#show ip bgp neighbors | inc BGP neighbor|Local host|Foreign host
BGP neighbor is 150.1.2.2,  remote AS 100, internal link
Local host: 150.1.1.1, Local port: 179
Foreign host: 150.1.2.2, Foreign port: 46662


Let's explicitly specify R1 as the client (active).

R1#
router bgp 100
 neighbor 150.1.2.2 transport connection-mode active


As expected, R1 now operates as the client.

R1#show ip bgp neighbors | inc BGP neighbor|Local host|Foreign host
BGP neighbor is 150.1.2.2,  remote AS 100, internal link
Local host: 150.1.1.1, Local port: 64038
Foreign host: 150.1.2.2, Foreign port: 179



3.7a(iii) States, timers

 

States

 

Idle: BGP is initializing its resources (refuses incoming BGP session requests).
  • Verify that the peers have correct IP address and AS number configuration (BGP does not accept connections from unknown BGP peers).
  • Make sure that the routers can reach each other using the configured IP addresses and TCP port 179.

Connect: BGP is waiting for the transport protocol connection to be completed. If successful, the state transitions to OpenSent (the OPEN message is sent). If unsuccessful, the state transitions to Active. If BGP peers get stuck in the Connect state, it is usually because of a configuration error.
  • Check inbound and outbound TCP connectivity on port 179 (and random TCP port greater than1023).
  • Verify IP addresses and AS numbers.

Active:  BGP is unable to establish a successful TCP connection with its neighbor. A neighbor state that is oscillating between Connect and Active typically indicates a problem with the TCP transport connection.

OpenSent: The BGP peer waits for an OPEN message from its peer. After an OPEN message has been received, it is checked for validity. At this time, all fields in the OPEN message are checked against the local BGP configuration.  In case of errors, an error NOTIFICATION is sent and the state goes back to Idle. If no errors, BGP starts sending KEEPALIVE messages.

OpenConfirm: The local router is waiting for the receipt of a KEEPALIVE message from its peer. Upon receipt of a KEEPALIVE message, the BGP session transitions to the Established state.

Established: BGP peers reach the Established state after they have successfully exchanged OPEN and KEEPALIVE messages. After the peers reach the Established state, they begin to send UPDATE messages containing routing information and KEEPALIVE messages to verify the TCP Connection state. If an error is encountered at any time while a peer is in the Established state, the local peer sends a NOTIFICATION message with the reason for the error and transitions back to the Idle state.


BGP Timers


KEEPALIVE: BGP session "refresh" timer that signals the router's presence to its BGP peers. 60 seconds by default.

HOLD-TIME: BGP session "validity" timer that tells the router how long to wait for a KEEPALIVE (or UPDATE) message from its peer. 180 seconds (3x KEEPALIVE) by default. If the HOLDDOWN timer expires, the neighbor is declared dead and the routes from this neighbor are flushed.

For all neighbors.
router bgp 100
 timers bgp 60 180


Per neighbor.
router bgp 100
 neighbor 1.1.1.1 timers 60 180


The timer values are exchanged during the BGP peer establishment and negotiated to the lower values.

ADVERTISEMENT TIMER: A minimum delay between updates sent to a neighbor. Introduced to maintain a stable routing table. By default, 30 seconds for eBGP peers and 0 seconds for iBGP peers.

router bgp 100
 neighbor 6.6.6.6 advertisement-interval 30


SCAN TIMER: Designed to go over the BGP prefix-tables every 60 seconds (default) and validate if an IGP route to the next-hop is reachable.

router bgp 100
 bgp scan-time 60



NEXT-HOP TRACKING (NHT): An event-driven system to provide faster convergence (optimization over the BGP scan timer). NHT monitors the RIB for next-hop related changes for both iBGP and eBGP prefixes and reports such events to the BGP process.

The delay interval between full routing table walks should match the tuning parameters for the IGP. The default delay interval is 5 seconds, which is an optimal value for a fast-tuned IGP. Aggressively dampening unstable IGP peering sessions is recommended to mitigate possible impact to BGP.

router bgp 100
 bgp nexthop trigger enable
 bgp nexthop trigger delay 5



UPDATE-DELAY: The maximum initial delay before a BGP speaker sends its first update. 120 seconds by default.

router bgp 100
 bgp update-delay 120



AGGREGATE-TIMER: Controls how often routes will be aggregated. Even if  using aggregate-address … summary-only, more specific routes will be advertised and later withdrawn when the timer kicks in.

The range is from 6 to 60 or else 0. The default is 30. A value of 0 disables timer-based aggregation and starts aggregation immediately.

router bgp 100
 bgp aggregate-timer 30



3.7a(iv) Dynamic Neighbors


The BGP dynamic neighbor feature allows BGP peering to a group of remote neighbors that are defined by a range of IP addresses (each range is a subnet) instead of individually configuring each neighbor.

Example: The BGP dynamic neighbor feature is extremely useful in a hub-and-spoke topology. On the hub, BGP dynamic neighbors allows BGP peering based on the peer group without having to use any individual  neighbor statements to specify who those neighbors actually are. The neighbors are learned dynamically. Normal BGP configuration (static neighbor statements) is required on the spokes. Still, the overeall BGP configuration is simplified drastically. BGP dynamic neighbors are an efficient way to support hundreds or even thousands of BGP sessions with minimal configuration.

router bgp 100
 neighbor HUB-AND-SPOKE peer-group
 neighbor HUB-AND-SPOKE remote-as 100
 bgp listen range 192.168.0.0/16 peer-group HUB-AND-SPOKE
 bgp listen limit 200


Optional Commands:
  • bgp listen limit <max-num> sets a limit (maximum number) of BGP dynamic neighbors.
  • neighbor HUB-AND-SPOKE remote-as 100 alternate-as <as-num1> ... <as-num5> identifies up to five alternate AS numbers for listen range neighbors.

Router# show ip bgp summary
BGP router identifier 192.168.3.1, local AS number 100
BGP table version is 1, main routing table version 1
Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
*192.168.3.3    4    100    3       3        1      0    0 00:00:37        0
*192.168.3.2    4    100    6       6        1      0    0 00:04:36        0
* Dynamically created based on a listen range command
Dynamically created neighbors: 2/(200 max), Subnet ranges: 1
BGP peergroup HUB-AND-SPOKE listen range group members:
  192.168.0.0/16

Tuesday, April 21, 2015

BGP: Internet Routing Architectures, Part III

Optimal routing solution:
  1. Redundancy: providing multiple alternative paths for the traffic.
  2. Symmetry: having traffic that leaves the AS from an exit point return through the same point.
  3. Load balancing: dividing traffic optimally over multiple links. Extremely challenging because multiple providers control and manipulate traffic that transits any AS.

REDUNDANCY

  • Connectivity is not the responsibility of one entity.
  • At any time, human error, software errors, physical errors, or adverse unforeseen conditions can jeopardize connectivity. Hence, redundancy is desirable.
  • However, the more redundancy a network has, the more unpredictable the traffic entrance and exit points are.
  • Traffic might exit on one point and come back on another.
  • Alternate routes translate into additional routing overhead.
  • Default routes become viable because they minimize resource consumption and provide "maximum" redundancy.
  • Any router advertising the universally known default route 0.0.0.0/0 represents itself as a gateway of last resort for other systems.
  • Default routes can be static or dynamic and they can point to a network or an exit interface.
  • It is important for defaults to disappear dynamically if what they point to disappears.
  • Selected default networks should not be specific subnets.
  • A subnet that is flip-flopping might cause your default to come and go constantly. It is much better to point the default to a major aggregate or supernet that reflects the stability of a whole provider rather than a particular link.
  • Multiple default routes can be used simultaneously.
  • One way to set multiple static defaults is to point to multiple networks (using aggregates if possible for stability reasons) and establish a degree of preference by using the local preference BGP attribute.
  • Another way is to use the distance parameter (the lower distance wins).
  • The distance parameter is not exchanged between routers, so this would work only in the case of one router connected via multiple connections.
  • If a route is associated with an interface, the interface must be unavailable before the route becomes invalid. In some cases, the interface will still be active, even if the virtual circuit has failed.

SYMMETRY

  • Traffic leaving from a given exit point and coming back through the same point.
  • Easy to achieve with a single point.
  • With redundancy (multiple connections), traffic tends to be asymmetrical.
  • In some situations, asymmetrical traffic is acceptable and does not pose significant problems.
  • In general, symmetrical routing is better because it minimizes potential delays that could result otherwise.
  • To accommodate symmetry, you should designate a primary link and make the utmost effort to direct the majority of traffic to flow on this link.

LOAD BALANCING

  • The capability to divide data traffic over multiple connections.
  • A common misconception about balancing is that it means an equal distribution of the load.
  • Equal distribution is difficult, if not impossible to achieve in most scenarios.
  • Load balancing tries to achieve a traffic distribution pattern that will best utilize the multiple links that provide redundancy.
  • Traffic should be thought of as two separate entities: inbound and outbound.
  • Inbound traffic is affected by how the AS advertises its networks to the outside world, whereas outbound traffic is affected by the routing updates coming in from outside ASes.


SCENARIO 1: SINGLE-HOMING

  • A single connection to a service provider.
  • Only a default route required.
  • The least expensive and the most effective method.
  • No need for BGP between the customer and the service provider.
  • Symmetric routing but no redundancy.
  • Obviously, not suitable for satisfying mission-critical data communication requirements.


SCENARIO 2: MULTIHOMING TO A SINGLE PROVIDER

  • Multiple connections to the same service provider.
  • Although not necessary in all cases, BGP will provide the most flexibility.
  • Possible to use a private AS.

Default Only, One Primary Link, and One Backup Link

  • Preference over the default route can be set with administrative distance or local preference if BGP is used.
  • Load balancing is not an option.
  • Inbound traffic is out of the customer's control.
  • The customer could affect incoming traffic by advertising different metrics.

Default, Primary and Backup, Plus Partial Routing

  • Same scenario as before but the customer also accepts partial routing information from the service provider.
  • Local preference is used to manipulate the preference based on AS path or IP prefix.
  • For all other Internet routes not known to the customer, default will be taken in the primary and backup default manner.
  • A totally different approach is for the provider to send its metrics (MED) toward the customer.
  • Less configuration on customer site but totally dependent on the provider delivering accurate MEDs.
  • The customer can influence inbound traffic by advertising different metrics on different links.
  • Some providers encourage their customers to send their internal IGP metrics as BGP metrics.

Default, Primary and Backup, Plus Full and Partial Routing

  • Multihomed to a single provider.
  • Local preference is used to control the customer's outbound traffic, and the metric is used to control the inbound traffic.
  • CAUTION: When dealing with outbound traffic, manipulating exit points for specific routes is dangerous. Routing loops can occur if outbound traffic following an IGP default toward the customer's BGP router is directed toward another router following default to the BGP router.


AUTOMATIC LOAD BALANCING

  • Cisco IOS software supports dynamic load balancing on a single router for identical destinations learned via EBGP that are sourced from the same autonomous system.
  • A Cisco router will keep (locally in its IP routing table) up to six identical BGP routes to the same destination (dictated by the maximum-paths command).
  • However, BGP installs only a single best route by default. BGP Multipath can be used to install multiple paths.
  • When passing on the EBGP updates to the IBGP peers, however, the router will pass only its singular best route for a particular destination.
  • By default, a Cisco router will load balance on a per-destination (host) basis in a round-robin fashion.
  • Does not work in a multiprovider environment.


SCENARIO 3: MULTIHOMING TO DIFFERENT PROVIDERS

Redundancy and geographical restrictions are strong motivations for multihoming.

Default Only, Primary and Backup

  • A customer can set or learn the default routes to the two providers either through static routes or through both providers' dynamic advertisements of default routes.
  • The customer can prefer one default over another by using administrative distance or local preference.

 

Default, Primary and Backup, Plus Partial Routing

  • By accepting partial routing from the providers, the customer does not need to see all Internet routes and can still make best routing decisions.
  • For the more specific routes, BGP will choose the provider link closer to the destination.
  • For other Internet routes, the basic principle of primary and backup default route can be used.

 

Default, Primary and Backup, Plus Full and Partial Routing

  • Accepting full routes from either or both providers is not really necessary unless the customer plans to be a provider itself and advertise full routes to its customers.
  • For effective load balancing, the customer can accept full routing from one or both providers.
  • In some cases, the customer might want to accept full routing from one provider and implement partial/default routing with the other provider

Customer Inbound Traffic

  • In a multiprovider scenario, sending different metrics from the customer's end will not have any effect because the MED value is non-transitive.
  • Only the customer's direct upstream provider will learn the MED value but it is not passed along.
  • Instead, the AS path attribute could be manipulated. By adding bogus AS entries to affect the length would make the route less desirable.