BGP Juniper

Download as pps, pdf, or txt
Download as pps, pdf, or txt
You are on page 1of 40

Border Gateway Protocol

2012 Juniper Networks, Inc. All rights reserved. | www.juniper.net


What Is BGP?

BGP is the core routing protocol within the Internet


BGP is a path-vector protocol BGP views the Internet as a
used for interdomain routing. collection of autonomous systems.

AS 65502

AS 65501 BGP AS 65504

AS 65503

Note: BGP Is an IETF standard defined in RFC 4271 (supersedes RFC 1771).
2012 Juniper Networks, Inc. All rights reserved. www.juniper.net | 2
When Should I Use BGP?
BGP is typically used in large enterprise environments
where multiple ISP connections exist, and in all service
provider environments
ISP A

AS 65502
Customer A
Single-homed customers typically
use a default route to the Internet.

AS 65501 BGP
Customer B

Static Routing
AS 65503
Multihomed customers use BGP to
control inbound and outbound traffic.
ISP B

2012 Juniper Networks, Inc. All rights reserved. www.juniper.net | 3


BGP Peers (1 of 2)

BGP peers can reside in different ASs or the same AS


Peers in different ASs use the external session type (EBGP)
Peers in the same AS use the internal session type (IBGP)
AS 65502
IBGP is not used because a
single BGP speaker exists. IBGP is used because
IGP multiple BGP speakers exist.
IBGP

IGP EBGP IGP

AS 65501 AS 65504
IGP
IBGP

AS 65503

2012 Juniper Networks, Inc. All rights reserved. www.juniper.net | 4


BGP Peers (2 of 2)

BGP peering sessions are manually defined and rely


on TCP connections
No automatic neighbor discovery

BGP Neighbor States


TCP Connectivity BGP Connectivity
Idle OpenSent
Connect OpenConfirm
Active Established
R1 R2
TCP Connectivity

BGP Connectivity

Established Neighbors

2012 Juniper Networks, Inc. All rights reserved. www.juniper.net | 5


BGP Message Types

BGP messages are used to establish and maintain


BGP peering sessions
All BGP messages use a common header

BGP Message Types


Open Keepalive
Update Notification
Refresh

R1 R2
TCP Connectivity

BGP Connectivity

Established Neighbors

2012 Juniper Networks, Inc. All rights reserved. www.juniper.net | 6


BGP Update Messages
BGP update messages include path advertisements
and their associated attributes
Can also list withdrawn routes that are no longer reachable

Router compares attributes associated with


update messages to select the best path

Route X Route X
R1 R2 R3

Established Neighbors Established Neighbors

2012 Juniper Networks, Inc. All rights reserved. www.juniper.net | 7


High-Level BGP Operation

ISP B
(AS 65002)

ISP A ISP C
(AS 65001) (AS 65003)

Static default
route to ISP A
Static route to Customer A

Customer A is single-homed to ISP A and Customer B


Customer A uses 172.20.21.0/24 subnet, which was (AS 65501)
assigned by ISP A

2012 Juniper Networks, Inc. All rights reserved. www.juniper.net | 8


ISP As Network
I can reach
172.20.0.0/16

R3

ISP A R2 ISP C R4
(AS 65001) (AS 65003)

R1

Customer A I can reach


172.20.21.0/24
Static route for 172.20.21.0/24 to
Customer A

Note: All BGP routes start as something other than BGP routes.

2012 Juniper Networks, Inc. All rights reserved. www.juniper.net | 9


ISP As Aggregate
172.20.0.0/16 is reachable through
AS 65002 and AS 65001

172.20.0.0/16 is reachable 172.20.0.0/16 is reachable through


through AS 65001 ISP B
AS 65003, AS 65002 and AS 65001
(AS 65002)

ISP A ISP C
(AS 65001) (AS 65003)

ISP A advertises an aggregate of


172.20.0.0/16 through BGP to ISP B

Customer B
Customer A (AS 65501)

2012 Juniper Networks, Inc. All rights reserved. www.juniper.net | 10


Customer Bs Aggregate
172.31.128.0/20 is reachable through AS
65002, AS 65003 and AS 65501

172.31.128.0/20 is
reachable through AS 65003
ISP B and AS 65501
(AS 65002)

ISP A ISP C
(AS 65001) (AS 65003)

172.31.128.0/20
is reachable
Default static route through AS 65501

Customer B advertises its


172.31.128.0/20 network Customer B
Customer A (AS 65501)
through BGP to ISP C

2012 Juniper Networks, Inc. All rights reserved. www.juniper.net | 11


Customer B Connects to ISP B
ISP B chooses the best path and
advertises only that path

172.31.128.0/20 is reachable 172.31.128.0/20 is reachable


through AS 65002 and AS 65501 ISP B through AS 65003 and AS 65501
(AS 65002)

ISP A ISP C
(AS 65001) (AS 65003)

172.31.128.0/20 is
Default static route reachable through
AS 65501

Customer B advertises its


172.31.128.0/20 network through Customer B
Customer A (AS 65501)
BGP to ISP B and ISP C

2012 Juniper Networks, Inc. All rights reserved. www.juniper.net | 12


BGP Attributes Table
BGP Attributes
Name Type
AS Path Well-known mandatory
Local Preference Well-known discretionary
MED Optional nontransitive
Origin Well-known mandatory
Next Hop Well-known mandatory
Community Optional transitive
Aggregator Optional transitive
Atomic Aggregator Well-known discretionary
Cluster List Optional nontransitive
Originator ID Optional nontransitive

2012 Juniper Networks, Inc. All rights reserved. www.juniper.net | 13


BGP Attributes
BGP attributes are included in the update messages
and describe the BGP prefixes received from a peer
Attributes are used to select the best path
Route X Route X
R1 R2 R3

Established Neighbors Established Neighbors

Some common examples include:

Common BGP Attributes

Next Hop Local Preference AS Path Origin MED Community

2012 Juniper Networks, Inc. All rights reserved. www.juniper.net | 14


BGP Attributes: Next Hop

Common BGP Attributes

Next Hop Local Preference AS Path Origin MED Community

The next-hop attribute is the IP address of the peer


advertising the prefix
Next-hop address must be reachable for receiving peer to
install route in RIB-local (routing table)
Route X
R1 R2

Next-hop value is changed by Next-hop value is not changed by


default across EBGP links only default across IBGP links; can be
changed through policy
Established Neighbors

2012 Juniper Networks, Inc. All rights reserved. www.juniper.net | 15


BGP Attributes: Local Preference

Common BGP Attributes

Next Hop Local Preference AS Path Origin MED Community

Determines the preferred path out of the AS


All BGP traffic in an AS flows toward the peer with the
highest local preference value
Can be altered through BGP configuration or policy
Values are used only within an individual AS
Nothing is sent across EBGP links

2012 Juniper Networks, Inc. All rights reserved. www.juniper.net | 16


Local-Preference Example

MyNET wants to use ISP A for outbound traffic but


have ISP B available for backup outbound traffic

ISP A ISP B
AS 65501 AS 65502

R1 R2

R1: local preference = 300 R2: local preference = 100


IGP
IBGP

R3

MyNET (AS 65503) Default local preference

2012 Juniper Networks, Inc. All rights reserved. www.juniper.net | 17


BGP Attributes: AS Path

Common BGP Attributes

Next Hop Local Preference AS Path Origin MED Community

Used to indicate path back to the routes source and


to prevent routing loops
Routes with the receiving routers AS number in the AS path
are considered looped and not advertised
Route X Route X Route X

AS 501 AS 645 AS 452 AS 521


Route X

Each router on the edge of the AS adds its


AS Path = 645 501 AS Path = 452 645 501
AS number to the front of the path

2012 Juniper Networks, Inc. All rights reserved. www.juniper.net | 18


BGP Attributes: Origin

Common BGP Attributes

Next Hop Local Preference AS Path Origin MED Community

Added by the router that injected a route into BGP


and describes from where the route information
was received
I = IGP (0)
E = EGP (1)
? = Incomplete (2)

2012 Juniper Networks, Inc. All rights reserved. www.juniper.net | 19


BGP Attributes: Multi-Exit Discriminator

Common BGP Attributes

Next Hop Local Preference AS Path Origin MED Community

Used to help influence the preferred path back into an


AS when multiple links exist between the same two ASs
Can be altered through BGP configuration or policy
Lower values are better
Route X (MED = 20)
AS 65501 AS 65502
R1 R1
prefix X
IGP Route X (MED = 10) IGP
IBGP IBGP
R2 R2

2012 Juniper Networks, Inc. All rights reserved. www.juniper.net | 20


BGP Attributes: Community

Common BGP Attributes

Next Hop Local Preference AS Path Origin MED Community

Used to tag certain routes that can be identified easily


Defined under [edit policy-options] hierarchy
[edit policy-options]
user@R1# show
policy-statement ibgp-export {
from neighbor 172.25.125.2;
then {
community set customer-routes; Communities are set, added, or
deleted through routing policy.
}
}
community customer-routes members 64700:133;

Community format is typically: AS-number:community

2012 Juniper Networks, Inc. All rights reserved. www.juniper.net | 21


Selecting the Active BGP Route

Once BGP verifies next-hop reachability and that no


loops exist, it selects the active route as follows:
BGP Route Selection Summary
1. Prefer the highest local-preference value 6. Prefer best exit from AS

2. Prefer the shortest AS-path length 7. For EBGP-received routes, prefer the
current active route; otherwise, prefer
routes from the peer with the lowest RID
3. Prefer the lowest origin value 8. Prefer paths with the shortest cluster
length
4. Prefer the lowest MED value 9. Prefer routes from the peer with the
lowest peer ID
5. Prefer routes learned from an
EBGP peer over an IBGP peer

2012 Juniper Networks, Inc. All rights reserved. www.juniper.net | 22


IBGP Versus EBGP

IBGP is used within an AS, whereas EBGP is used


between ASs
AS 65502

IGP
IBGP

IGP EBGP IGP

AS 65501 AS 65504
IGP
IBGP

AS 65503

2012 Juniper Networks, Inc. All rights reserved. www.juniper.net | 23


Loopback and Interface Peering

IBGP sessions are usually established between


loopback addresses
Uses IGP to maintain sessions regardless of physical topology
EBGP sessions are usually established using the IP
addresses of the physically connected interfaces

AS 65503
R1
ge-0/0/1.0 ge-0/0/1.0
AS 65502 R2
(.1) 172.24.1.0/30 (.2)
IGP
IBGP

If failure occurs, loopback-based IBGP


sessions stay up over working links
R3

2012 Juniper Networks, Inc. All rights reserved. www.juniper.net | 24


IBGP Route Propagation

To avoid loops, BGP speakers do not propagate


IBGP-received routes to other IBGP peers
A full mesh is required to ensure all IBGP speakers have
consistent BGP routing information Rule prohibits R2 from
advertising route X to R3

AS 65503
Route X Route X
R1 R2 R3
AS 65502
IBGP Neighbors IBGP Neighbors

Solution is to have R1 and R3


become IBGP neighbors

2012 Juniper Networks, Inc. All rights reserved. www.juniper.net | 25


IBGP Next-Hop Propagation

By default, IBGP peers do not change the next hop for


routes received from EBGP peers
To make the next hop reachable, you can:
Put external interface in IGP using the passive option, or
Use next-hop self in a policy to cause the router to use its own
IP address as the next hop

By default, the next-hop value for the route X


advertisement will remain as 172.24.1.1

How do I get to
AS 65503 172.24.1.1?
Route X Route X
AS 65502 R1 R2

(.1) 172.24.1.0/30 (.2)


IBGP Neighbors

2012 Juniper Networks, Inc. All rights reserved. www.juniper.net | 26


Default BGP Advertisement Rules
1. IBGP advertises routes 2. EBGP advertises routes
learned from EBGP, and learned from IBGP or EBGP, but
AS 65501
AS 65510 Route X

prefix X
EBGP IGP
IBGP

IGP IGP
IBGP IBGP

AS 65502 AS 65503
3. IBGP does not advertise
any routes learned from IBGP

2012 Juniper Networks, Inc. All rights reserved. www.juniper.net | 27


Case Study: Objectives and Topology

Configure IBGP and EBGP as outlined on the diagram


Use loopback-based IBGP peering sessions
Ensure next-hop reachability for both EBGP peers
Advertise an aggregate route of 172.24.0.0/22 to both ISPs

ISP A ISP B
AS 65501 AS 65502

Note: Loopback addresses are


reachable through the IGP.
AS 65503

ge-0/0/1.0 ge-0/0/1.0
lo0/RID: 192.168.100.1 lo0/RID: 192.168.100.2
R1 (.1) 172.24.1.0/30 (.2) R2
IBGP
2012 Juniper Networks, Inc. All rights reserved. www.juniper.net | 28
Case Study: Configuring BGP
[edit]
user@R1# show routing-options
router-id 192.168.100.1;
autonomous-system 65503; Devices assigned AS number

[edit]
user@R1# show protocols bgp
group int-65503 { BGP group names are user-defined
type internal;
local-address 192.168.100.1;
neighbor 192.168.100.2; BGP session type determines if the
} peering session is IBGP or EBGP
group ext-65501 {
type external;
peer-AS 65501; EBGP peers assigned AS number
neighbor 172.30.1.2;
}

2012 Juniper Networks, Inc. All rights reserved. www.juniper.net | 29


Case Study: Changing the Next Hop
[edit]
user@R1# show policy-options
policy-statement next-hop-self-policy {
term alter-next-hop {
then {
Using the self option alters the next-hop value to the
next-hop self;
address used for the respective peering session
}
}
}

[edit]
user@R1# show protocols bgp
group int-65503 {
type internal;
local-address 192.168.100.1; Policy is applied as an export
export next-hop-self-policy; policy for the internal BGP group
neighbor 192.168.100.2;
}
group ext-65501 {
type external;
peer-AS 65501;
neighbor 172.30.1.2;
}

2012 Juniper Networks, Inc. All rights reserved. www.juniper.net | 30


Case Study: Advertising the Aggregate

[edit]
user@R1# show routing-options aggregate
route 172.24.0.0/22; Aggregate route defined

[edit]
user@R1# show policy-options policy-statement adv-aggregate
term match-aggregate {
from {
protocol aggregate;
route-filter 172.24.0.0/22 exact; Redistribution policy defined
}
then accept;
}

[edit]
user@R1# show protocols bgp group ext-65501
type external;
Redistribution policy applied as an
export adv-aggregate; export policy to the EBGP group
peer-AS 65501;
neighbor 172.30.1.2;

2012 Juniper Networks, Inc. All rights reserved. www.juniper.net | 31


Time Out: Applying Policy to BGP (1 of 2)

A policy can be applied at the protocol, group, and


neighbor hierarchy levels
[edit protocols bgp]
user@R1# show
import add-community;
Only the most specific policy is applied
Protocol level (neighbor, then group, then protocol)
export alt-next-hop;
group ISPs {
type external;
import alt-local-pref; Protocol
Group level
export adv-aggregate;
neighbor 172.25.1.1 {
peer-as 65100;
} Group
neighbor 172.25.2.1 {
Neighbor level export adv-custom;
peer-as 65200;
}
} Neighbor
group Internal-Peers {
type internal;
neighbor 192.168.100.10;
neighbor 192.168.100.20;
}

2012 Juniper Networks, Inc. All rights reserved. www.juniper.net | 32


Time Out: Applying Policy to BGP (2 of 2)

Import Policy Versus Export Policy


Import policies affect routes passed between
the RIB-In and the RIB-Local tables
Export policies affect routes passed between
RIB-Local and the RIB-Out tables
Filtering and attribute Filtering and attribute
manipulation manipulation

Routes
from BGP Import RIB-Local Export Routes to
peers RIB-In (Route table) RIB-Out BGP peers
policy policy

2012 Juniper Networks, Inc. All rights reserved. www.juniper.net | 33


Case Study: Monitoring BGP (1 of 3)

Use the show bgp summary command to show an


overview of the systems BGP information:
user@R1> show bgp summary
Groups: 2 Peers: 2 Down peers: 0
Table Tot Paths Act Paths Suppressed History Damp State Pending
inet.0 12 6 0 0 0 0
Peer AS InPkt OutPkt OutQ Flaps Last Up/Dwn State|#Act/Rec/Acc/Damped.
172.30.1.2 65501 914 915 0 0 6:51:16 6/6/6/0 0/0/0/0
192.168.100.2 65503 978 983 0 0 7:19:03 0/6/6/0 0/0/0/0

2012 Juniper Networks, Inc. All rights reserved. www.juniper.net | 34


Case Study: Monitoring BGP (2 of 3)

Use the show bgp neighbor command to show


the BGP neighbor database:
user@R1> show bgp neighbor
Peer: 172.30.1.2+62790 AS 65501 Local: 172.30.1.1+179 AS 65503
Type: External State: Established Flags: <Sync>
Last State: OpenConfirm Last Event: RecvKeepAlive
Last Error: None
Export: [ adv-aggregate ]
Options: <Preference PeerAS Refresh>
Holdtime: 90 Preference: 170
Number of flaps: 0
Peer ID: 172.18.1.1 Local ID: 192.168.100.1 Active Holdtime: 90
Keepalive Interval: 30 Peer index: 0
BFD: disabled, down
Local Interface: ge-0/0/3.0

2012 Juniper Networks, Inc. All rights reserved. www.juniper.net | 35


Case Study: Monitoring BGP (3 of 3)

Use the show bgp group command to show the


BGP group database:
user@R1> show bgp group
Group Type: Internal AS: 65503 Local AS: 65503
Name: int-65503 Index: 0 Flags: <Export Eval>
Export: [ next-hop-self-policy ]
Holdtime: 0
Total peers: 1 Established: 1
192.168.100.2+51067
inet.0: 0/6/6/0

Group Type: External Local AS: 65503


Name: ext-65501 Index: 1 Flags: <Export Eval>
Export: [ adv-aggregate ]
Holdtime: 0
Total peers: 1 Established: 1
172.30.1.2+62790
inet.0: 6/6/6/0

2012 Juniper Networks, Inc. All rights reserved. www.juniper.net | 36


Case Study: Displaying BGP Routes (1 of 3)

Use show route protocol bgp to display BGP


routes installed in the RIB-Local:
user@R1> show route protocol bgp

inet.0: 15 destinations, 21 routes (15 active, 0 holddown, 0 hidden)


+ = Active Route, - = Last Active, * = Both

10.0.0.0/16 *[BGP/170] 1d 21:43:42, localpref 100


AS path: 64501 65500 65501 65502 65503 I
> to 172.30.1.2 via ge-0/0/3.0
[BGP/170] 1d 21:43:42, localpref 100, from 192.168.100.2
AS path: 64502 65400 65501 65502 65503 I
> to 172.24.1.2 via ge-0/0/1.0

Note: You can add options to filter the output by BGP attributes such as AS path, next
hop, and community.

2012 Juniper Networks, Inc. All rights reserved. www.juniper.net | 37


Case Study: Displaying BGP Routes (2 of 3)

Use show route receive-protocol bgp


neighbor to display received routes (RIB-In):
user@R1> show route receive-protocol bgp 172.30.1.2

inet.0: 14 destinations, 20 routes (14 active, 0 holddown, 0 hidden)


Prefix Nexthop MED Lclpref AS path
* 10.0.0.0/16 172.30.1.2 65501 65510 65515 65520 65525 I
* 10.1.0.0/16 172.30.1.2 65501 65510 65515 65520 65525 I
* 10.2.0.0/16 172.30.1.2 65501 65510 65515 65520 65525 I

Displays route entries in the RIB-In


table that have not yet been filtered

Routes from Import RIB-Local


BGP peers RIB-In (Route table)
policy

2012 Juniper Networks, Inc. All rights reserved. www.juniper.net | 38


Case Study: Displaying BGP Routes (3 of 3)

Use show route advertising-protocol bgp


neighbor to display advertised routes (RIB-Out):
user@R1> show route advertising-protocol bgp 172.30.1.2

inet.0: 14 destinations, 20 routes (14 active, 0 holddown, 0 hidden)


Prefix Nexthop MED Lclpref AS path
* 172.24.0.0/22 Self I

Displays route entries in the RIB-


Out table that are not yet filtered

RIB-Local Export Routes to


(Route table) RIB-Out BGP peers
policy

2012 Juniper Networks, Inc. All rights reserved. www.juniper.net | 39

You might also like