Day 3 BGP+Basics+principles
Day 3 BGP+Basics+principles
•An autonomous system (AS) refers to a set of devices that use the same policy and are
managed by the same organization. An AS is a connected group of routers that are under the
control of an entity and adhere to a single routing policy. Each AS is uniquely identified by an
AS number assigned by the Internet assigned numbers authority (IANA).
•Each AS on a BGP network is assigned a unique AS number for identification. AS numbers
are classified as 2-byte AS numbers or 4-byte AS numbers. 2-byte AS numbers range from 1
to 65535, and 4-byte AS numbers range from 1 to 4294967295. The devices that support 4-
byte AS numbers are compatible with the devices that support only 2-byte AS numbers.
•The AS numbers from 64512 to 65535 are private AS numbers. The IANA distributes AS num
bers.
•China Telecom 163 AS number: 4134
•China Telecom CN2 AS number: 4809
•China Netcom AS number: 9929
•Refer to this link http://www.bgplookingglass.com/list-of-autonomous-system-numbers
Classification of Routing Protocols
•An Interior Gateway Protocol (IGP) is used to exchange routing information between routers within an
autonomous system (AS).
• RIP, OSPF, and IS-IS
•An Exterior Gateway Protocol (EGP) is used to exchange routing information between ASs.
• BGP
AS 100 AS 200
BGP
OSPF RIP
BGP Overview
•Border Gateway Protocol (BGP) is a distance-vector protocol that implements route interworking between ASs and
selects the optimal route. The earlier versions of BGP are BGP-1 (defined in RFC 1105), BGP-2 (defined in RFC 1163),
and BGP-3 (defined in RFC 1267). The current version, BGP-4, was first defined in RFC 1771 in 1994. In 2006, this
version was updated in RFC 4271 for use on unicast IPv4 networks and extended in RFC 4760 for use on other networks.
•BGP has the following characteristics:
• BGP can carry a large number of routes to support large-scale networks.
• BGP provides various routing policies to help with route selection and instruct peers to advertise routes accordingly.
• BGP supports MPLS/VPN applications and can transmit VPN routes.
• BGP provides route summarization and route dampening to prevent route flapping and improve network stability.
• BGP uses TCP as the transport layer protocol (port number 179) and supports association between BGP and BFD,
BGP tracking, BGP Auto FRR, BGP GR, and NSR, improving network reliability.
Path-vector Characteristics of BGP
AS100
AS200
R4
BGP route: 9 10.1.1.1/1
AS_Path = 200 100 AS500
BGP route: 4.
10.1.1.1/1
R5 AS_Path = 400 300 100
Characteristics of BGP
•BGP uses TCP as the transport layer protocol and TCP port number 179. BGP sessions between
routers are established based on TCP connections. BGP peers do not need to be directly connected.
•Each router running BGP is called a BGP speaker. There are two types of BGP peer relationships: EB
GP and IBGP.
•The two routers that establish BGP sessions are peers. BGP peers exchange BGP routes.
•After a BGP peer relationship is established, only incremental update is advertised upon a route
update, or triggered-update is implemented.
•BGP has wide array of path attributes and powerful routing policy tools.
•BGP can carry a large number of route prefixes for large-scale networks.
BGP Message Types
Open
Update
Marker (16B)
Notification
Keepalive
Length (2B) Type (1B)
Route-refresh
BGP Message Types
Open-sent Idle
Error
Open-confirm Established
Keepalive timer Keepalive message 1. Keepalive timer expired
expired received 2. Keepalive received
3. Update received
Idle TCP The router attempts to set up a TCP connection with the peer end
and monitors the peer end to start the TCP connection.
Connect TCP The TCP connection is being established, and the router is
waiting for completion. During the establishment, authentication
is implemented. If the TCP connection fails to be set up, the state
becomes Active, and the device continues its attempt to set up
the TCP connection.
Active TCP The TCP connection fails to be set up, and the device continues
its attempt to set up the TCP connection.
OpenSent Open The TCP connection is set up successfully, and an Open
message is sent. The Open message carries parameters for the
negotiation of the peer relationship establishment.
OpenConfirm Keepalive Parameters and capabilities have been negotiated. The device is
waiting for a Keepalive message from the peer.
Established Update The device has received a Keepalive message from the peer.
Both ends can exchange Update messages.
Common Causes of BGP Failure
BGP Peers
IBGP peer
R1
EBGP peer
•EBGP peer relationships are established between BGP routers in different ASs.
•To establish an EBGP peer relationship between two routers, the following conditions must be met:
(1) The two routers belong to different ASs (that is, AS numbers are different).
(2) The peer IP address specified in the peer command must be reachable, and a TCP connection must be e
stablished.
R1
EBGP peer
•IBGP peer relationships are established between BGP routers in the same AS.
•To establish an IBGP peer relationship between two routers, the following conditions must be met:
(1) The two routers belong to the same AS (that is, AS numbers are the same).
(2) The peer IP address specified in the peer command must be reachable, and a TCP connection must
be established.
IBGP peer
R1
OSPF
C
AS 65101 AS 65103
EBGP peer IBGP peer EBGP peer
A B E
F
D AS 65102
Non- BGP router
•In the transit AS (AS 65102), the four routers run OSPF, which ensures that they can communicate with
each other.
•BGP runs on routers B and E, but not on C or D. B and E are not directly connected, and they establish
an IBGP peer relationship.
Routing Black Hole in a Transit AS
IP Packet
Non- BGP router
C
AS 65101 AS 65103
EBGP peer IBGP peer EBGP peer
A B E To 1.1.1.1 F
D AS 65102
Non- BGP router
•A advertises the local route 1.1.1.0/24 to BGP, allowing F to learn the route through BGP. Because C and D do not
run BGP, they cannot learn the route through BGP.
•F sends a packet destined for 1.1.1.0/24 to E. The packet is discarded after reaching C or D, causing a routing black
hole.
Solution 1 to the Black Hole
•Import the BGP route to an IGP (OSPF in this example) and disable the synchronization rule.
OSPF
C
AS 65101 AS 65103
EBGP peer IBGP peer EBGP peer
A B E
F
D AS 65102
Non- BGP router
Solution 2 to the Black Hole
•Ensure that all routers in the transit AS run BGP and are fully meshed, and disable the synchronization r
ule.
BGP router
OSPF
C
AS 65101 AS 65103
EBGP peer EBGP peer
A B E
F
D AS 65102
BGP router
Solution 3 to the Black Hole
•Deploy MPLS.
BGP router
OSPF
C
AS 65101 AS 65103
EBGP peer EBGP peer
IBGP peer
A B E
F
D AS 65102
BGP router
IBGP Split Horizon Rule
•The anti-loop mechanism used between ASs is based on the AS_Path attribute. If a BGP
router receives a BGP route and finds that the AS_Path carries the local AS number, the
router considers that a routing loop occurs and ignores the route.
•The AS_Path changes only when the route leaves an AS. Therefore, the AS_Path cannot be
used to prevent routing loops within an AS.
•To prevent routing loops within an AS, BGP uses a split horizon rule. That is, if a BGP router
receives a route from an IBGP peer, it does not advertise the route to other IBGP peers.
•IBGP split horizon requires that IBGP peers are fully meshed in the AS.
IBGP Split Horizon Rule
Route
BGP router
OSPF
ute
Ro
C
AS 65101 AS 65103
EBGP peer EBGP peer
A Route B E
F
D AS 65102
BGP router
IBGP Split Horizon Rule
•To enable all routers in an AS to learn BGP routes, we must establish fully meshed IBGP
peer relationships to mitigate the limitations of the IBGP split horizon rule.
•However, to maintain full-mesh IBGP peer relationships between all BGP routers in an AS
consumes many resources. In addition, the scalability and maintainability of the network are
also negatively affected.
•Solution:
• Route reflector
• Confederation
BGP Route Advertisement Rules
•If multiple routes to the same destination are available, the BGP router selects only the optimal route
(when load balancing is disabled).
•BGP advertises only the routes used by itself to its peers.
•The routes learned from EBGP peers are advertised to all BGP peers (including IBGP and EBGP peers).
•The routes learned from IBGP peers are not advertised to other IBGP peers (due to the split horizon rule).
•When a BGP router receives a route from an IBGP peer and the previously mentioned synchronization
rule is enabled, the router does not advertise the route to EBGP peers unless it also learns the route from
an IGP; if the synchronization rule is disabled, the router advertises the route to EBGP peers.
•BGP sends only updated routes upon a route update.
Multiprotocol BGP (MP-BGP)
BGP has been in use for a long time as the routing protocol of the internet. BGP has been extended
beyond just basic routing and peering between service providers.
RFC 4760, of 2007, defined extensions to BGP to make it capable of carrying more than IP traffic, at
one time. This is MP-BGP, or Multiprotocol BGP.
Standard BGP only supports IPv4 unicast address family, whereas MP-BGP supports 12 or more
different BGP address families. Multi protocol BGP supports IPv4 and IPv6 address families and their
unicast and multicast variants. MP-BGP also supports Layer 2 VPN address families. EVPN (Ethernet
VPN) is a mechanism which the mac addresses are exchanged between PE devices over BGP control
plane. All these address families are exchanged between BGP neighbors over a single BGP session in
parallel.
• BGP does not discover routes. Therefore, routes need to be imported to the BGP routing ta
ble.
• Routes can be imported to the BGP routing table using the import-route or network
command.
• The import-route command imports routes into the BGP routing table from a routing protocol,
such as RIP, OSPF, or IS-IS, according to the protocol type. The command can also import static
or direct routes.
• The network command imports routes into the BGP routing table from existing routes in the IP
routing table one by one.
• When importing IGP routes, BGP can use routing policies to filter routes and set route
attributes.
Basic BGP Configurations
IBGP EBGP
IBGP EBGP
R1 R2 R3 R4
AS 123
AS 400
IBGP EBGP
R1 R2 R3 R4
AS 123
AS 400
Current status of BGP. When the network is stable, the status must be
Established.
Number of route prefixes received from the peer
BGP Routing Table
AS 123
R5
OSPF
R2
GE0/0/0 GE0/0/0
10.1.12.1 10.1.13.3
R1 R3 R4
IBGP AS 400
• To specify the source interface and source IP address for a TCP connection, run the following command:
[Router-bgp] peer x.x.x.x connect-interface intf[ ipv4-src-address]
• By default, BGP uses the IP address of the outbound interface as the source IP address for establishing a
session with the peer.
• When deploying an IBGP peer relationship, you are advised to use a loopback interface’s IP address as
the source IP address because loopback interfaces are stable. In addition, use an IGP and redundancy in t
he AS to ensure reliability.
• When deploying an EBGP peer relationship, use the IP address of the interface directly connected to the
peer as the source IP address. Issues relating to EBGP multi-hop must be considered if you use loopback
interfaces to establish an EBGP peer relationship.
Basic BGP Configuration — EBGP Multi-Hop
• Generally, EBGP peer relationships are established using directly connected interfaces. To
establish an EBGP peer relationship using loopback interfaces or to establish a multi-hop
EBGP peer relationship, increase the hop count using the ebgp-max-hop parameter. By
default, the TTL of BGP messages exchanged between EBGP peers is 1.
• The command is as follows:
[Router-bgp] peer ipv4-address ebgp-max-hop [ hop-count]
• If hop-count is not specified in the command, the default value 255 is used.
Basic BGP Configuration — EBGP Multi-Hop
1.1.1.1 2.2.2.2
10.1.20.1 10.1.20.2
R1 EBGP R2
AS 64512 R4
AS 64513
The key configurations of R1 are as follows: The key configurations of R2 are as follows:
bgp 64512 bgp 64513
peer 2.2.2.2 as-number 64513 peer 1.1.1.1 as-number 64512
peer 2.2.2.2 ebgp-max-hop 2 peer 1.1.1.1 ebgp-max-hop 2
peer 2.2.2.2 connect-interface loopback0 peer 1.1.1.1 connect-interface loopback0
! !
ip route-static 2.2.2.2 32 10.1.10.2 ip route-static 1.1.1.1 32 10.1.10.1
ip route-static 2.2.2.2 32 10.1.20.2 80 ip route-static 1.1.1.1 32 10.1.20.1 80
Checking Information About BGP Routes