You are on page 1of 24

BGP

Boarder Gateway Protocol: Protocol that runs inside an Enterprise(inside an AS ) is called IGP. While the
protocol that runs between the AS is called EGP. BGP is an example of EGP. BGP is the routing protocol of the
Internet.
Here we deal with BGP that runs on co-operate customer.

Autonomous System:
is a group of routers that fall inside a technical administration domain using ICP to exchange updates within that
domain.
1- 65535 (1-65411 public, 65412-65535 private)
Two types of AS:
1. Single home AS-----> Having only one exit point
2. Multi home AS ----> Two exit point (a Transit AS

Place of BGP:

a. Used for redundancy: Most of the person think about outgoing direction when they implement BGP, but its
the incoming connection when they implement BGP. Most of the org. are concerned with their web presence.
Company wants redundancy to the ISP. If one org. goes down or link down, they have redundancy to the other
ISP, so the co-operate Web-Server doesn't goes down.

Both ISP see the public IP of the org. and are advertised to the other ISP.

b. use of shortest path: Another uses of the BGP is to identify the shortest path. For eg. ISP1 may be the

1
shortest path to reach the Telecoummuter1.

Both of them uses the term Multi-homing.


Multihoming:
multihoming is when an AS has more than one connection to the Internet.

BGP Facts:
1. BGP runs over on the top of TCP(port 179). OSPF and other IGP have their own layer 4 protocol.
2. TCP uses for reliability.
3. Updates are of course incremental and triggered.
4. Metric is the biggest you've ever seen. (It checks the a list of attribute and choose the path)
5. Slowest routing protocol on the planet to converge. (By design BGP is slow)

Styles of BGP Implementation:


1. Default route only
2. Partial routes
3. Full updates

1. Default route only:

The org. will not receive the BGP tables from the ISP1 and ISP2 . They will configure the default route. Here you
can advertise to both ISP assigned IP block. So that you provide a redundant link to your ISP.

2. Partial Routes:

Receives partial routes only from the ISP.

2
3. Full updates
Receives the full updates.

BGP Routing Alogrithm:

● BGP is technically a distance vector routing alog. But most call it a path vector protocol.
● Without tuning BGP behaves just like RIP.

Your router will determine the destination network based on the Hop count. Hop is ISP (As) not router.

BGP packets and Tables:

Packets:
1. open --- Starts the session
2. keepalive ---DUH
3. Update--- Network reachability exchange
4. Notification—sth bad has happened, close session.

Tables:
1. Neighbor Table: the connected BGP friends (Manual configuration)
2. BGP tables : a list of all BGP routes, can be big.
List of all networks learned from each neighbor.
Can contain multiple paths to the destination network.
Contains BGP attributes for each paths.
3. Routing Tables: A list of the best routes.

3
BGP Implementation and Tuning:

IBGP VS EBGP

under BGP there are two flavor of routing protocols.


1. EBGP (Exterior BGP, between the AS)
2. IBGP (Interior BGP, with the AS)

AS represents all of network under Authority. For IBGP neighborship formation the router should not be directly
connected.

4
BGP neighbor configuration:

BGP neighbor relationship are formed manually.

EBGP neighbor formation:

R5(config)# router bgp 6500 ------> BGP process starts.


R5(config-router)# neighbor 10.1.45.1 remote-as 5500

R4(config)# router bgp 5500


R4(config-router)# neighbor 10.1.45.2 remote-as 6500

R4# show ip bgp summary

IBGP Neighborship formation:

5
the only difference is that IBGP has same AS no. in the neighbor command. The IBGP neighbor can be formed
between the routers that are not directly connected.

Which IP should be used for forming IBGP neighbor-ship between R1 and R4. So in order to maintain the proper
redundancy we use loopback addresses to form the neighborship.

Forming neighborship with loopback addresses:


R1(config)#router bgp 5500
R1(config-router)# neighbor 4.4.4.4 remoete-as 5500

R1(config)#router ospf 1
R1(config-router)# network 1.1.1.1 0.0.0.0 area 0

R4(config)# router bgp 5500


R4(config-router)# neighbor 1.1.1.1 remote-as 5500

R4(config)# router ospf 1


R4(config-router)# network 4.4.4.4 0.0.0.0 area 0

BGP issues with source IP address:


● When creating a BGP packet , the neighbor statement defines destination IP addresses , and the
outbound interface defines the source IP address.
● When a BGP packet is received for a new BGP session, the source addresses of the packet is
compared to the list of the neighbor statements.
-If a match is found, a relationship is established
-If no match is found, the packet is ignored.
● Make sure that the source IP address matches the address that the other router has in its neighbor
statement.

neighborship will never form, since R1 receives the packet from source IP 10.1.24.2 or 10.1.34.2. But R1 doesn't
recognise it as neighbor, as neighbor is formed with another loopback IP.
So change the source with update-source command. Update-source command is normally used only in IBGP.

R1(config-router)# neighbor 4.4.4.4 update-source lo0


R4(config-router)# neighbor 1.1.1.1 update-source lo4

To form EBGP relationship with loopback address use the ebgp-multihop command. For forming EBGP
neighbor relationship routers must be directly connected. For loopback it doesn't see as directly connected it
sees one Hop way.

R5(config)# int lo5


R5(config-if)# ip add 5.5.5.5 255.255.255.255
R5(config)# ip route 4.4.4.4 255.255.255.255 10.1.45.1
R5(config)# router bgp 6500

6
R5(config-)# neighbor 4.4.4.4 egbp-multihop 2
R5(config)# neighbor 4.4.4.4 update-source lo5

R4(config)# ip route 5.5.5.5 255.255.255.255 10.1.45.2


R4(config)# router bgp 5500
R4(config-router)# neighbor 5.5.5.5 ebgp-multihop 2
R4(config-router)# neighbor 5.5.5.5 update-source lo4

General configuration command:


Router(config)# router bgp <AS-no>
Router(config-router)# neighbore {ip address | peer-group-name } remote-as <AS-no>

Advertising the Network into BGP:

two ways:
1. network command
2. redistribution

network command:
when you are talking about network command you'll realize two things
a. what network to advertise
b. what interface to from relationship on
In BGP there is no 2nd phase. Neighbor relationship should be formed statically.

R5(config)# rotuer bgp 6500

7
R5(config-router)# network 50.0.0.0
OR
R5(config-router)# network 50.1.1.0 mask 255.255.255.0

Either you advertise the whole class block or type the exact subnet mask.

R#show ip bgp

Through redistribution:

R5(config)#access-list 50 deny 200.1.5.0 0.0.0.255


R5(config)#access-list 50 deny 200.1.6.0 0.0.0.255
R5(config)#access-list 50 10.1.45.2 0.0.0.255
R5(coinfig)#access-list 50 permit any

(Here we put the filter that means you want to advertise only other network except those)
R5(config)#route-map FILTER
R5(config-route-map)#match ip address 50

R5(config)# router bgp 6500


R5(config-router)# redistribute connected route-map FILTER

R#show ip bgp
It will shows the bgp table. Those route with *> symbol (The best route) will only be entered into the routing table
of the router.

Note in R1 we can't see the routing table entries, i.e in BGP table we don't see the * symbol infront of the >
carate.

There are two issues with it:

Two reasons:
1. BGP synchronization
2. BGP next hop processing

BGP Synchronization:
Do not use or advertise a route learned via IBGP until the same route has been learned from the internal routing
protocol.

BGP synchronization ON < 12.2 (8)T


OFF >= 12.2(8)T

It might be useful to turn off synchronization for the following reasons.


1. All the routers in the AS are running BGP.
2. All the BGP routers in the AS are meshed.
3. When AS is not a transit AS.

8
Configuration:
R1(config)# router bgp 6500
R1(config-router)# no synchronization

Still we don't see the best route symbol in the BGP table.

Router(config-router)# no synchronization
Disables BGP synchronization so that a router will advertise routes in BGP without learning them via an IGP.

Router (config-router)# synchronization


Enables BGP synchronization so that a router will no advertise routes in BGP until it learns them via an IGP.

BGP Next Hop processing:

For BGP peers: Change next hop address on the advertised routes.
For IBGP peers: Don't change the Next hop address on the advertised routes.

Next-hop-self----> whatever the address It uses to form neighborship, advertise itself as next hop.
R4(confg)router bgp 5500
R4(config)# neighbor 1.1.1.1 next-hop-self

9
next-hop-self
This command forces all updates for this neighbor to be advertised with this router as next-hop.
The IP address used for next-hop-self will be the same as the source IP address of the BGP packet.

BGP States:
BGP cycles thru five states as it runs:
1. Idle--->searching for neigbors
2. Connect ---> TCP 3 way Handshake complete with neighbor
3. Open Sent--> BGP open message has been sent
4. Open Confirm---> Response received
5. Established----> BGP neighborship is established

10
If the router is in the active state, it has found the IP address in the neighbor statement and has created and sent
out a BGP open packet. However, the router has not received a response (open confirm packet) back.

Understanding BGP Peer Groups:

11
BGP peer group allows you to assign configuration in groups, rather than to each individual neighbor.

R1(config)# router bgp 5500


R1(config-router)# neighbor IBGP_PEERS peer-group
R1(config-router)# neighbor IBGP_PEERS remote-as 5500
R1(config-router)# neighbor IBGP_PEERS next-hop-self
R1(config-router)# neighbor IBGP_PEERS update-source lo0

R1(config-router)# neighbor 3.3.3.3 peer-group IBGP_PEERS


R1(config-router)# neighbor 2.2.2.2 peer-group IBGP_PEERS
R1(config-router)# neighbor 4.4.4.4 peer-group IBGP_PEERS

BGP Split Horizon:


different than other, don't send update that you receive via IBGP to other IBGP peers. You need to form the
IBGP relationship between R1 and R4 as well and R2 and R3 to form full Mesh to solve the issue due to split
horizon. It can also be solved by Route Reflector.

Route Reflector: Solution to Split Horizon:

12
Verify the o/p in each router. R1 gets the IBGP routes from both R2 and R3. R2 and R3 can't see the updates of
each others LAN in their routing table. This is because of Split Horizon.

R1(config)# router bgp 6500


R1(config-router)# neighbor 192.168.1.82 route-reflector-client
R1(config-router)# neighbor 192.168.1.93 route-reflector-client
By configuring above R1 becomes route-reflector-server & it reflects the routes coming from one interface out
the other interface.

Verifying BGP:
show ip bgp summary
show ip bgp--->bgp table
show ip bgp rib-failure

debug ip bgp events


clear ip bgp *

13
BGP Turing Attributes:

What are BGP Attributes?


1. The BGP metric is not simple.
2. Attributes are the ways you can tags incoming and outgoing BGP routes.
3. Some attributes are well known (Everyone supports), while other are optional (may not support)
4. some attributes are mandatory (Must be in the update) while some are discretionary (may or may not be
there).
5. Some attributes are transitive (Travel from router to router), while other are non transitive.

Well Known Attributes:


– AS path (Mandatory)
– Next Hop Address (Mandatory)
– origin (Mandatory)
– Local preference (Discretionary)
– Atomic Aggregate (Discretionary)

Optional Attributes:
– aggregator
– Multi-exit-descriminator (MED)
– weight

How BGP finds the best routes:

0. ignore the routes with an inaccessible next hop address.


1. Prefer the path with the highest WEIGHT.
2. Prefer the path with the highest LOCAL_PREF.
3. Prefer the path that was locally generated via a network command.
4. Prefer the path with shortest AS path.
5. Prefer the path with lowest origin type.
6. Prefer the path with lowest multi-exit-discriminator (MED).
7. Prefer ebgp over ibgp.

We Love Oranges As Orange Means Pure Refreshment.

W----> weight (highest)


L------> Local Pref (highest_
O-----> originate (Local originate)
A-----> AS path (shortest)
O-----> Origin code (IGP < EGP < Incomplete)
M----->MED (lowest)
P------> paths (External over internal)
R------> Router ID (lowest router ID).

14
LAB:

R1# show ip bgp

R2 and R3 next-hop-self and no sync in all routers.

15
AS Path Attributes:

The AS path is a well-known mandatory attribute. Whenever a route update passes through an autonomous
system, the autonomous system number is prepended (added) to that update when it is advertised to the next
EBGP neighbor.

Next Hop Attribute:

The BGP next-hop attribute is a well-known mandatory attribute that indicates the next-hop IP address that is to
be used to reach a destination.
BGP routes autonomous system by autonomous system, not router by router. The next-hop attribute defines the
IP address of the border router that should be used as the next hop to the destination.

16
router B can change the next-hop attribute to itself if you use the neighbor next-hop-self command.

Origin Attribute:

e---> not supported now

Local Preference:
Local preference is a well-known discretionary attribute that provides an indication to routers in the autonomous
system about which path is preferred to exit the autonomous system. A path with a higher local preference is
preferred.

17
MED Attribute:

18
19
20
the router B MED attribute is set to 150, and the router C MED attribute is set to 200. When router A receives
updates from routers B and C, it chooses router B as the best next hop because its MED of 150 is less than
router C.

Unlike local preference, the MED is exchanged between autonomous systems. MED influences inbound traffic to
an autonomous system, and local preference influences outbound traffic.

Weight Attribute:(Cisco Only)

21
The weight attribute is a Cisco attribute for path selection. The weight is configured locally on a router and is not
propagated to any other routers. This attribute applies when you are using one router with multiple exit points in
autonomous system, as opposed to the local preference attribute, which is used when two or more routers
provide multiple exit points.

The weight can have a value from 0 to 65535. By default, paths that the router originates have a weight of
32768, and other paths have a weight of 0.

In the example, router A sets the weight of updates coming from router B to 200 and the weight of those coming
from router C to 150. Because the weight for router B is higher than router C, router A uses router B as a next
hop to reach 172.20.0.0.

Route Selection process:


BGP is not designed for load balancing.

22
changing the attributes

weight:
weight: 0
per neighbor basis:

Router1(config-router)# nieghbor 192.168.1.82 weight 500


prefer the route from neigbor 192.168.1.82 as it has highest weight.

Local preference:

Default value: 100


Router(config-router)# bgp default local-preference 700
using route map:

Router(config)# route map LOCAL_PREF 10


R3(config-route-map)# match ip address 10
R3(config-route-map)# set local-preference 1000

R3(config)# route bgp 5500


R3(config-router)# neighbor 192.168.1.82 route-map LOCAL_PREF in

(in ----> Apply map to incoming direction)


(out---->Apply map to outgoing direction)

MED:
Default Value: 0
Lower MED is preferred.

Router(config-router)# default-metric number

Using the route-map:

R(config)# route-map MED permit 10


R(config-route-map)# set metric 100

23
24