BGP Border Gateway Routing ProtocolBGP Border Gateway Routing Protocol is a standardized exterior gateway protocol designed to exchange routing and reachability information between auton
Trang 1BGP (Border Gateway Routing Protocol)
BGP (Border Gateway Routing Protocol) is a standardized exterior gateway protocol designed to exchange routing and reachability information between autonomous systems (AS) on the Internet The Border Gateway Protocol makes routing decisions based on paths, network policies or rule-sets configured by a network administrator, and are involved in making core routing decisions
BGP is a very robust and scalable routing protocol, as evidenced by the fact that BGP is the routing protocol employed on the Internet
Basics of BGP
1 BGP is the path-vector protocol that provides routing information for autonomous systems on the Internet via its AS-Path attribute
2 BGP is a Layer 4 protocol that sits on top of TCP It is much simpler than OSPF, because it doesn’t have to worry about the things TCP will handle
3 Peers that have been manually configured to exchange routing information will form a TCP connection and begin speaking BGP There is no discovery in BGP
4 Medium-sized businesses usually get into BGP for the purpose of true multi-homing for their entire network
Figure 1 Basic Topology of BGP
Trang 2BGP (Border Gateway Routing Protocol)
5 An important aspect of BGP is that the AS-Path itself is an anti-loop mechanism Routers will not import any routes that contain themselves in the AS-Path
Current Version
The current version of BGP is version 4 (BGP4) codified in RFC 4271 since 2006 Early versions of the protocol are widely considered obsolete and are rarely supported
Types of BGP
There are different terms used when describing BGP These including:
1 Internal BGP (iBGP) operates inside an autonomous System (AS)
2 External BGP (eBGP), which is also known as an interdomain routing protocol, operates outside
an AS and connects one AS to another These terms are just used to describe the same protocol just the area of operation is what differs
Figure 2 Types of BGP
Trang 3BGP (Border Gateway Routing Protocol)
Uses
Most Internet service providers must use BGP to establish routing between one another (especially if they are multihomed) Compare this with Signaling System 7 (SS7), which is the inter-provider core call setup protocol on the PSTN
Very large private IP networks use BGP internally An example would be the joining of a number of large OSPF (Open Shortest Path First) networks where OSPF by itself would not scale to size Another reason
to use BGP is multihoming a network for better redundancy, either to multiple access points of a single ISP or to multiple ISPs
BGP AD
EBGP-20
IBGP-200
Characteristics of BGP-4
The key features of BGP-4 include and not limited to these:
1 It is an advanced distance-vector protocol
2 BGP sends full routing updates at the start of the session, trigger updates are sent afterward
3 BGP maintains connection by sending periodic keepalives
4 It creates and maintains connections between peers, using TCP port 179
5 BGP sends a triggered update when a keepalive, an update, or a notification is not received
6 It has its own routing table, although it is capable of both sharing and inquiring of the interior IP routing table
7 BGP uses a very complex metric, and is the source of its strength The metric, referred to as attributes, allows great flexibility in path selection
8 It selects the route based on the AS Path
9 It selects that route, which provides a network with least AS
10 Max AS length 65535
11 1 to 64511 Public
12 64512 to 65535 Private
13 BGP doesn’t discover neighbour automatically In BGP we have to define neighbours They are called BGP peers
14 BGP supports only one type of authentication that is MD-5
Trang 4BGP (Border Gateway Routing Protocol)
How to advertise Routes in BGP?
Using two ways
Using Network Command
Redistribution
BGP Messages
Content of Open Message
Version – 4 (Right now we are using BGP V4)
MY-AS – Itself AS number
Router ID
Hold Time – 180 sec (Default)
Contents of update
a) Routes
b) Route Attributes- These are those criteria’s which are used to select the best path
cause of resetting
BGP Tables
1 Neighbour
2 BGP Table
3 Routing Table
BGP States
Trang 5BGP (Border Gateway Routing Protocol)
BGP Terminology
routes with default next hop to IBGP neighbour
To solve this drawback we have a solution that is called next hop self
This command tells a router give your own IP address as a next hop to your IBGP neighbor
(Note: Always applied on edge routers.)
neighbour with another neighbour
To solve this problem we have a solution that is called route reflector client
This command tells a router do exchange the routes of one neighbor with another neighbor
Figure 3 BGP States
Trang 6BGP (Border Gateway Routing Protocol)
value 1 in open message If your neighbour is not directly connected, then you have to change the TTL Value using EBGP Multihop command
implement load balancing then you have to change max path value
5 BGP- By default, the redistribution of iBGP into IGP isn’t allowed on Cisco IOS
update source command
BGP Attributes/Rich Metric/Path Attributes
Directly Connected – 32768
Indirectly Connected – 0
Preferred – Directly Connected
Default 100 < 4.2 billion
Preferred – Higher
6 MED- Multi Exit Discriminator
By default – 0
Lowest will be preferred
Trang 7BGP (Border Gateway Routing Protocol)
By default BGP selects single path, for load balancing we use maximum path command
BGP Path Selection
BGP could possibly receive multiple advertisements for the same route from multiple sources BGP selects only one path as the best path When the path is selected, BGP puts the selected path in the IP routing table and propagates the path to its neighbours BGP uses the following criteria, in the order presented, to select a path for a destination:
1 If the path specifies a next hop that is inaccessible, drop the update
2 Prefer the path with the largest weight
3 If the weights are the same, prefer the path with the largest local preference
4 If the local preferences are the same, prefer the path that was originated by BGP running on this router
5 If no route was originated, prefer the route that has the shortest AS_path
6 If all paths have the same AS_path length, prefer the path with the lowest origin type (where IGP
is lower than EGP, and EGP is lower than incomplete)
7 If the origin codes are the same, prefer the path with the lowest MED attribute
8 If the paths have the same MED, prefer the external path over the internal path
9 If the paths are still the same, prefer the path through the closest IGP neighbour
10 Prefer the path with the lowest IP address, as specified by the BGP router ID
Message Header Format
1 Marker- Included for compatibility, must be set to all ones
2 Length- Total length of the message in octets, including the header
3 Type- Type of BGP message The following values are defined:
a) Open (1)
b) Update (2)
c) Notification (3)
Figure 4 Message Header Format
Trang 8BGP (Border Gateway Routing Protocol)
d) KeepAlive (4)
e) Route-Refresh (5)
BGP Example
R1 (config) #int fa0/0
R1 (config-if) #ip add 172.168.101.1 255.255.255.0
R1 (config-if) #no shut
R1 (config-if) #int s0/0
R1 (config-if) #ip add 192.168.1.1 255.255.255.0
R1 (config-if) #no shut
R1 (config-if) #int s0/1
R1 (config-if) #ip add 192.168.4.2 255.255.255.0
R1 (config-if) #no shut
R1 (config-if) #do sh ip int br
Figure 5 BGP Example Topology
Trang 9BGP (Border Gateway Routing Protocol)
R2 (config) #int fa0/0
R2 (config-if) #ip add 172.168.102.1 255.255.255.0
R2 (config-if) #no shut
R2 (config-if) #int s0/0
R2 (config-if) #ip add 192.168.1.2 255.255.255.0
R2 (config-if) #no shut
R2 (config-if) #int s0/1
R2 (config-if) #ip add 192.168.2.1 255.255.255.0
R2 (config-if) #no shut
R2 (config-if) #do sh ip int br
R3 (config) #int fa0/0
R3 (config-if) #int 172.168.103.1 255.255.2550
R3 (config-if) #no shut
R3 (config-if) #int s0/0
R3 (config-if) #ip add 192.168.2.2 255.255.255.0
R3 (config-if) #no shut
R3 (config-if) #int s0/1
R3 (config-if) #ip add 192.168.3.1 255.255.255.0
R3 (config-if) #no shut
On Router 3, we will create some loopback also
R3 (config-if) #int lo 1
R3 (config-if) #ip add 172.30.1.1 255.255.255.0
R3 (config-if) #int lo 2
R3 (config-if) #ip add 172.30.2.1 255.255.255.0
R3 (config-if) #int lo 3
R3 (config-if) #ip add 172.30.3.1 255.255.255.0
R3 (config-if) #int lo 4
R3 (config-if) #ip add 172.30.4.1 255.255.255.0
R3 (config-if) #int lo 5
R3 (config-if) #ip add 172.30.5.1 255.255.255.0
R3 (config-if) #do sh ip int br
R4 (config) #int fa0/0
R4 (config-if) #ip add 172.168.104.1 255.255.255.0
R4 (config-if) #no shut
R4 (config-if) #int s0/0
R4 (config-if) #ip add 192.168.3.2 255.255.255.0
R4 (config-if) #no shut
R4 (config-if) #int s0/1
Trang 10BGP (Border Gateway Routing Protocol)
R4 (config-if) #ip add 192.168.4.1 255.255.255.0
R4 (config-if) #no shut
R4 (config-if) #do sh ip int br
Here we will Perform BGP Routing
R1 (config) #router bgp 100
R1 (config-router) #network 192.168.1.0
R1 (config-router) #network 192.168.4.0
R1 (config-router) #network 172.168.101.0 mask 255.255.255.0
R1 (config-router) #neighbour 192.168.1.2 remote-as 100
R1 (config-router) #neighbour 192.168.4.1 remote-as 100
R2 (config) #router bgp 100
R2 (config-router) #network 192.168.1.0
R2 (config-router) #network 192.68.2.0
R2 (config-router) #network 172.168.102.0 mask 255.255.255.0
R2 (config-router) #neighbour 192.168.1.1 remote-as 100
R2 (config-router) #neighbour 192.168.2.2 remote-as 200
R3 (config) #router bgp 200
R3 (config-router) #network 192.168.2.0
R3 (config-router) #network 192.68.3.0
R3 (config-router) #network 172.168.103.0 mask 255.255.255.0
R3 (config-router) #network 172.30.1.0 mask 255.255.255.0
R3 (config-router) #network 172.30.2.0 mask 255.255.255.0
R3 (config-router) #network 172.30.3.0 mask 255.255.255.0
R3 (config-router) #network 172.30.4.0 mask 255.255.255.0
R3 (config-router) #network 172.30.5.0 mask 255.255.255.0
R3 (config-router) #neighbour 192.168.2.1 remote-as 100
R3 (config-router) #neighbour 192.168.3.2 remote-as 100
R4 (config) #router bgp 100
R4 (config-router) #network 192.168.3.0
R4 (config-router) #network 192.68.4.0
R4 (config-router) #network 172.168.104.0 mask 255.255.255.0
R4 (config-router) #neighbour 192.168.3.1 remote-as 200
R4 (config-router) #neighbour 192.168.4.2 remote-as 100
BGP Creates Three Tables
Trang 11BGP (Border Gateway Routing Protocol)
R1#sh ip bgp neighbours
R1#sh ip bgp neighbours 192.68.1.2
R1#sh ip bgp neighbours 192.68.4.1
R1#sh ip bgp
R1#sh ip route bgp
Now if we talk about the network 172.30.0.0, we can see this network on R1 via 2.2 Because it advertises routes with default next hop which is 2.2 Now on edge router we run a command next hop self
Here edge router is R2 & R4
R2 (config) #router bgp 100
R2 (config-router) #neighbour 192.168.1.1 next-hop-self
R4 (config) #router bgp 100
R4 (config-router) #neighbour 192.168.4.2 next-hop-self
Here we tell router, provide your own IP add as a next hop
In BGP a router will share the information with the directly connected router only Router 1 would not share the information with the Router 3 For that here we will run route reflector client command
R2 #sh ip route bgp
We won’t see any routes of 104 networks
R4 #sh ip route bgp
We won’t see any routes of 102 networks
R1 (config) #router bgp 100
R1 (config-router) #neighbour 192.168.1.2 rout-reflector-client
R1 (config-router) #neighbour 192.168.4.1 rout-reflector-client
R4#sh ip route bgp
Now we can see here 102 routes
R2#sh ip route bgp
Trang 12BGP (Border Gateway Routing Protocol)
We can see 104 routes here
R1#sh ip bgp
First rich metric is weight
For indirectly connected 0
Next local preference 100 Always prefer higher
Next AS path 200
Next self-originate
MED is by default 0
We have two ID 4.1 & 1.2 1.2 will prefer (lower will prefer)
R1#sh ip route bgp
Here we can see 172.30.0.0 route learn via 192.168.1.2
R1#traceroute 172.30.1.1 via 1.2
R1#sh ip protocols
By default it selects only one path
If we want to implement load balance then we need to change max path value
R1 (Config) #router bgp 100
R1 (config-router) #maximum-paths?
1 to 16