Let's take a look at how BGP works at a fundamental level. BGP runs over TCP on port 179. A BGP connection between two routers is called a peering session, and I should point out that this is different to the concept of peering versus transit. A BGP peering session simply means that two routers have established a connection for exchanging routing information. Every BGP peering session has to be configured explicitly, there's no auto discovery such as you might see with OSPF or ISIS. A BGP session can only be set up with the agreement of both sides and they need to coordinate with each other to make it happen. BGP is a Path Vector Protocol. What that means is, the route announcements that you learn via BGP, carry a list of which ASes were traversed to get there. If you learn the same prefix from different peers then comparing the AS paths is one of the ways you can choose which route you prefer. The Path Vector also performs a very important role by preventing routing loops. If you see your own AS number in a Path Vector, then you know that the route is one which already passed through your AS, and so you can discard it. There are two ways BGP can be configured. External BGP or EBGP, is used to exchange routing information with other ASes. And Internal BGP or IBGP, allows that information to propagate between routers within your own AS. The diagram here shows EBGP, but you will need to deploy IBGP as well, unless your AS consists of just a single router. BGP can carry both IPv4 and IPv6 routing information. It's best practice to have two separate BGP sessions between peers. One between IPv4 addresses which carries the IPv4 prefixes, and a separate one between IPv6 addresses to carry IPv6 prefixes. Now let's have a look at how you connect ASes. The network segment which links to ASes is called Demarcation Zone or DMZ. This network segment doesn't belong to either AS, but carries traffic and routing information between the ASes. The address space used for the link can be supplied by either AS, or the address space may be supplied by a neutral third party such as an Internet Exchange Point (IXP). Here's how BGP operates once the peering session is up. Each BGP speaking router will learn routes from any direct EBGP neighbors it has and from other IBGP speaking routers within its own AS. After applying any filters and policies, it picks the best route and stores it into its BGP routing information base or RIB, and the best route is then sent on to any EBGP neighbors. This breaks down into several sub processes, the BGP "in" process receives routes from BGP peers, applies filters and policies, and installs the best route in the BGP RIB. The BGP "out" process applies outbound filters and announces the best path information to peers. That's how the BGP prefixes and their attributes propagate through the network. Finally, the routes from the BGP RIB are installed into the global RIB. It's possible that the exact same prefix is also learned via another protocol such as OSPF or a static route. In that case, the route with the lowest protocol distance, or admin distance, is chosen to go into the global RIB. The route from the global RIB then propagates to the Forwarding Information Base, or FIB, and this is what the router uses when forwarding individual packets. So that's how BGP operates. This process may seem complex at first, but BGP is what makes the internet work, by allowing every AS to discover routes to all the other ASes. And its BGP's ability to filter and modify the routes you send and receive, which lets you apply a wide range of policies to control how traffic flows between your AS and other ASes.

© Produced by Philip Smith and the Network Startup Resource Center, through the University of Oregon.

Attribution-NonCommercial 4.0 International (CC BY-NC 4.0)
This is a human-readable summary of (and not a substitute for) the license. Disclaimer. You are free to: Share — copy and redistribute the material in any medium or format Adapt — remix, transform, and build upon the material The licensor cannot revoke these freedoms as long as you follow the license terms. Under the following terms: Attribution — You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use. NonCommercial — You may not use the material for commercial purposes. No additional restrictions — You may not apply legal terms or technological measures that legally restrict others from doing anything the license permits.