Topic: tech juniper jir prev next
tech juniper jir > 09: Fundamentals of BGP
BGP is a path vector protocol. It is the core routing protocol on the Internet.
Path vector means that BGP routing information contains a series of ASNs to route packets through the network.
BGP is primarily used for routing on the Internet, but it is also used for MPLS VPNs and to separate large OSPF networks. BGP is more scalable and offers a greater degree of control through policy than an interior gateway protocol (IGP).
An autonomous system is a set of routers that operate under the same administration and offer a unified routing policy to the rest of the world. BGP uses the routing information to maintain an information base of Network Layer reachability information (NLRI). It is a classless routing protocol which supports prefix routing, irrespective of the network sizes.
BGP exchanges information between peers. Without configuration changes, the peers must be directly connected for inter-AS routing. Peers exchange information over a TCP connection. BGPv4 is essentially the only exterior gateway protocol (EGP) used on the Internet.
There is little benefit to using a dynamic routing protocol when a customer has only one connection to the Internet. They would more likely use a static default route. Usually, a customer will have IP addresses assigned from the ISP’s allocation. These are nonportable addresses and cannot be announced by another ISP. They can be aggregated with other customers’ IP addresses to be announced by the ISP.
A customer with portable address space will have their own AS and will use BGP to announce their address space via one or more ISPs.
Exchanges between ASs use the external session type (EBGP). Exchanges within the same AS use the internal session type (IBGP). The EBGP session is established only between directly connected routers, because the TTL of the BGP packets is set to 1. If there are multiple BGP speakers in an AS, then IBGP must be used to establish sessions between them. The routers’ loopback addresses are usually used when establishing IBGP sessions, for stability.
Unlike other routing protocols, BGP sessions must be manually defined. There is no automatic neighbour discovery mechanism.
BGP transitions through several states when establishing a neighbour relationship. The first three states are part of the underlying TCP transport protocol. The latter three states are part of BGP.
BGP maintains the TCP connection for the life of the BGP relationship. If the peers do not exchange messages before a hold timer, the session is terminated.
Examples of notification messages include when an unsupported feature is used, or when the remote peer has allowed the hold timer to expire.
The refresh message allows a peer to send routing information which has already been sent previously. It is used in some MPLS networks.
A BGP update message includes a single path, then lists prefixes which can be reached through the path. An update can also remove multiple prefixes, regardless of their paths.
Attribute classes are described in RFC1771. They are well-known mandatory, well-known discretionary, optional transitive, or optional nontransitive.
Well-known mandatory attributes must be understood by every BGP implementation and included in every BGP update. Well-known discretionary attributes must be understood by every BGP implementation but not necessarily included in every BGP update.
Optional transitive attributes not required to be supported, but if they are, they should be passed along unchanged to other peers. Optional nontransitive attributes are not passed on if not understood.
Well known mandatory BGP attributes:
Well known discretionary BGP attributes:
Optional transitive BGP attributes:
Optional nontransitive BGP attributes:
The purpose of BGP is to find the best path, not necessarily the shortest path. BGP includes attributes to help routers belonging to the source, destination, and transit ASs, to make routing decisions based on their own routing policies.
The IP address of the peer advertising the prefix. The Next Hop address must be reachable for the receiving peer to install the route in the local routing table. The Next Hop value is changed by default across EBGP links only; it is not changed across IBGP links.
In Junos, if the next hop is not reachable, the route is entered into the
routing table as a hidden route. Hidden routes can be shown with the show
route hidden
command.
Determines the preferred path out of the AS. All BGP traffic in an AS flows towards the peer with the highest local preference value. The default local preference is 100.
Local preference values are only used within an AS; nothing is sent over EBGP links.
Junos allows the local preference to be assigned through BGP configuration and routing policy. If both are set, the value set in the routing policy takes priority.
The list of ASs the route has been through already. If the receiving ASN is in the path, the router drops the route, as adding it to the routing table would cause a routing loop.
The same AS can be prepended several times, to discourage routers in other ASs from using the path.
Added by the router that initially injected the route into BGP, to describe where the route came from. The three possible values are 0 (IGP), 1 (EGP), 2 (incomplete).
By default, Junos assigns routes injected into BGP the value 0 (IGP). This behaviour can be changed with routing policy.
MED is only used when there are multiple paths between the same two ASs. It helps to influence the preferred back into an AS. Lower values are better.
In Junos, the MED value can be configured through BGP configuration (using the
metric-out
statement at protocol, peer or group level), or routing policy
(using the metric
action in the then
statement).
An identifier that applies to several prefixes that have a common property. In
Junos, communities are configured as actions under policy-options
.
policy-options {
policy-statement ibgp-export {
from neighbor ...;
then {
community set customer-route;
}
}
community customer-route members 64700:133;
}
BGP communities usually take the form ‘ASN:commnuity’. Multiple communities
can be set for the same prefix. They can be set, added, or deleted in a
routing policy, using the add
, delete
and set
keywords, or the shorthand
+
, -
, and =
.
Before installing a route, the router must make sure that the next hop is reachable, and that it will not create a loop. If multiple routes for a BGP prefix are learned, the one with the lowest route preference is selected.
The BGP path is selected as follows;
For IBGP peers, install a next physical hop based on the inet.0
and inet.3
routing tables. The best route from either table wins. This usually means
that an MPLS label-switched path from the inet.3
table wins. If the two
tables tie, select the route from inet.3
. When a preference tie exists in
the same table, use the next hop with the greatest number of equal-cost paths.
This tie occurs when traffic-engineering bgp-igp
is configured.