The Border Gateway Protocol (BGP) is a routing protocol used mainly by Internet Service Providers (ISP) to enable communication between multiple autonomous systems (AS), that is between multiple ISPs, thus being the backbone of the Internet. An autonomous system is a collection of connected IP networks controlled by one or more ISPs and connected via an internal routing protocol (e.g. IGP). BGP is described as path vector protocol and, in contrast to IGP, makes routing decisions based on path, network policies, and/or rulesets. For this reason it can be regarded as a reachability protocol rather than a routing protocol.
Each ISP (or other network provider) must have an officially registered Autonomous System Number (ASN) to identify themselves on the network. Although an ISP may support multiple autonomous systems internally, to the Internet only the routing protocol is relevant. ASN with a number of the range 64512-65534 are private and can only be used internally.
BGP uses TCP as the transport protocol, on port 179.
When BGP is used between routers of a single AS it's called interior BGP (iBGP); when it is used between routers of different AS it is called exterior BGP (eBGP).
A strength of eBGP is that it prevents routing loops, that is an IP packet never passes an AS twice. This is accomplished in the following way: An eBGP router maintains a complete list of all AS an IP packet needs to pass to reach a certain network segment. When sending, it shares that information with neighbor eBGP routers which in turn update their routing list if necessary. When an eBGP router finds that it is already on such an UPDATE list it does not add itself again.