27 November 2016

BGP Tips

Collection of BGP Tips and Tricks

BGP Error Handling;
BFD - http://wiki.nil.com/Bidirectional_Forwarding_Detection_(BFD)

  interface <uplink>
    bfd interval <timer> min_rx <timer> multiplier <n>
    !
    router bgp 65000
    neighbor <ip> remote-as <ISP-AS>
    neighbor <ip> fall-over bfd


* Fast External Neighbour Failover (beware 0/0) - http://wiki.nil.com/Fast_BGP_neighbor_loss_detection
  interface <uplink>
    ip bgp fast-external-fallover permit


    - * In networks using summary routes or default routing, you have to configure a route map which matches potential BGP next-hops to prevent the router from using a default-route or a summary route as the potential valid path toward BGP neighbour's peer IP!

BGP Next-Hop tracking (beware 0/0)
    - BGP next-hop tracking is enabled by default on Cisco IOS; you can adjust the tracking interval with the "bgp nexthop trigger delay" router configuration command.

    - In environments using default routing, you should limit the valid prefixes that can be used for BGP next hop tracking with the "bgp nexthop route-map" router configuration command.
    - Do not change the BGP next hop on IBGP updates. Do not use "next-hop-self" router configuration command.
    - Advertise the IP subnets of the directly-connected links towards the ISPs into IGP (example: OSPF redistribute connected).
    - Use a route-map to prevent the default route from being used as a valid path toward external BGP next hop.

Pre-installs backup paths in BGP RIB (BGP Best Ext) and FIB (PIC);
BGP best external paths
BGP Prefix Independant Convergence - http://blog.ipspace.net/2012/01/prefix-independent-convergence-pic.html


    - BGP PIC is a feature that allows a router to pre-install alternate routes to BGP destinations in its forwarding table. The drastic changes caused by external link failure or EBGP session failure are thus easier to implement in the forwarding table.



It’s impossible to document a generic one-size-fits-all BGP prefix filtering policy. Possibly always accepting prefixes originated by ISPs, their customers, and their peering partners is the best you can get. But even then you should filter for over padded prefixes. In most cases, filters based on AS-path lengths work well.


Some ISPs attach BGP communities to BGP prefixes they advertise to help their customers implement well-tuned filters (http://onesc.net/communities/).

    Any Single AS;

ip as-path access-list 100 permit ^[0-9]+$ (does not support AS path prepending)
    One or more specific Single AS; 

ip as-path access-list 100 permit ^65001(_65001)*$ (not always good to accept highly padded paths)
    One or more any single AS;

ip as-path access-list 100 permit ^([0-9]+)(_\1)*$ (not always good to accept highly padded paths)
    Block routes with AS path repeated more than 5 times;

ip as-path access-list 100 deny _([0-9]+)_\1_\1_\1_\1_

    You can use the show ip bgp regexp command to test a regular expression on the actual data stored in the BGP table

Choosing iBGP OR eBGP?
There are numerous differences between EBGP and IBGP and their nuances sometimes make it hard to decide whether to use EBGP or IBGP in a specific scenario.

However, you the following guidelines usually result in simple and stable designs:
- If you plan to use BGP as the sole routing protocol in (a part of) your network, use EBGP.
- If you’re using BGP in combination with another routing protocol that will advertise reachability of BGP next hops, use IBGP. You can also use IBGP between routers residing in a single subnet.
- It’s easier to implement routing policies with EBGP. Large IBGP deployments need route
reflectors for scalability and some BGP implementations don’t apply BGP routing policies on reflected routes.
- All routers in the same AS should have the same view of the network and the same routing policies.
- EBGP should be used between routers in different administrative (or trust) domains.
Default loop prevention filters built into BGP reject EBGP updates with local AS number in the AS path, making it impossible to pass routes between two remote sites when they use the same AS number.

How to set BGP Local Preference or OSPF Metric (IGP metric is copied in BGP MED attribute) of received routes according to received Community


Eg; EBGP routes with BGP community 65000:1 (Backup route) will get local preference 50. These
 routes will be redistributed into OSPF as external type 2 routes with metric 10000.
- EBGP routes with BGP community 65000:2 (Primary route) will get local preference 150. These routes will be redistributed into OSPF as external type 1 routes with metric 1.

ip community-list 1 permit 65000:1
ip community-list 2 permit 65000:2
route-map Peer-R3 permit 10
 match community 1
 set local-preference 50
 set metric 10000
 set metric-type 2
 match community 2
 set local-preference 150
 set metric 1
 set metric-type 1


References; IPSpace.net, Cisco's Running an IXP, myself

(To be finished)

No comments:

Post a Comment