Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
34 views48 pages

Day 3 BGP+Basics+principles

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views48 pages

Day 3 BGP+Basics+principles

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 48

Basics of BGP Routing Protocol

Huawei Technologies Co., Ltd. All rights reserved. Page1


BGP
 As network sizes keep increasing, a network is divided into multiple interconnected
autonomous systems (ASs). Uniquely identified by an AS number, an AS is an
internetwork under the control of one administrative entity. The administrative entity
selects an interior gateway protocol (IGP), for example, open shortest path first (OSPF)
and intermediate system-to-intermediate system (IS-IS), within each AS. Routing
information is shared between ASs by using an exterior gateway protocol (EGP). In this
way, interconnection is achieved on the entire internetwork.

Huawei Technologies Co., Ltd. All rights reserved. Page2


Basic Characteristics of BGP
 BGP is an EGP. Different from IGPs, for example, OSPF and routing information protocol (RIP), BGP focuses on route
propagation control and optimal route selection, instead of route discovery and calculation.
 BGP uses transport control protocol (TCP) as the transport layer protocol (using port 179) to improve protocol reliability.
 BGP supports classless inter-domain routing (CIDR).
 During routing updates, BGP sends only incremental routes. This greatly reduces the bandwidths occupied when BGP
advertises routes. Therefore, BGP is suitable for advertising a great deal of routing information on the Internet.
 As a distance-vector routing protocol, BGP is designed to prevent routing loops.
 BGP provides diverse routing policies for flexible route filtering and selection.

Huawei Technologies Co., Ltd. All rights reserved. Page3


Contents

Basic Concepts of BGP

Basic BGP Configurations


Concept of AS

•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

10.1.0.0/16 BGP route: 10.1.1.1/1 6


R1 AS_Path = 100
BGP route: 1.
10.1.1.1/1 AS300
AS_Path = 100
R3

AS200

BGP route: 10.1.1.1/1 6


AS_Path = 300 100
R2
AS400

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

L2 Header IP Header TCP Header BGP Packets FCS

IP protocol ID: 6 TCP port number:


179

BGP Header BGP Packet

Open
Update
Marker (16B)
Notification
Keepalive
Length (2B) Type (1B)
Route-refresh
BGP Message Types

Message Type Function When to Send the Message


Open To negotiate parameters of BGP After a TCP connection is set up
peers and establish BGP peer
relationships
Update To carry BGP routing information When route information needs to be
advertised or a route update occurs
Notification To notify peers of detected errors When BGP detects an error
and instruct the peers to tear down
the BGP peer connection

Keepalive To maintain peer relationships Periodically sent


Route-refresh To instruct peers to refresh BGP When a routing policy is changed
routes when a routing policy is
changed. Only the routers on which
route-refresh is enabled can send or
respond to Route-refresh
messages.
State Machine of Neighbor Relationship Establishment
Connect-retry
timer expired
TCP connection fails Connect-retry
timer expired
Active Connect
TCP connection fails
TCP connection fails
others
TCP connection setup
others BGP start
TCP connection setup

Open-sent Idle
Error

Correct Open Error Error


message received

Open-confirm Established
Keepalive timer Keepalive message 1. Keepalive timer expired
expired received 2. Keepalive received
3. Update received

Huawei Technologies Co., Ltd. All rights reserved. Page13


BGP Finite State Machine (FSM)
Peer State Message Type Description

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

•Each router running BGP is called a BGP speaker or a BGP router.


•Different from OSPF and RIP, BGP sessions are established based on TCP. The two routers
that establish a BGP peer relationship do not need to be directly connected.
•BGP has two types of peer relationships: EBGP and IBGP. The processing of EBGP routes is
different from that of IBGP routes.

IBGP peer

R1

EBGP peer

AS 100 R2 OSPF R3 R4 AS 200


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

AS 100 R2 OSPF R3 R4 AS 200


IBGP 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

AS 100 R2 OSPF R3 R4 AS 200


Routing Black Hole in a Transit AS

Non- BGP router

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.

Import the BGP route to OSPF on B and E.

Non- BGP router

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.

Huawei Technologies Co., Ltd. All rights reserved. Page28


BGP IPv4 Address Families

Huawei Technologies Co., Ltd. All rights reserved. Page29


BGP IPv6 Address Families

Huawei Technologies Co., Ltd. All rights reserved. Page30


Contents

Basic BGP Concepts

Basic BGP Configurations


Basic BGP Configurations

•Start a BGP process and specify a BGP router ID.


[Router] bgp as-num
[Router-bgp] router-id x.x.x.x
•as-num indicates the AS number of the device.
•To improve network reliability, you are advised to manually set the BGP router ID to the IP ad
dress of a loopback interface on the device. If no BGP router ID is set, BGP automatically sele
cts a router ID in the system view as the BGP router ID. For details about the rules of router I
D selection in the system view, see the description of the router-id command.
Basic BGP Configurations

•Configure a BGP peer.


[Router-bgp] peer x.x.x.x as-number as-num
•x.x.x.x indicates the IP address of the peer and must be reachable.
•In BGP, peers must be manually specified using the peer as-number command. BGP does not automatically
discover peers as IGPs do.
•An AS number determines whether an EBGP or IBGP session is to be set up between the two devices.
•(Optional) Specify a source interface or source IP address for establishing a BGP session (TCP connection).
[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 w
ith the peer.
Basic BGP Configurations

• 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

•Run the network command to import routes to BGP.


[router-bgp] network ipv4-address [ mask| mask-length]
•The network command imports the routes in the IP routing table to BGP. Routes can be imported to BGP only
if they exist in the IP routing table.
•If the mask or mask-length parameter is not specified in the preceding command, the IP address is
considered as a classful address. If a mask is specified, only the routes that match the specified IP address
and mask are imported to the BGP routing table.
•The network command in BGP is different from that in IGPs. The network command in BGP is used to import
routes to BGP rather than activating BGP on interfaces.
•When running the network command, you can associate a route-policy to flexibly control route import.
Example of Basic BGP Configurations

IBGP EBGP

GE0/0/0 GE0/0/1 GE0/0/1


10.1.12.1/24 10.1.23.2/24 10.1.34.3/24
GE0/0/0 GE0/0/0 GE0/0/0
12.2/24 R2 23.3/24 R3 34.4/24
R1 R4
OSPF
AS 123 AS 400

•R1, R2, and R3 belong to AS 123, and R4 belongs to AS 400.


•OSPF runs on R1, R2, and R3 in AS 123, and routes of their directly connected interfaces (including loopback 0 interfaces)
are advertised to OSPF. The IP address of Loopback 0 interfaces is in the format of x.x.x.x/32, where x is the device number
(for example, the IP address of R1 is 1.1.1.1/32).
•An EBGP peer relationship is established between R3 and R4, and an IBGP peer relationship is established between R1
and R3. R2 does not run BGP. All BGP peer relationships are established using directly connected interfaces. R4 advertises
the direct route 4.4.4.4/32 to BGP. It is required that R1 learn the BGP route 4.4.4.4/32.
•BGP configurations need to be modified so that R1 and R3 establish an IBGP peer relationship using loopback 0 interfaces.
Example of Basic BGP Configurations
Note: The OSPF configuration is omitted here.
•Configurations of R1:
[R1] bgp 123
[R1-bgp] router-id 1.1.1.1
[R1-bgp] peer 10.1.23.3 as-number 123
•Configurations of R3:
[R3] bgp 123
[R3-bgp] router-id 3.3.3.3
[R3-bgp] peer 10.1.12.1 as-number 123
[R3-bgp] peer 10.1.34.4 as-number 400
•Configurations of R4:
[R4] bgp 400
[R4-bgp] router-id 4.4.4.4
[R4-bgp] peer 10.1.34.3 as-number 123
[R4-bgp] network 4.4.4.4 32
Checking the BGP Routing Table of R3

IBGP EBGP

R1 R2 R3 R4

AS 123
AS 400

[R3] display bgp routing-table


BGP Local router ID is 3.3.3.3
Status codes: * -valid, > -best, d -damped,
h -history, i -internal, s -suppressed, S -Stale
Origin : i -IGP, e -EGP, ? -incomplete
Total Number of Routes: 1
Network NextHop MED LocPrf PrefVal Path/Ogn
*> 4.4.4.4/32 10.1.34.4 0 0 400 i
R3 has learned the BGP route from R4, and the route is preferred. The > flag is displayed in
front of the route.
Checking the BGP Routing Table of R3

IBGP EBGP

R1 R2 R3 R4

AS 123
AS 400

R3] display ip routing-table protocol bgp


Destination/Mask Proto Pre Cost Flags NextHop Interface
4.4.4.4/32 EBGP 255 0 D 10.1.34.4 GigabitEthernet0/0/1

R3 has added the preferred BGP route to the IP routing table.


Common Tables Related to BGP

Name Command Description


BGP peer display bgp peer Displays the BGP peers and peer status of th
table e local device.
BGP routing display bgp routing-table Displays all BGP routes learned by the local
table device. If multiple routes to the same
destination exist, all these routes are
displayed in the BGP routing table, but only
one optimal route is selected among them.
IP routing tab display ip routing-table Routing table of the device. Preferred BGP ro
le utes are added to the IP routing table.
BGP Peer Table

<Quidway> display bgp peer


BGP Local router ID : 1.2.3.4
local AS number : 10
Total number of peers : 2
Peers in established state : 1

Peer V AS MsgRcvd MsgSent OutQ Up/Down State PrefRcv


1.1.1.1 4 100 0 0 0 00:00:07 Idle 0
1.2.5.6 4 200 32 35 0 00:17:49 Established 181

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

<Quidway> display bgp routing-table


BGP Local router ID is 1.1.1.2
Status codes: * -valid, > -best, d -damped,
h -history, i -internal, s -suppressed, S -Stale
Origin : i -IGP, e -EGP, ? -incomplete
Total Number of Routes: 4
Network NextHop MED LocPrf PrefVal Path/Ogn
* 1.1.1.0/24 1.1.1.1 0 0 100 ?
* 1.1.1.2/32 1.1.1.1 0 0 100 ?
*> 5.1.1.0/24 1.1.1.1 0 0 100 ?
*> 100.1.1.0/24 1.1.1.1 0 0 100 ?

Network ID and mask of the route


Preferred value of the route
Next-hop IP address of the route
MED of the route AS_Path and Origin of the route

Local preference of the route


Basic BGP Configuration — Specifying the Source IP Address

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

Generally, network redundancy is displayed in an AS. If an IBGP peer rel


ationship is established between R1 and R3 through directly connected i
nterfaces, the BGP session is interrupted once either interface or the dire
ct link fails. However, the IP connectivity between R1 and R3 is not
affected because of a redundant link (R1 -> R5 -> R3).
Basic BGP Configuration — Specifying the Source IP Address

• 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.10.1 EBGP 10.1.10.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

[R1] display bgp routing-table 4.4.4.4


BGP local router ID : 1.1.1.1
Local AS number : 123 Source IP address for the BGP peer relationship
Paths: 1 available, 1 best, 1 select
BGP routing table entry information of
4.4.4.4/32:
From: 3.3.3.3 (3.3.3.3) Router ID of the peer
Route Duration: 02h18m13s
Relay IP Nexthop: 10.1.12.2 Iteration next hop
Relay IP Out-Interface: GigabitEthernet0/0/0
Original nexthop: 3.3.3.3 Next-Hop of the BGP route
Qos information : 0x0
AS-path 400, origin igp, MED 0, localpref 100,
pref-val 0, valid, internal, best, select, active, Path attributes
pre 255, IGP cost 2
Not advertised to any peer yet
Huawei Technologies Co., Ltd. All rights reserved.

You might also like