BGP is a routing protocol used to exchange routing information between different autonomous systems (Ases) and is described in RFC 4271, A BGP 4. An IGP such as OSPF or IS-IS have a main role for exchange of routing information within each AS. BGP is very scalable and stable routing, therefore bgp in most cases is deployed to improve/enhanced the existing network.
BGP can scale to million of routes and multiple copies of the Internet route table. Therefore, BGP is the fundamental routing protocol of the internet and is used by every ISP in the world for ISP interoperability. Right now BGP still growth to support various capabilities such as multiple protocol families.
BGP Operation
To exchange routing information with BGP, a BGP session must be established between BGP Speaker (Router that running bgp routing known as bgp speaker). BGP routers with established BGP sessions are knows as BGP Neighbors or peers.
A BGP session is established in two phase:
Phase 1:TCP connection – Both BGP speaker atempt a TCP session on port 179. BGP speaker with higher router-ID retains the connection, and the other BGP speaker drop its connection.
Phase 2: BGP Capabilities exchange – After TCP session is established, BGP speaker exchange BGP messages. The following parameters must be correctly configured for a session to be established:
- BGP Version Number
- AS Number of the peer
- BGP router-ID
- Authentication if you configured
BGP currently defines five message types, type 1 throgh 4 defined in RFC 4271, and type 5 is defined in RFC 2918.
- Open – is used to initialy request a BGP session with peer and exchange BGP parameters
- Update – is used to exchange NLRI/Prefix
- Notification – indicate an error and close peer session
- KeepAlive – is used to respond to an Open message and to maintain TCP session
- RouteRefresh – is used to request a BGP peer resend the routes it advertised at session establishment
You can see the exchange more detail in the packet capture file .pcap in this link.
BGP Session Types (eBGP and iBGP)
The different between these type is peer AS. When you peer with the same AS its called iBGP (Internal BGP), and when you peer with the differen AS its called eBGP (External BGP)
eBGP session are usually direct connect between BGP speaker, but its not mandatory, these router are called border or edge router. When you want peer not directly you should set BGP Multi-hop for increase IP TTL.
iBGP session are usually not directly connected. Because the routers are in the same AS and managed by one administrator.
BGP Attributes
BGP is a path-vector protocol that uses BGP path attributes to choose the preferred path to destination. BGP attributes are divided into two main categories: well-known and optional. Well –known attributes have two sub categories: Mandatory and discretionary while Optional attributes have two subcategpries: transitive and non-transitive.
- Well-Known Mandatory –This Type of attribute must be present in every BGP update, and its expected that all BGP speaker understand the meaning of the attribute. If well-known mandatory attribute missing, a Notification message is generated and BGP cant established. The well-known mandatory are Origin, AS-Path, and Next-Hop.
- Well-Known Discretionary – This type of attribute is recognized by all BGP speaker, but may or may not present in the Update message. The sender choice to include it, based in its meaning. The well-known dicretionary attributes are Local Preference and Atomic-Aggregate.
- Optional Transitive – This attribute may or may not be supported in all BGP implementations. If one is snet in an Update message, the BGP speaker must accept the attribute and past it along to other BGP speakers, even if its not supported. Optional trasitive attributes are Aggregator and Community.
- Optional Non-transitive – This attribute may or may not be supported in all BGP implementations. Non-trasitive attribute is not passed to eBGP peers and can be safely ignored if its not understood. Optional non-transitive attribute are MED, Originator-ID, and Cluster-list.
Here some brief explaination about each attributes :
LAB Test
In the Lab The the following Software released were used :
- Nokia (Alcatel Lucent) vSR 13.0.R10
- Juniper vMX 14.R1.10
- Cisco IOSXRv k9-demo-6.0.1
- Huawei eNSP V100R002C00B500
- GNS3 v1.5.2
I would use this base topology for lab test :
We can see 2 AS In the topology above, 65540 and 65550. Each AS running OSPF area 0 as IGP base protocol. But OSPF not mandatory, you can choose other IGP that you want like IS-IS. The IGP infrastructure must be stable because BGP relies on the IGP routing within AS. Instability in the IGP environment may cause a larger problem in BGP.
R1, R2, R3, and R4 act as border router/edge router, R5 and R6 both are member of AS 65540 they have loopback address as customer network and want to advertise to AS 65550 via BGP.
Below OSPF configuration for all routers :
R1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
A:R1>config>router>ospf# info ---------------------------------------------- router-id 10.10.10.1 area 0.0.0.0 interface "system" no shutdown exit interface "to-R2" interface-type point-to-point no shutdown exit interface "to-R6" interface-type point-to-point no shutdown exit exit no shutdown ---------------------------------------------- A:R1>config>router>ospf# |
R2
1 2 3 4 5 6 7 8 9 10 11 12 13 |
root@R2# show area 0.0.0.0 { interface lo0.0; interface ge-0/0/1.0 { interface-type p2p; } interface ge-0/0/2.0 { interface-type p2p; } } [edit protocols ospf] root@R2# |
R3
1 2 3 4 5 6 7 8 9 10 11 |
[R3-ospf-1]display this [V200R003C00] # ospf 1 router-id 10.10.10.3 bandwidth-reference 100000 area 0.0.0.0 network 10.10.10.3 0.0.0.0 network 116.0.0.0 0.0.0.3 # return [R3-ospf-1] |
R4
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
RP/0/0/CPU0:R4#sh run router ospf Mon Mar 20 10:14:11.184 UTC router ospf 1 router-id 10.10.10.4 area 0 interface Loopback0 ! interface GigabitEthernet0/0/0/0 network point-to-point ! ! ! RP/0/0/CPU0:R4# |
R5
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
A:R5>config>router>ospf# info ---------------------------------------------- area 0.0.0.0 interface "system" no shutdown exit interface "to-R1" interface-type point-to-point no shutdown exit interface "to-R6" interface-type point-to-point no shutdown exit exit no shutdown ---------------------------------------------- A:R5>config>router>ospf# |
R6
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
A:R6>config>router>ospf# info ---------------------------------------------- area 0.0.0.0 interface "system" no shutdown exit interface "to-R2" interface-type point-to-point no shutdown exit interface "to-R5" interface-type point-to-point no shutdown exit exit no shutdown ---------------------------------------------- A:R6>config>router>ospf# |
Configuring Global Parameters
Two Global Parameters that are configured when implementing BGP: AS Number and Router ID. Because i use four different router, so the configuration each router also different, but i can say the basic CLI Nokia and Juniper is very similar and Huawei have similarity with Cisco.
For Nokia, AS number can be configured either globallly in the router context or specified peer group with local-as and juniper too. We will configured in global router :
A:R1#configure router autonomous-system 65540
root@R2# set routing-options autonomous-system 65540
For Huawei and Cisco AS number configured in BGP context :
RP/0/0/CPU0:R4(config)#router bgp 65550
[R3]bgp 65550
We must also configuring router-ID at the global or BGP level context, we choose configuring router ID at BGP level. If the router ID have not configuring, the system or loopback address will be derived as router id. If neither router-ID nor system address is configured, a BGP peering is not established.
Group and Peer Configration
A peer group defines a template with common configuration parameters shared by all neighbors in the group. The use of peer groups simplifies BGP management and administration. In Nokia and Juniper defines peer group are mandatory, but in Huawei and Cisco its just an options. In this LAB configuration the all routers defines peer group to facilitate management and administration. Below the configuration of Peer groups for all router :
R1
1 2 3 4 5 6 7 8 |
A:R1>config>router>bgp# info ---------------------------------------------- group "eBGP" exit group "iBGP" exit no shutdown ---------------------------------------------- |
R2
1 2 3 4 5 6 7 8 9 |
root@R2# show group eBGP { type external; } group iBGP { type internal; } [edit protocols bgp] |
R3
1 2 3 4 5 6 7 8 9 10 11 12 |
[R3-bgp]display this [V200R003C00] # bgp 65550 router-id 10.10.10.3 group eBGP external group iBGP internal # ipv4-family unicast undo synchronization peer eBGP enable peer iBGP enable |
R4
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
RP/0/0/CPU0:R4#sh run router bgp Mon Mar 20 10:34:25.111 UTC router bgp 65550 bgp router-id 10.10.10.4 address-family ipv4 unicast ! session-group iBGP remote-as 65550 update-source Loopback0 ! session-group eBGP-peer-65540 remote-as 65540 update-source GigabitEthernet0/0/0/1 ! ! RP/0/0/CPU0:R4# |
We have two BGP group “eBGP” and “iBGP”, eBGP group will you use Interface address AS as source address to update packet while iBGP group will use system address as source IP to update packet.
eBGP anf iBGP Configuration
eBGP peer are usually directly connected, and the peer address used is the neighbor interface address, while iBGP peer are used to system address to provide a more fault-tolerant design. Listing below show the configuration of an eBGP and iBGP session between R1, R2 and R3, R4, R5 and R6. On cisco router we must enable soft-reconfiguration inbound always to store routes that has been received.
R1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
A:R1>config>router>bgp# info ---------------------------------------------- group "eBGP" peer-as 65550 split-horizon neighbor 117.0.0.1 exit exit group "iBGP" type internal neighbor 10.10.10.2 exit neighbor 10.10.10.5 exit neighbor 10.10.10.6 exit exit no shutdown ---------------------------------------------- |
R2
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
root@R2# show group eBGP { type external; peer-as 65550; neighbor 117.0.0.3; } group iBGP { type internal; neighbor 10.10.10.1; neighbor 10.10.10.5; neighbor 10.10.10.6; } [edit protocols bgp] |
R3
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
[R3-bgp]display this [V200R003C00] # bgp 65550 router-id 10.10.10.3 group eBGP external peer 117.0.0.0 as-number 65540 peer 117.0.0.0 group eBGP peer 117.0.0.0 connect-interface GigabitEthernet0/0/0 group iBGP internal peer 10.10.10.4 as-number 65550 peer 10.10.10.4 group iBGP peer 10.10.10.4 connect-interface LoopBack0 # ipv4-family unicast undo synchronization peer eBGP enable peer 117.0.0.0 enable peer 117.0.0.0 group eBGP peer iBGP enable peer 10.10.10.4 enable peer 10.10.10.4 group iBGP # return [R3-bgp] |
R4
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
RP/0/0/CPU0:R4#sh run router bgp Tue Mar 21 04:29:10.949 UTC router bgp 65550 bgp router-id 10.10.10.4 address-family ipv4 unicast ! session-group iBGP remote-as 65550 update-source Loopback0 ! session-group eBGP-peer-65540 remote-as 65540 update-source GigabitEthernet0/0/0/1 ! neighbor 117.0.0.2 use session-group eBGP-peer-65540 address-family ipv4 unicast soft-reconfiguration inbound always ! ! neighbor 10.10.10.3 use session-group iBGP address-family ipv4 unicast soft-reconfiguration inbound always ! ! ! RP/0/0/CPU0:R4# |
R5
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
A:R5>config>router>bgp# info ---------------------------------------------- group "iBGP" type internal export "adv-cus-net" neighbor 10.10.10.1 exit neighbor 10.10.10.2 exit neighbor 10.10.10.6 exit exit no shutdown ---------------------------------------------- |
R6
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
A:R6>config>router>bgp# info ---------------------------------------------- group "iBGP" type internal export "adv-cust-net" neighbor 10.10.10.1 exit neighbor 10.10.10.2 exit neighbor 10.10.10.5 exit exit no shutdown ---------------------------------------------- |
Exporting Network to BGP
The All router required export policy to advertised non-BGP routes in BGP, by default BGP not advertise prefix anything. First, we want to advertise system/loopback address of router R1 and R2 to AS 65550 and vice versa, for router R3 and R4. and then we advertise all customer network through BGP. Below the configuration of policy :
R1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
A:R1>config>router>policy-options# info ---------------------------------------------- prefix-list "system-ip" prefix 10.10.10.1/32 exact exit policy-statement "advertise-system-address" entry 10 from prefix-list "system-ip" exit action accept exit exit exit ---------------------------------------------- ----output-omitted---- group "eBGP" export "advertise-system-address" peer-as 65550 split-horizon neighbor 117.0.0.1 exit exit |
R2
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
root@R2# show prefix-list loopback-address { 10.10.10.2/32; } policy-statement advertise-loopback-address { term 10 { from { prefix-list loopback-address; } then accept; } } ----output-omitted---- group eBGP { type external; export advertise-loopback-address; peer-as 65550; neighbor 117.0.0.3; } [edit] |
R3
1 2 3 4 5 6 7 8 9 10 |
[R3-bgp]display this ----output omitted---- # ipv4-family unicast undo synchronization network 10.10.10.3 255.255.255.255 network 172.16.3.0 255.255.255.0 peer eBGP enable peer 117.0.0.0 enable peer 117.0.0.0 group eBGP |
R4
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
RP/0/0/CPU0:R4#sh run Building configuration... !! IOS XR Configuration 6.0.1 !! Last configuration change at Tue Mar 21 09:38:41 2017 by admin ! ----output-omitted---- route-policy pass-all pass end-policy ! ----output-omitted---- router bgp 65550 bgp router-id 10.10.10.4 address-family ipv4 unicast network 10.10.10.4/32 network 172.16.4.0/24 ! session-group eBGP-peer-65540 remote-as 65540 update-source GigabitEthernet0/0/0/1 ! neighbor 117.0.0.2 use session-group eBGP-peer-65540 address-family ipv4 unicast route-policy pass-all in route-policy pass-all out soft-reconfiguration inbound always ! ! end |
Nokia and Juniper must specify policy statement to tell export their system/loopback address and then apply to BGP group. Huawei and Cisco have same characteristic about how to advertise their system/loopback IP to the BGP, we don’t use specific policy statement to advertise this, we just need define IP in family address unicast with statement network . I think it’s done, but in the cisco router they applied routing special enforcement that mean every eBGP neighbors must have an inbound and outbound policy configured. If no policy is configured, no routes are accepeted from the neighbor, nor are any routes advertised to it. This added security measure ensures that routes cant accidentally be accepted or advertised in the case of a configuration omission error. The enforcment policy affect just on externalBGP neighbor. For internalBGP neighbors all routes are accepted or advertised if there is no policy. For simple eBGP neighbor policy configuration, we will accept and advertised all routes with no modification with policy pass-all. After that router R5 and R6 will received customer 3 and 4 prefix and router R3 and R4 will receive customer 5 and 4 prefix, let see the BGP RIB IN.
R3
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
<R3>display bgp routing-table BGP Local router ID is 10.10.10.3 Status codes: * - valid, > - best, d - damped, h - history, i - internal, s - suppressed, S - Stale Origin : i - IGP, e - EGP, ? - incomplete Total Number of Routes: 10 Network NextHop MED LocPrf PrefVal Path/Ogn *> 10.10.10.1/32 117.0.0.0 0 1.4i i 10.10.10.2/32 117.0.0.2 100 0 1.4i *> 10.10.10.3/32 0.0.0.0 0 0 i i 10.10.10.4/32 10.10.10.4 0 100 0 i *> 172.16.3.0/24 0.0.0.0 0 0 i *>i 172.16.4.0/24 10.10.10.4 0 100 0 i *> 172.16.5.0/24 117.0.0.0 0 1.4i i 117.0.0.2 100 0 1.4i *> 172.16.6.0/24 117.0.0.0 0 1.4i i 117.0.0.2 100 0 1.4i <R3> |
R4
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
RP/0/0/CPU0:R4#show bgp Fri Mar 24 04:28:00.925 UTC BGP router identifier 10.10.10.4, local AS number 65550 BGP generic scan interval 60 secs Non-stop routing is enabled BGP table state: Active Table ID: 0xe0000000 RD version: 9 BGP main routing table version 9 BGP NSR Initial initsync version 2 (Reached) BGP NSR/ISSU Sync-Group versions 0/0 BGP scan interval 60 secs Status codes: s suppressed, d damped, h history, * valid, > best i - internal, r RIB-failure, S stale, N Nexthop-discard Origin codes: i - IGP, e - EGP, ? - incomplete Network Next Hop Metric LocPrf Weight Path * i10.10.10.1/32 117.0.0.0 100 0 65540 i *> 10.10.10.2/32 117.0.0.2 0 65540 i *>i10.10.10.3/32 10.10.10.3 0 100 0 i *> 10.10.10.4/32 0.0.0.0 0 32768 i *>i172.16.3.0/24 10.10.10.3 0 100 0 i *> 172.16.4.0/24 0.0.0.0 0 32768 i * i172.16.5.0/24 117.0.0.0 100 0 65540 i *> 117.0.0.2 0 65540 i * i172.16.6.0/24 117.0.0.0 100 0 65540 i *> 117.0.0.2 0 65540 i Processed 8 prefixes, 10 paths |
R5
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
A:R5# show router bgp routes =============================================================================== BGP Router ID:10.10.10.5 AS:65540 Local AS:65540 =============================================================================== Legend - Status codes : u - used, s - suppressed, h - history, d - decayed, * - valid l - leaked, x - stale, > - best, b - backup, p - purge Origin codes : i - IGP, e - EGP, ? - incomplete =============================================================================== BGP IPv4 Routes =============================================================================== Flag Network LocalPref MED Nexthop (Router) Path-Id Label As-Path ------------------------------------------------------------------------------- i 10.10.10.3/32 100 0 117.0.0.1 None - 65550 i 10.10.10.3/32 100 None 117.0.0.3 None - 65550 i 10.10.10.4/32 100 0 117.0.0.3 None - 65550 i 172.16.3.0/24 100 0 117.0.0.1 None - 65550 i 172.16.3.0/24 100 None 117.0.0.3 None - 65550 i 172.16.4.0/24 100 None 117.0.0.1 None - 65550 i 172.16.4.0/24 100 0 117.0.0.3 None - 65550 u*>i 172.16.6.0/24 100 None 10.10.10.6 None - No As-Path ------------------------------------------------------------------------------- Routes : 8 =============================================================================== |
R6
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
A:R6# show router bgp routes =============================================================================== BGP Router ID:10.10.10.6 AS:65540 Local AS:65540 =============================================================================== Legend - Status codes : u - used, s - suppressed, h - history, d - decayed, * - valid l - leaked, x - stale, > - best, b - backup, p - purge Origin codes : i - IGP, e - EGP, ? - incomplete =============================================================================== BGP IPv4 Routes =============================================================================== Flag Network LocalPref MED Nexthop (Router) Path-Id Label As-Path ------------------------------------------------------------------------------- i 10.10.10.3/32 100 0 117.0.0.1 None - 65550 i 10.10.10.3/32 100 None 117.0.0.3 None - 65550 i 10.10.10.4/32 100 0 117.0.0.3 None - 65550 i 172.16.3.0/24 100 0 117.0.0.1 None - 65550 i 172.16.3.0/24 100 None 117.0.0.3 None - 65550 i 172.16.4.0/24 100 None 117.0.0.1 None - 65550 i 172.16.4.0/24 100 0 117.0.0.3 None - 65550 u*>i 172.16.5.0/24 100 None 10.10.10.5 None - No As-Path ------------------------------------------------------------------------------- Routes : 8 =============================================================================== |
In router R5 and R6, customer prefix of R3 (172.16.3.0/24) and R4 (172.16.4.0/24) doesn’t mark as valid route, Why? lets examine one of the customer prefix and route propagation between AS.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
A:R5# show router bgp routes 172.16.3.0/24 =============================================================================== BGP Router ID:10.10.10.5 AS:65540 Local AS:65540 =============================================================================== Legend - Status codes : u - used, s - suppressed, h - history, d - decayed, * - valid l - leaked, x - stale, > - best, b - backup, p - purge Origin codes : i - IGP, e - EGP, ? - incomplete =============================================================================== BGP IPv4 Routes =============================================================================== Flag Network LocalPref MED Nexthop (Router) Path-Id Label As-Path ------------------------------------------------------------------------------- i 172.16.3.0/24 100 0 117.0.0.1 None - 65550 i 172.16.3.0/24 100 None 117.0.0.3 None - 65550 ------------------------------------------------------------------------------- Routes : 2 =============================================================================== A:R5# show router bgp routes 172.16.3.0/24 hunt =============================================================================== BGP Router ID:10.10.10.5 AS:65540 Local AS:65540 =============================================================================== Legend - Status codes : u - used, s - suppressed, h - history, d - decayed, * - valid l - leaked, x - stale, > - best, b - backup, p - purge Origin codes : i - IGP, e - EGP, ? - incomplete =============================================================================== BGP IPv4 Routes =============================================================================== ------------------------------------------------------------------------------- RIB In Entries ------------------------------------------------------------------------------- Network : 172.16.3.0/24 Nexthop : 117.0.0.1 Path Id : None From : 10.10.10.1 Res. Nexthop : Unresolved Local Pref. : 100 Interface Name : NotAvailable Aggregator AS : None Aggregator : None Atomic Aggr. : Not Atomic MED : 0 AIGP Metric : None Connector : None Community : No Community Members Cluster : No Cluster Members Originator Id : None Peer Router Id : 10.10.10.1 Fwd Class : None Priority : None Flags : Invalid IGP Nexthop-Unresolved Route Source : Internal AS-Path : 65550 Route Tag : 0 Neighbor-AS : 65550 Orig Validation: NotFound Source Class : 0 Dest Class : 0 Add Paths Send : Default Last Modified : 00h03m01s Network : 172.16.3.0/24 Nexthop : 117.0.0.3 Path Id : None From : 10.10.10.2 Res. Nexthop : Unresolved Local Pref. : 100 Interface Name : NotAvailable Aggregator AS : None Aggregator : None Atomic Aggr. : Not Atomic MED : None AIGP Metric : None Connector : None Community : No Community Members Cluster : No Cluster Members Originator Id : None Peer Router Id : 10.10.10.2 Fwd Class : None Priority : None Flags : Invalid IGP Nexthop-Unresolved Route Source : Internal AS-Path : 65550 Route Tag : 0 Neighbor-AS : 65550 Orig Validation: NotFound Source Class : 0 Dest Class : 0 Add Paths Send : Default Last Modified : 00h01m19s ------------------------------------------------------------------------------- RIB Out Entries ------------------------------------------------------------------------------- ------------------------------------------------------------------------------- Routes : 2 =============================================================================== |
Use of Next Hop Self
By default eBGP doesn’t make a change about the next hop address, the router just passed the route without modification. In listing above prefix 172.16.3.0/24 have Res. Nexthop Unresolved because the Next-Hop, 117.0.0.3, is not known in AS 65540. The situation is the same R6. The unresolved Next-Hop issue can be resolved by configuring next-hop-self on router R1 and R2 which play as edge router. When applied to group iBGP, R1 and R2 sets the Next-Hop of routes advertised to its iBGP peers to its system/loopback address.
R1
1 2 3 |
A:R1# configure router bgp group "iBGP" A:R1>config>router>bgp>group# next-hop-self *A:R1>config>router>bgp>group# |
R2
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
root@R2# show ## Last changed: 2017-03-25 03:01:52 UTC version 14.1R1.10; ---output-omitted--- protocols { bgp { group eBGP { type external; export advertise-loopback-address; peer-as 65550; neighbor 117.0.0.3; } group iBGP { type internal; export ibgp-export; neighbor 10.10.10.1; neighbor 10.10.10.5; neighbor 10.10.10.6; } } } } } ---output-omitted--- policy-options { policy-statement ibgp-export { term next-hop-self { then { next-hop self; } } } } [edit] |
Let’s examine customer prefix on router R5 and R6 again.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
A:R5# show router bgp routes 172.16.3.0/24 =============================================================================== BGP Router ID:10.10.10.5 AS:65540 Local AS:65540 =============================================================================== Legend - Status codes : u - used, s - suppressed, h - history, d - decayed, * - valid l - leaked, x - stale, > - best, b - backup, p - purge Origin codes : i - IGP, e - EGP, ? - incomplete =============================================================================== BGP IPv4 Routes =============================================================================== Flag Network LocalPref MED Nexthop (Router) Path-Id Label As-Path ------------------------------------------------------------------------------- u*>i 172.16.3.0/24 100 0 10.10.10.1 None - 65550 *i 172.16.3.0/24 100 None 10.10.10.2 None - 65550 ------------------------------------------------------------------------------- Routes : 2 =============================================================================== A:R5# |
There are other solution to an unresolved Next-Hop. One approch is to advertise the external interface into IGP, typically as passive interafce. However next hop self is simple and effective, and is usually the preffered solution.
Selection of eBGP vs. iBGP routes
When router receives two routes for the prefix, in the example router R2 receive prefix 172.16.3.0/24 from eBGP peer R4 and another from iBGP peer R1. The two routes have the same AS-Path, Origin, and MED. BGP therefore selects the route learned from the eBGP peer over the one learned from iBGP peer, as shown in listing above. The result is the traffic from R2 for 172.16.3.0/24 leaves the AS at R2 instead of through R1.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
root@R2> show route protocol bgp 172.16.3.0/24 detail inet.0: 19 destinations, 22 routes (19 active, 0 holddown, 0 hidden) 172.16.3.0/24 (2 entries, 1 announced) *BGP Preference: 170/-101 Next hop type: Router, Next hop index: 564 Address: 0x940ebb4 Next-hop reference count: 12 Source: 117.0.0.3 Next hop: 117.0.0.3 via ge-0/0/0.0, selected Session Id: 0x1 State: <Active Ext> Local AS: 65540 Peer AS: 65550 Age: 1:29:59 Validation State: unverified Task: BGP_65550.117.0.0.3+30241 Announcement bits (3): 0-KRT 3-BGP_RT_Background 4-Resolve tree 1 AS path: 65550 I Accepted Localpref: 100 Router ID: 10.10.10.4 BGP Preference: 170/-101 Next hop type: Indirect Address: 0x940e380 Next-hop reference count: 3 Source: 10.10.10.1 Next hop type: Router, Next hop index: 565 Next hop: 114.0.0.13 via ge-0/0/1.0, selected Session Id: 0x2 Protocol next hop: 10.10.10.1 Indirect next hop: 0x9680000 - INH Session ID: 0x0 State: <NotBest Int Ext> Inactive reason: Not Best in its group - Interior > Exterior > Exterior via Interior Local AS: 65540 Peer AS: 65540 Age: 1:00:07 Metric: 0 Metric2: 1 Validation State: unverified Task: BGP_65540.10.10.10.1+49185 AS path: 65550 I Accepted Localpref: 100 Router ID: 10.10.10.1 root@R2> |
Selection of Route Based on IGP Cost
When R6 receives two routes for prefix 172.16.3.0/24. and the routes have the same Local-Pref, As-Path, Origin, and MED. They are both learned via iBGP. but the router R6 will choose route from R2 because he have IGP cost lower than R1. The route with the lowest IGP cost to the Next-Hop is selected.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
A:R6# show router bgp routes 172.16.3.0/24 =============================================================================== BGP Router ID:10.10.10.6 AS:65540 Local AS:65540 =============================================================================== Legend - Status codes : u - used, s - suppressed, h - history, d - decayed, * - valid l - leaked, x - stale, > - best, b - backup, p - purge Origin codes : i - IGP, e - EGP, ? - incomplete =============================================================================== BGP IPv4 Routes =============================================================================== Flag Network LocalPref MED Nexthop (Router) Path-Id Label As-Path ------------------------------------------------------------------------------- u*>i 172.16.3.0/24 100 None 10.10.10.2 None - 65550 *i 172.16.3.0/24 100 0 10.10.10.1 None - 65550 ------------------------------------------------------------------------------- Routes : 2 =============================================================================== |
Source :
~. Alcatel-Lucent Service Routing Architect (SRA) Self-Study Guide: Preparing for the BGP, VPRN and Multicast Exams
~. Implementing BGP on Cisco IOS XR Software (Cisco.com)
~. AR150&200&1200&2200&3200 V200R003C01 Configuration Guide – IP Routing (support.huawei.com)
~. Junos OS BGP Feature Guide (Juniper Networks)
Network Telco Engineer – SDN/NFV Enthusiast
Komentar