Anda di halaman 1dari 40

BGP Basics

1. Basic BGP Properties


Routing update carries multiple attributes
Next-hop and origin attributes Path-Vector attribute prevent routing loop among ASes

net1 <100>, origin = i next hop = 192.10.1.1

net1 <200, 100>, origin = i next hop = 20.1.1.1

net1, <300, 200, 100>, origin = i, next hop=65.1.1.1


CN8815 Network Architecture 1

BGP Basics
Explicit peer connection
BGP peers must explicitly indicate their desire of establishing a BGP session with each other A TCP connection must be first established Usually, an IGP or static-route configuration is required to support the establishment of some types of BGP sessions

TCP connection BGP connection

CN8815 Network Architecture

BGP Basics
Continue
BGP finite-state machine Idle
Initiate a TCP connection

Connect
Timer expires/ Initiate a TCP connection

TCP session established/ send open message

TCP connection terminated, Notification, keep-alive message time out

TCP connection fails

Active
Send updates or keep-alive messages Received keep-alive message

Open sent
Receive open message/ send keep alive message

TCP session established/ send open message

Established

Open received
3

CN8815 Network Architecture

BGP Basics
Incremental update and route withdrawal
Reduce the traffic load Use keep-alive message to maintain the BGP session

net 4 net 4 net 4 net 4

withdrawals: net2, net3 withdrawals: net2, net3


CN8815 Network Architecture 4

BGP Basics
2. Internal and External BGP sessions
A BGP session between two ASes is called external BGP A BGP session between two BGP routers in the same AS is called internal BGP

IBGP EBGP multi-hop EBGP

router bgp AS-number neighbor ip-address remote-as AS-number


CN8815 Network Architecture 5

BGP Basics
Routes learned from an EBGP peer are distributed to other IBGP and EBGP peers Routes learned from an IBGP peer will only be distributed to other EBGP peers

EBGP(net1)

IBGP(net1) IBGP(net1) EBGP(net1) EBGP(net1)


CN8815 Network Architecture

BGP Basics
The IBGP characteristic is used to prevent routing loop inside the AS.
net1 <20 10> Without the IBGP route distribution restriction, routing loop may result

AS 20
net1 <10>

net1 <10> net1 <10>

net1 <30 40 20 10> AS Path attribute can only prevent routing loop among ASes

CN8815 Network Architecture

BGP Basics
3. Recursive Routing Table Lookup
BGP route advertisement only specifies the BGP next hop, which is not necessary the physical next hop
To use the BGP entry in the routing table, recursive lookup is required to determine the physical next hop

Routing Table
net1, next_hop=200.10.1.1

Addr.

Next Hop

Interface Fa0/1

Net1 200.10.1.1 200.10.1.0/24 145.10.1.1

Forwarding Datagram to net1

Recursive lookup

CN8815 Network Architecture

BGP Basics
Next-Hop attribute manipulation
N.H. attribute indicates the downstream router of the route By default, the Next-Hop attribute will not changed in IBGP route distribution

Net 1 Next-hop=R3

Net 1 Next-hop=R3

Net 1 Next-hop=R2

CN8815 Network Architecture

BGP Basics
The route is only valid if the next hop is accessible the routing table must provide the information on how to reach the next hop

net1 N.H. = R1

If R3 does not know how to reach R1, then the route will not be adopted and advertised net1 N.H.=R3

net1 N.H. = R1

CN8815 Network Architecture

10

BGP Basics
It is necessary sometimes to change the Next-Hop value in the IBGP update

net1 N.H. = 150.10.1.2

IGP(subnets of 145.10.0.0/16) IBGP net1 N.H.=145.10.1.1

BGP Table Route N.H. * net1 145.10.1.1

Neighbor 145.10.4.1 next-hop-self

CN8815 Network Architecture

11

BGP Basics
4. Synchronization
The physical path of the IBGP route may have to go through the intermediate router(s)
The route is not feasible if the intermediate router(s) has(have) not learned the route
Addr N.H.
R2

net2

DC

Net 2 IBGP(net1) EBGP (net1)


R1

Net 3

No entry of Net 1

R3

Addr N.H. net1 R1 net2 R2


12

CN8815 Network Architecture

BGP Basics
Synchronization rule:
A route learned from an IBGP peer is feasible only if it is also learned through IGP IBGP route The route will not be applied to the route selection process Route is not feasible

Is route also learned by IGP? The route must be in the Routing table Yes Route is feasible

No

The route will be applied to the route selection process and may be advertised to the peer(s)
13

CN8815 Network Architecture

BGP Basics
To abide to the synchronization rule, external BGP routes must be redistributed into IGP
Addr N.H. Net2 DC Net1 R1
R2

Learned from IGP

Net 2 redistribution

IGP (Net1)

Net 3

IBGP(net1) EBGP

(Net1)

R1

R3

EBGP(Net1)
CN8815 Network Architecture

Addr N.H. Net1 R2 Net2 R2

14

BGP Basics
Synchronization problems:
BGP may carry thousands of routes Redistribution may cause the IGP overload

In practice, BGP synchronization is disabled Configuration: router bgp AS-number no synchronization Other methods are used to deal with the synchronization issues

CN8815 Network Architecture

15

BGP Basics
Solutions:
Full-mesh IBGP all the routers in the AS are IBGP-connected with each other Route reflector Confederation

net1 net1 net1 net1

CN8815 Network Architecture

16

BGP Basics
5. Advertisement of Routes from Non-BGP Source
Redistribution from IGP to BGP
Less control on route distribution Loss of AS-Path information Route filter at the BGP router is required AS 10 redistribution EBGP(net1) <20> AS20 Net 1 EBGP(net1) <10>
CN8815 Network Architecture 17

IGP(net1)

redistribution EBGP(net1) <10>

BGP Basics
Semi-dynamic routing update
Use network command to specify which networks will be advertised by BGP Configuration:

router bgp AS-number network ip-prefix [mask mask]


The BGP process will verify the existence of the route by checking the routing table

The route is advertised only if it exits in the routing table

CN8815 Network Architecture

18

BGP Basics
Example
AS 10 145.10.1.0/24 145.10.2.0/24 down 145.10.3.0/24 145.10.4.0/24

IGP

router BGP 10 network 145.10.1.0 mask 255.255.255.0 network 145.10.2.0 mask 255.255.255.0 network 145.10.3.0 mask 255.255.255.0

EBGP 145.10.1.0/24 145.10.2.0/24 145.10.3.0/24

CN8815 Network Architecture

19

BGP Basics
Static routing updates
Combining static route and network commands

ip route ip-prefix mask {next-hop-address | interface} router bgp AS-number network ip-prefix [mask mask]
AS 10 145.10.1.0/24 145.10.2.0/24 145.10.3.0/24 ip route 150.10.0.0 255.255.0.0 null0 router BGP 10 network 145.10.0.0 network 150.10.0.0
CN8815 Network Architecture

IGP

EBGP 145.10.0.0/16 150.10.0.0/16


20

BGP Basics
6. BGP Update Packets
Update packet format

Unfeasible Route Length Withdrawn Routes (variable) Total Path Attribute Length Length Prefix Path Attributes (variable) Network Layer Reachability Information (NLRI)

CN8815 Network Architecture

21

BGP Basics
Example:

withdrawal: 200.10.1.0/24 200.10.2.0/24 200.10.3.0/24 145.10.0.0/16 150.10.0.0/16

update packet

155.10.2.1

CN8815 Network Architecture

22

BGP Basics
Continue update packet content: 3 200.10.1.0/24 200.10.2.0/24 200.10.3.0/24 Path attribute length AS-PATH = <AS100, AS200> Next hop = 155.10.2.1 145.10.0.0/16 150.10.0.0/16

CN8815 Network Architecture

23

BGP Basics
Path attribute format
Type code Length Value

0 1-byte length field 1 2-byte length field 0 complete 1 - partial 0 non-transitive 1 transitive 0 - well-known 1 - optional

CN8815 Network Architecture

24

BGP Basics
Path attributes
Well-know mandatory must be in the BGP update packets Well-know discretionary recognized by all BGP implementations, but it may not be in BGP update packets Optional may not be recognized by a BGP implementation non-transitive

if it is not recognized by a BGP implementation, it will be removed only kept within an AS


Transitive it will be passed to the BGP peer, even if it is not recognized Complete the attribute is recognized by all downstream routers Partial the attribute is not recognized by all downstream routers.

CN8815 Network Architecture

25

BGP Basics
Example

010 010 100 110

AS-Path: <100> Next Hop: R1 Mult_Exit_Disc new attribute

010 010 100 111

AS-Path: <200 100> Next Hop: R3 Mult_Exit_Disc new attribute Not recognized

CN8815 Network Architecture

26

BGP Basics
7. BGP Attributes
Types Attribute Name 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. Origin AS_Path Next-Hop Multi_Exit_Disc Local_Preference Atomic_Aggregate Aggregator Community Originator_ID Cluster_List Category/Type Code Well-known mandatory Well-known mandatory Well-known mandatory Optional nontransitive Well-known discretionary Well-known discretionary Optional transitive Optional transitive Optional nontransitive Optional nontransitive
27

CN8815 Network Architecture

BGP Basics
Attribute functions
Origin, AS_PATH, Local_preference, and Multi_Exit_Disc

used for route selection process AS_PATH is also used for routing loop detection
Atomic_Aggregate, and Aggregator

used for providing route aggregation information


Community

used for route filtering and attribute manipulation


Originator ID and Cluster_List

used for routing loop detection within AS when the routereflector is configured
Others

route distribution in NAP and multiprotocol attributes


CN8815 Network Architecture 28

BGP Basics
7. BGP Routing Process
BGP process structure

CN8815 Network Architecture

29

BGP Basics
Route Selection Process
Route selection is based on the various attribute values In general, an attribute more specific to local policies has a higher precedence
This allows the administration of a domain to control its own policies Weight configured and used within a BGP router Local_Preference configured and used within one AS AS_PATH length derived based on the AS_PATH attribute Origin indicates where the route originated MED attribute assigned by the other AS Weight > Local_Preference > AS_PATH length > Origin > MED

CN8815 Network Architecture

30

BGP Basics
BGP route decision process (From Cisco document)
1. 2. 3. 4. 5. 6. 7. 8. 9. If the next hop is inaccessible, the route is ignored Prefer the path with the largest weight (weight is a Cisco proprietary parameter) Prefer the route with the largest local preference value Prefer the route with the shortest AS_PATH Prefer the route with the lowest origin type Prefer the route with the lowest MED value if the routes were received from the same AS Prefer EBGP paths to IBGP paths Prefer the route that can be reached via the closest IGP neighbor. (Follow the shortest path to the BGP Next-Hop Prefer the route coming from the BGP router with the lowest Router ID

CN8815 Network Architecture

31

BGP Basics
EBGP > IBGP
BGP updates usually contain routes from other ASes Preferring EBGP route means traffic can be directly sent out to the peer AS without traversing the local AS

IBGP(net1) EBGP(net1)

EBGP(net1)

net1

net1

CN8815 Network Architecture

32

BGP Basics
Prefer closest IGP neighbor Prefer lowest peer ID

net1
Preferred 145.10.1.1 Preferred 145.10.12.1

net1

CN8815 Network Architecture

33

BGP Basics
Example
170.1.0.0/16 <1,3> 145.10.0.0/16 <1> 193.168.2.0/24 <5,1,2>, LP=200 145.10.0.0/16 <5,1> 150.10.0.0/16 <5> 140.10.0.0/16 <.>

130.15.0.0/16 <4> 193.168.2.0/24 <4,2>

AS 6

CN8815 Network Architecture

34

BGP Basics
Continue
Incoming policy configured at R1

rejects all the external routes from R3 except 145.10.0.0/16


Outgoing policies

Route to 130.15.2.0/24 is not advertised to other ASes When route to 145.10.0.0/16 is advertised to other ASes Artificially increasing the AS_PATH length by 2 Advertise 140.10.0.0/16 to other ASes

CN8815 Network Architecture

35

BGP Basics
Continue BGP Table
Route Next-Hop 0.0.0.0 R4 R2 R2 R5 R3 R5 R5 Default: 100

Local Metric Preference Weight 0 0 100 32768 0 0 0 0 0 0 0

AS PATH <.> <.> <4> <4,2> <5,1,2> <1> <5,1> <5>

Origin i i i i i i i i

> * 140.10.0.0/16
Best route

> > >


IBGP route

>

*i 140.10.0.0/16 * 130.15.0.0/16 * 193.168.2.0/24 *i * 145.10.0.0/16 *i *i 150.10.0.0/16

200 100 100

Feasible route

If R1 knows the route to R5, then the iBGP routes are feasible

Default: 0

CN8815 Network Architecture

36

BGP Basics
Continue
Outgoing routing updates
140.10.0.0/16, NH=R1, <6> 193.168.2.0/24, NH=R1, <6,5,1,2> 150.10.0.0/16, NH=R1, <6,5>

140.10.0.0/16, NH=R1, <.> 145.10.0.0/16, NH=R3, <1> 130.15.0.0/16, NH=R2, <4>

AS 6 140.10.0.0/16, NH=R1, <6> 193.168.2.0/24, NH=R1, <6,5,1,2> 145.10.0.0/16, NH=R1, <6,6,6,1> 150.10.0.0/16, NH=R1, <6,5>

CN8815 Network Architecture

37

BGP Basics
9. Multiprotocol Extensions for BGP
The NLRI attribute in BGP is only defined for IPv4 address
To support multiprotocol environment, new attributes are needed to carry NLRI information of other address families

The MP_REACH_NLRI attribute contains the next hop information Two new attributes
MP_REACH_NLRI; MP_UNREACH_NLRI

CN8815 Network Architecture

38

BGP Basics
MP_REACH_NLRI format

2 octets 1 octet 1 octet variable 1 octet variable variable

Address Family Identifier (AFI) Subsequent AFI Length of Next Hop Address Next Hop Address Number of SNAPs SNAPs NLRI

IPv4-1; IPv6-2 unicast-1; multicast-2; vpn-128

Second-layer addresses

CN8815 Network Architecture

39

BGP Basics
MP_UNREACH_NLRI format
AFI SAFI Withdrawn Routes

IPv6 example

R1

R2

R3
NLRI= ::06:1234:5678 NH=R2s non-link IPv6 address

NLRI= ::06:1234:5678 NH=R1s non-link IPv6 address R1s link IPv6 address SNPA=R1s second layer address

CN8815 Network Architecture

40

Anda mungkin juga menyukai