Showing posts with label BGP. Show all posts
Showing posts with label BGP. Show all posts

Tuesday, September 13, 2022

BGP Path Selection Process

 1. Largest Weight

- Cisco proprietary. Only valid on the router it is configured on. It is not passed to other routers.

2. Highest Local Preference

- Highest Local Pref is preferred. Local Pref does not get passed between different ASs
- Due to the above reason, customers are sending/using BGP community string with their announcements
- Local Pref does get passed between confederations (sub-ASs).

3. Locally Originated

- Prefer the path that was locally originated via a network or aggregate BGP subcommand, or through redistribution from an IGP. Local paths sourced by network or redistribute commands are preferred over local aggregates sourced by the aggregate-address command.

4. Shortest AS Path

- An AS_SET counts as 1, no matter how many ASs are in the set
- The AS_CONFED_SEQUENCE and AS_CONFED_SET are not included in the AS_PATH length.
- (**Confederation hops ARE NOT counted as hops)

5. Lowest Origin Type

- Prefer the path with the lowest origin type: IGP is lower than EGP, and EGP is lower than INCOMPLETE. (IGP < EGP < Incomplete)
- IGP origin is created when there is a network statement
-EGP origin is created via รข€˜redistribute
-Incomplete origin is created via redistribute

6. Lowest MED(multi-exit discriminator)

- Only compared when the AS path entering our network is the same. EX. 777 2 33 and 777 2 44 - metrics compared¦.777 2 44 and 777 3 44
- metrics NOT compared. NOTE  MED is different than IGP metric. MED is assigned by the end-user, the IGP metric is determined via the ISIS settings on our backbone.

7. eBGP over iBGP

- Routes are preferred over iBGP routes. eBGP routes are those learned via eBGP sessions (ie different ASs). iBGP routes are learned via iBGP sessions (same AS).

8. Lowest IGP metric

- IGP metrics are the internal routing protocols that BGP uses to reach the next-hop ip address(MCI backbone uses ISIS and MPLS).
- Prefer the path with the lowest IGP metric to the BGP next hop. Continue, even if bestpath is already selected.

9. Maximum paths

- Check if multiple paths need to be installed in the routing table for BGP Multipath. Continue, if bestpath is not selected yet

10. Oldest one(External)

- When both paths are external, prefer the path that was received first (the oldest one). This step minimizes route-flap, since a newer path will not displace an older one, even if it would be the preferred route based on the next decision criteria

11. Lowest Router ID

- Prefer the route coming from the BGP router with the lowest router ID
-If a path contains route-reflector (RR) attributes, the originator ID is substituted for the router ID in the path selection process
- The router ID is the highest IP address on the router, with preference given to loopback addresses. It can also be set manually using the bgp router-id command.

12. Minimum Cluster ID/list length

- This will only be present in BGP route-reflector environments

13. Lowest IP

- Prefer the path coming from the lowest neighbor address. This is the IP address used in the BGP neighbor configuration, and corresponds to the remote peer used in the TCP connection with the local router.

BGP

BGP 16-bits and 32-bits ASN

 A complete table of 16-bits and 32-bits ASN

NumberBitsDescriptionReference
016Reserved for RPKI unallocated space invalidation[11]RFC6483, RFC7607
1 - 2345516Public ASNs
2345616Reserved for AS Pool TransitionRFC6793
23457 - 6449516Public ASNs
64496 - 6451116Reserved for use in documentation/sample codeRFC5398
64512 - 6553416Private ASNsRFC1930, RFC6996
6553516ReservedRFC7300
65536 - 6555132Reserved for use in documentation and sample codeRFC4893, RFC5398
65552 - 13107132Reserved
131072 - 419999999932Public 32-bit ASNs
4200000000 - 429496729432Private ASNsRFC6996
429496729532ReservedRFC7300

Understanding BGP 4-byte ASN

BGP Autonomous System Number (ASN) is a 2-byte (16-bits) entity. 2-bytes give 65536 possible numbers, of which, 0, 23456, 65535 and 64512- 65534 (private ASN) are reserved by IANA. Of the remaining, 39000+ ASNs are already used.

RFC 4893 discusses about 4-byte ASN. 4-bytes provide ASNs ranging from 0 to 4294967296. 0-65535 are called mappable-ASN. The 4-byte ASN can be represented in one of three ways-

1. asplain - simple decimal representation of the ASN. For example, ASN 7747 will be represented as 7747, while 123456 will be represented as 123456.

2. asdot+ - breaks the number up in two 16-bit values as low-order and high-order, separated by a dot. All the 2-byte ASNs can be represented in the low-order value. For example, ASN 65535 will be 0.65535, 65536 will be 1.0, 65537 will be 1.1 and so on. The last ASN 4294967296 will be 65535.65535.

3. asdot - it is a mixture of asplain and asdot+. Any ASN in the 2-byte range is represented as asplain and any ASN above the 2-byte range is represented as asdot+. For example, 65535 will be 65535 while 65536 will be 1.0. Cisco uses this form of implementation.

ASN role in BGP

BGP carries ASN in-
    - OPEN messages
    - AS_PATH attribute
    - AGGREGATOR attribute
    - COMMUNITY attribute

Terminology
Old BGP Speaker- BGP Speaker running 2-byte ASN
New BGP Speaker- BGP Speaker running 4-byte ASN

Sunday, September 11, 2022

BGP: 51 Points to Remember for BGP

  A path vector protocol could be a network routing protocol that maintains the trail data that gets updated dynamically. Updates that have coiled through the network and came to a similar node square measure simply detected and discarded. This algorithmic program is typically utilized in Bellman–Ford routing algorithms to avoid "Count to Infinity" issues.

It is completely different from the space vector routing and link state routing. every entry within the routing table contains the destination network, ensuing router and also the path to succeed in the destination.

Path Vector Messages in BGP: The autonomous system boundary routers (ASBR), that participate in path vector routing, advertise the reachability of networks. every router that receives a path vector message should verify that the publicized  path is in line with its policy. If the messages go with the policy, the ASBR modifies its routing table and also the message before causation it to ensuing neighbor. within the changed message it sends its own AS variety and replaces ensuing router entry with its own identification.

There are some things we need to remember for BGP

1. BGP uses TCP port 179 for transport. Router with the higher BGP router-id initiates BGP session from a random port.

2. The interface from which the BGP router ID is taken does not have to be running BGP. Any valid IP address can be used as BGP router-id, even an address that is not locally configured on the router.

3. The BGP router-id must be the same as the OSPF router-id for redistributing the routes from OSPF to BGP or vice versa.

4. If the 'network …' command is configured with the 'mask' option under the BGP process, then an exact match (network/mask) must exist in the IP routing table in order to advertise this route into BGP regardless of 'auto-summary' / 'no auto-summary' command. But the 'network …' command configured without the 'mask' assumes the default classful mask and if 'auto-summary' is configured then BGP will advertise a classful network only if any subnets of the classful network exist in the IP routing table. Again if the 'network …' command is configured without the 'mask' option and if 'no auto-summary' is configured, then that router must have the exact classful network in the IP routing table in order to advertise it in BGP.

5. To accept and attempt BGP connections to the external peers residing on networks that are not directly connected, we need to use either 'neighbor ebgp-multihop …' or 'neighbor ttl-security …' command. These two commands are mutually exclusive. We can use another command 'neighbor disable-connected-check' to accomplish the same task if the BGP neighbor is one-hop away.

6. The synchronization rule states that an iBGP learned prefix cannot be considered best unless there is a matching IGP route for that BGP prefix. BGP only advertises what it considers the best path. This issue can be resolved (1) by redistributing BGP routes into the IGP, (2) by creating a full-mesh of IBGP routers and disabling the synchronization, or (3) by creating a GRE tunnel. When BGP is synchronizing with OSPF, the router ID must match in both protocols in order to make it work.

7. When a prefix is received from an eBGP neighbor, it is advertised to both eBGP & iBGP neighbors. When a prefix is received from an iBGP neighbor, it is advertised ONLY to eBGP neighbors and not to any iBGP neighbors. To advertise iBGP leaned routes to other iBGP peers requires the use of route-reflectors or confederations or a full-mesh of iBGP peers.

8. While sending BGP updates, EBGP peers modify the next-hop value to its own IP address. But iBGP peers do not modify it.

9. The ‘default-information originate’ command, however, requires explicit redistribution of the route 0.0.0.0. . Default routes can be injected into BGP in one of three ways: (1) using the 'network …' command (default route must exist in the local routing table), (2) using the 'default-information originate' command (a redistribution statement must also be configured to redistribute the default route from the local routing table to the BGP table), and (3) using the 'neighbor … default-originate [route-map route-map-name]' command (this method does not even check for the existence of a default route in the IP routing table). The 'default-information originate' command should not be configured with the 'neighbor … default-originate' command on the same router.

10. 'weight' and 'local-preference' are set inbound and they affect outbound traffic. But 'as-path' and 'med' are set outbound and they affect inbound traffic.

11. The weights assigned with the 'set weight …’ route-map command overrides the weights assigned using the 'neighbor…  weight …' command.

12. Origin code 'i' is default on the BGP routes advertised by 'network ...', 'aggregate-address ...' (if all subnet has 'i'), and 'neighbor … default-originate' commands. And origin code '?' is default on the BGP routes advertised by 'redistribute ...', 'aggregate-address ...' (if any single subnet has '?', but can be changed using ‘attribute-map’ option), 'default-information originate', and 'bgp inject-map ...' commands.

13. When BGP originates a route with the ‘network …’ command, MED is copied from the metric of the original route.

14. BGP MED values are not passed beyond the receiving (neighbor) AS.

15. Enabling the ‘bgp deterministic-med’ command ensures the comparison of the MED variable when choosing routes advertised by different peers in the same autonomous system. Enabling the ‘bgp always-compare-med’ command ensures the comparison of the MED for paths from neighbors in different autonomous systems.

16. The default behavior of BGP routers that run Cisco IOS software is to treat routes without the MED attribute as having a MED of 0, making the route that lacks the MED variable the most preferred. The 'bgp bestpath med missing-as-worst' command can be configured to treat the route that missing MED as the least preferred one.

17. ‘bgp bestpath as-path ignore’ is a hidden command in Cisco IOS which allows BGP to not consider the AS path during best path route selection.

18. There are two ways to create an aggregate address under BGP. The first is to create a static route to null interface in the routing table for the aggregate address and then advertise it with the ‘network …’ command. The second way is to use the ‘aggregate-address …’ command.

19. By default when aggregation is configured in BGP, the 'atomic-aggregate' attribute is attached to the aggregate address if the 'as-set' argument is not used in the 'aggregate-address …' command. The 'as-set' argument reveals the AS numbers which can prevent a routing loop, and once 'as-set' is configured along with the 'aggregate-address …' command, the 'atomic-aggregate' attribute is automatically removed.

20. A router reflector and its clients are known collectively as a cluster. If the cluster contains a single route reflector, the cluster ID is the router ID of the route reflector. If the cluster contains multiple route reflectors, each RR must be manually configured with a cluster ID.

21. A client router in a route reflection cluster can peer with external neighbors, but the only internal neighbor it can peer with is a route reflector in its cluster or other clients in the cluster. Clients cannot peer with routers outside of their own cluster. However, the RR itself can peer with both internal and external neighbors outside of the cluster and can reflect their routes to its clients.

22. In case of route reflection, (1) routes from EBGP are advertised to EBGP, client, non-client (2) routes from client are advertised to EBGP, client, non-client (3) routes from non-client are advertised to EBGP, client.

23. When the 'no bgp client-to-client reflection' command is configured the RR does not reflect routes from one client to another. It does, however, continue to reflect routes from clients to peers outside of the cluster, and from peers outside of the cluster to clients.

24. Standard and extended BGP communities are removed from the reflected routes unless the 'neighbor ... send-community [both]' is configured on the route reflector. The link bandwidth community is removed from reflected route if the route-reflector performs IBGP multipath load-sharing for that route.

25. The “neighbor … nexthop-self” on router reflectors only affects the next hop of eBGP learned routes because the next hop of reflected routes should not be changed. To avoid a common configuration error for reflected routes, the “set ip next-hop” command should not be used in a route map to BGP route reflector clients.

26. Unlike route reflector environments in which only the route reflector itself has to support route reflection, all routers within a confederation must support the confederation functionality.

27. EBGP routes external to the confederation are preferred over EBGP routes to member autonomous systems, which are preferred over iBGP routes.

28. AS_PATH types are AS_SEQUENCE, AS_CONFED_SEQUENCE, AS_SET, and AS_CONFED_SET. AS_SEQUENCE is an ordered set of AS numbers, and AS_SET is an unordered set of AS numbers. AS_CONFED_SEQUENCE and AS_CONFED_SET are the same as AS_SEQUENCE and AS_SET but are used only within BGP confederations.

29. When 'bgp bestpath med confed' command is configured, the router picks the confederation-internal path with the lowest MED and ignores the path with the external AS number.

30. BGP private autonomous system numbers are from 64,512 to 65,535

31. BGP prefixes can be filtered using (1) 'distribute-list', (2) 'prefix-list', (3) 'filter-list', (4) 'policy-list', (5) community/extended community lists, (6) 'route-map' .

32. For BGP, the ‘distance …’ command sets the administrative distance of the External BGP (eBGP) route. This command only affects the routing table and not the BGP table.

33. The 'network … backdoor' command has the same effect as the 'network …' command. The EBGP route is treated as a local BGP route, and the administrative distance is changed to 200. The difference is that the address specified by the network backdoor command is not advertised to EBGP peers.

34. iBGP routes are not redistributed into an IGP unless you use "bgp redistribute-internal" command under BGP routing process.

35. 'bgp inject-map ... exist-map ...' command injects prefixes in the local BGP RIB when a valid parent route exists. Only prefixes that are equal to or more specific than the aggregate route (existing prefix) can be injected. exist-map (route-map) must contain a 'match ip address prefix-list ...' command statement to specify the aggregate prefix and a 'match ip route-source prefix-list ...' command statement to specify the route source. If the parent route is a default route, we can inject any route out of it.

36. A BGP neighbor cannot be configured to work with both peer groups and peer templates. BGP peer templates and BGP peer groups are mutually exclusive.

37. Peer session template can inherit only one session template directly, but peer policy template can inherit multiple policy templates.

38. When the maximum number (as set by the ‘neighbor … maximum-prefix ...’ command) of prefixes are reached, the string "PfxRcd" appears in the entry, the neighbor goes to shutdown  state, and the connection becomes idle.

39. No penalty is applied to a BGP peer reset when route dampening is enabled. Although the reset withdraws the route, no penalty is applied in this instance.

40. In case of iBGP multipath load sharing, when multiple iBGP paths installed in a routing table, a route reflector will advertise only one of the paths (one next hop).

41. For multiple paths to the same destination to be considered as multipaths, all attributes including weight, local preference, autonomous system path (entire attribute and not just length), origin code, MED, and IGP distance must be same. But if 'bgp bestpath as-path multipath-relax' command is configured, the AS paths still have to be the same length, but don't have to be identical.

42. Though BGP Multipath allows the installation of multiple BGP paths (for load sharing purpose) into the IP routing table for the same prefix, it does not affect the bestpath selection. A router still designates one of the paths as the best path and advertises this best path to its neighbors.

43. 'neighbor … dmzlink-bw' command can be used with eBGP and iBGP multipath features to enable unequal cost load balancing over multiple links. BGP can originate the link bandwidth community only for directly connected links to eBGP neighbors.

44. The 'bgp update-delay ...' command is used to tune the maximum time the software will wait after the first neighbor is established until it starts calculating best paths and sending out advertisements.

45. The routers configured with the “neighbor … local-as …” command prepend local-AS in inbound EBGP updates and prepend both actual AS number and local-AS number in outbound EBGP updates

46. The “neighbor … local-as …” command is valid only if the peer is a true eBGP peer. It does not work for two peers in different sub-ASs in a confederation.

47. In a route-map, a continue clause can be executed, without a successful match, if a route map entry does not contain a match clause. But if a match clause exists, the continue clause is executed only if a match occurs. If no successful matches occur, the continue clause is ignored. The continue statement proceeds to the specified route map entry only after configured set actions (if any) are performed.

48. When multiple values are configured in the same community list statement, a logical AND condition is created. All community values must match to satisfy an AND condition. When multiple values are configured in separate community list statements, a logical OR condition is created. The first list that matches a condition is processed.

49. While redistributing OSPF into BGP, by default only OSPF intra-area and inter-area routes are redistributed into BGP.

50. When a BGP router with synchronization enabled has also a OSPF route (redistributed from BGP) for a iBGP-learned route, then the OSPF ASBR router-id must match the originating BGP router-id in order to synchronize BGP route with OSPF route.

51. An “update group” is a group of peers with a common outbound policy which will be converged as if they are in a peer-group