BGP (border gateway routing protocol)

12
BGP (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

Transcript of BGP (border gateway routing protocol)

Page 1: BGP (border gateway routing protocol)

BGP (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

Page 2: BGP (border gateway routing protocol)

BGP (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

Page 3: BGP (border gateway routing protocol)

BGP (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

Page 4: BGP (border gateway routing protocol)

BGP (Border Gateway Routing Protocol)

How to advertise Routes in BGP?

Using two ways

Using Network Command

Redistribution

BGP Messages

1. Open- BGP sends Open message using TCP Port no 179.

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)

2. Keep alive- BGP sends periodic keep alive. Default time 60 sec.

3. Update- When two routers become BGP neighbour they send update message.

Contents of update

a) Routes

b) Route Attributes- These are those criteria’s which are used to select the best path.

4. Notification- When a neighbour is reset then it sends notification message. It contains the

cause of resetting.

BGP Tables

1. Neighbour

2. BGP Table

3. Routing Table

BGP States

1. Idle- Searching for Neighbour.

2. Connect- TCP three way handshake done.

3. Open sent- Open message has been sent.

4. Open confirm- Open message has been received.

Page 5: BGP (border gateway routing protocol)

BGP (Border Gateway Routing Protocol)

5. Established- Connection Done.

BGP Terminology

1. Next Hop Self- When a BGP edge router learns the external routes then it advertise those

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.)

2. Route Reflector Client- Normally an IBGP neighbour never exchanges the routes of one

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

Page 6: BGP (border gateway routing protocol)

BGP (Border Gateway Routing Protocol)

3. EBGP-Multihop- When a BGP router wants to establish EBGP neighbourship then it set TTL

value 1 in open message. If your neighbour is not directly connected, then you have to change

the TTL Value using EBGP Multihop command.

4. Max-Path- By default BGP selects one best path using route attributes. If you want to

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.

6. Update Source- When we want to establish neighbourship via loopback then we have to use

update source command.

7. Aggregation- In BGP Summarization is called Aggregation.

BGP Attributes/Rich Metric/Path Attributes

1. Weight- Cisco Proprietary Attributes.

Directly Connected – 32768

Indirectly Connected – 0

Preferred – Directly Connected.

2. Local Preference

Default 100 < 4.2 billion

Preferred – Higher

3. Self-Originate- a router gives preference to self-originate routes.

4. AS-Path- Lowest Path will be Preferred.

5. Origin- ebgp >ibgp >Redistributed

6. MED- Multi Exit Discriminator

By default – 0

Lowest will be preferred.

7. eBGP > iBGP- eBGP will be preferred.

8. IGP Cost- Select Lowest Cost

Page 7: BGP (border gateway routing protocol)

BGP (Border Gateway Routing Protocol)

9. Ebgp Peer- Old neighbour will be preferred.

10. Router ID- Lower Router ID will be preferred.

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

Page 8: BGP (border gateway routing protocol)

BGP (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

Page 9: BGP (border gateway routing protocol)

BGP (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

Page 10: BGP (border gateway routing protocol)

BGP (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

Neighbour Table

Page 11: BGP (border gateway routing protocol)

BGP (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

BGP Table

R1#sh ip bgp

Routing Table

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

Page 12: BGP (border gateway routing protocol)

BGP (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