To change this behavior, use the neighbor [ip address] next-hop-self-command in BGP
configuration mode. In Figure, this configuration goes on RtrB. After you give
this command, RtrB advertises its IP address to RtrC as the next hop for
networks from AS 65100, rather than the address of RtrA. Thus, RtrC does not
have to know about the external network between RtrA and RtrB (network 10.2.2.0).
How does BGP select the best routing path /
BGP Attributes
BGP
Best Path Selection Algorithm determines the best route by selecting the
shortest path to the destination. An Autonomous System is a single network or a
set of networks and routers, which are under the control of one administrative
entity. Nevertheless, network administrators frequently manipulate such options
as local preference, lowest multi-exit discriminator and weight.
The
list of the selection criteria is presented below in the same order in which
BGP uses them to select the optimal routes to be injected into the IP Routing
table:
1) Weight — weight is the first criterion used by the router and it
is set locally on the user’s router. The Weight is not passed to the following
router updates. In case there are multiple paths to a certain IP address, BGP
always selects the path with the highest weight. The weight parameter can be
set either through neighbor command, route maps or via the AS-path access list.
Figure: BGP Weight Attribute
In Figure: BGP Weight Attribute,
Router A is receiving an advertisement for network 172.16.1.0 from
routers B and C. When Router A receives the advertisement from Router B,
the associated weight is set to 50. When Router A receives the
advertisement from Router C, the associated weight is set to 100. Both
paths for network 172.16.1.0 will be in the BGP routing table, with
their respective weights. The route with the highest weight will be
installed in the IP routing table.
2) Local Preference — this criterion indicates which route has local preference
and BGP selects the one with the highest preference. Local Preference default
is 100.
Figure: BGP Local Preference Attribute
In Figure: BGP Local Preference Attribute,
AS 100 is receiving two advertisements for network 172.16.1.0 from AS
200. When Router A receives the advertisement for network 172.16.1.0,
the corresponding local preference is set to 50. When Router B receives
the advertisement for network 172.16.1.0, the corresponding local
preference is set to 100. These local preference values will be
exchanged between routers A and B. Because Router B has a higher local
preference than Router A, Router B will be used as the exit point from
AS 100 to reach network 172.16.1.0 in AS 200.
3) Network or Aggregate — this criterion chooses the path that was originated
locally via an aggregate or a network, as the aggregation of certain routes in
one is quite effective and helps to save a lot of space on the network.
4) Shortest AS_PATH — this criterion is used by BGP only in case it detects two
similar paths with nearly the same local preference, weight and locally
originated or aggregate addresses.
Figure: BGP AS_PATH Attribute
AS1 originates the route to 172.16.1.0 and advertises this route to AS 2
and AS 3, with the AS_path attribute equal to {1}. AS 3 will advertise
back to AS 1 with AS-path attribute {3,1}, and AS 2 will advertise back
to AS 1 with AS-path attribute {2,1}. AS 1 will reject these routes when
its own AS number is detected in the route advertisement. This is the
mechanism that BGP uses to detect routing loops. AS 2 and AS 3 propagate
the route to each other with their AS numbers added to the AS_path
attribute. These routes will not be installed in the IP routing table
because AS 2 and AS 3 are learning a route to 172.16.1.0 from AS 1 with a
shorter AS_path list.
5) Lowest origin type — this criterion assigns higher preference to Exterior
Gateway Protocol (EGP) and lower preference to Interior Gateway Protocol (IGP).
6) Lowest multi-exit discriminator
(MED) — this criterion, representing the
external metric of a route, gives preference to the lower MED value.
Figure: BGP Multi-Exit Discriminator Attribute
In Figure: BGP Multi-Exit Discriminator Attribute,
Router C is advertising the route 172.16.1.0 with a metric of 10, while
Route D is advertising 172.16.1.0 with a metric of 5. The lower value
of the metric is preferred, so AS 100 will select the route to router D
for network 172.16.1.0 in AS 200. MEDs are advertised throughout the
local AS.
7) eBGP over iBGP — just like the “Lowest origin type” criterion, this
criterion prefers eBGP rather than iBGP.
8) Lowest IGP metric — this criterion selects the path with the lowest IGP
metric to the BGP next hop.
9) Multiple paths — this criterion serves as indication whether multiple
routes need to be installed in the routing table.
10) External paths — out of several external paths, this criterion selects the
first received path.
11) Lowest router ID — this criterion selects the path which connects to the BGP
router that has the lowest router ID.
12) Minimum cluster list — in case multiple paths have the same router ID or
originator, this criterion selects the path with the minimum length of the
cluster list.
13) Lowest neighbor address — this criterion selects the path, which originates from
the lowest neighbor address.
Example Configuration of BGP
To start BGP on a Cisco router, the following command is required:
router bgp autonomous system number
To define networks to be advertised, apply the following command:
network network-number mask network-mask
You must be aware that the network command is not used in
the same way you use it when you apply networks in OSPF or EIGRP. With BGP, you
use the network command to advertise networks that originate
from the router and need to be advertised through BGP.
To identify peer routers, apply the following command:
neighbor ip-address | peer-group name remote-as autonomous system number
Next, we will see how to configure IBGP and EBGP among the three routers in below
Figure.
Example-6 displays the BGP table on R1, using the command show ip
bgp.
Example-6. show ip bgp
on R1
R1#show ip bgp
BGP table version is 4, local router ID is 131.108.1.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*> 131.108.2.0/24 0.0.0.0 0 32768 i
*> 131.108.3.0/24 0.0.0.0 0 32768 i
*> 131.108.4.0/24 0.0.0.0 0 32768 i
The BGP table on R1 displays three local networks (next hop is 0.0.0.0 or
local interfaces). Example-6 also displays the path as i, or advertised
through BGP. The local router ID is 131.108.1.1.
Example-7 displays the BGP table on R2.
Example-7. show ip bgp
on R2
R2#show ip bgp
BGP table version is 7, local router ID is 171.109.3.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
* i131.108.2.0/24 131.108.1.1 0 100 0 i
* i131.108.3.0/24 131.108.1.1 0 100 0 i
* i131.108.4.0/24 131.108.1.1 0 100 0 i
R2's local router is 131.108.1.2, and it learns the remote loopbacks on R1
through the next hop address 131.108.1.1, or R1's Ethernet interface. Notice
that R2 has set the local preference to 100 (default value); the origin
attribute is set to i or IGP.
Because R1 and R2 are running only IBGP and no other interior gateway
protocol, R2's IP routing table does not have the BGP entries inserted because
of synchronization.
Example-8 confirms this with only the locally connected routes visible on
R2.
Example-8. show ip route
on R2
R2#show ip route
131.108.0.0/24 is subnetted, 2 subnets
C 131.108.255.0 is directly connected, Serial1/0
C 131.108.1.0 is directly connected, Ethernet0/0
To enable BGP to insert the routes, you must disable synchronization or
configure an IGP routing protocol. R2, in turn, does not propagate the
loopbacks to R3; therefore, R3 does not have any entries at all, either in the
BGP table or IP routing table.
Disable synchronization on R1 and R2.
Example-9 displays the no synchronization
command on R1 and R2.
Example-9. Disabling Synchronization on R1/R2
R1(config)#router bgp 1
R1(config-router)#no synchronization
R2(config)#router bgp 1
R2(config-router)#no synchronization
Example-10 displays R2's routing table.
Example-10. R2's Routing Table
R2#sh ip route
131.108.0.0/24 is subnetted, 5 subnets
C 131.108.255.0 is directly connected, Serial1/0
B 131.108.4.0 [200/0] via 131.108.1.1, 00:00:43
B 131.108.3.0 [200/0] via 131.108.1.1, 00:00:43
B 131.108.2.0 [200/0] via 131.108.1.1, 00:00:43
C 131.108.1.0 is directly connected, Ethernet0/0
The three remote networks are inserted into the IP routing tables as
BGP-learned networks.
Example-11 displays R3's BGP and IP routing table.
Example-11. R3's BGP and IP Tables
R3>show ip bgp
BGP table version is 10, local router ID is 131.108.255.2
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal
Origin codes: i - IGP, e - EGP,? - incomplete
Network Next Hop Metric LocPrf Weight Path
*> 131.108.2.0/24 131.108.255.1 0 1 i
*> 131.108.3.0/24 131.108.255.1 0 1 i
*> 131.108.4.0/24 131.108.255.1 0 1 i
R3>show ip route
131.108.0.0/24 is subnetted, 5 subnets
C 131.108.255.0 is directly connected, Serial0
B 131.108.4.0 [20/0] via 131.108.255.1, 00:02:09
B 131.108.3.0 [20/0] via 131.108.255.1, 00:02:09
B 131.108.2.0 [20/0] via 131.108.255.1, 00:02:09
C 131.108.1.0 is directly connected, Ethernet0
Notice that the next hop address on R3 is R2. The AS path on R3 indicates
that the remote networks, 131.108.2.0 to 131.108.4.0/24, transverse autonomous
system number 1, as displayed in the BGP table in Example-11.
Verifying BGP Operation
This final scenario looks at Cisco IOS mechanisms for monitoring and
verifying BGP routing within a Cisco router network.
Refer to Figure and the BGP topology to see how to use some common
show commands to verify that BGP is operating correctly.
Show and debug commands can be valuable,
not only in the real-life networks you come across, but also during your
certification exams.
This scenario covers the following commands:
- show ip bgp summary— Displays BGP
neighbors in summary mode
- show ip bgp— Displays the
BGP topology table
- clear ip bgp *— Clears all
BGP TCP sessions
- show tcp brief— Displays
all TCP sessions (BGP uses TCP)
- debug ip bgp events—
Displays any BGP events, such as neighbor state changes
-
Example 1 displays a sample output taken from R1 in Figure using the
IOS show ip bgp summary command.
Example 1. show ip
bgp summary on R1
R1#show ip bgp summary
BGP router identifier 131.108.255.13, local AS number 1
BGP table version is 11, main routing table version 11
6 network entries and 10 paths using 854 bytes of memory
3 BGP path attribute entries using 280 bytes of memory
BGP activity 50/44 prefixes, 73/63 paths
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
131.108.1.2 4 1 194 195 11 0 0 00:03:22 2
131.108.255.6 4 1 84 83 11 0 0 00:03:23 3
131.108.255.14 4 1 152 152 11 0 0 00:03:23 3
141.199.1.1 4 1001 0 0 0 0 0 never Idle
Example 1 displays a lot of useful information, including the local router
identifier 131.108.255.13, the local AS of 1, and the BGP table version of 11.
(An increasing version number indicates a network change is occurring; if no
changes occur, this number remains the same.) It also shows six network paths
on R1, using 854 bytes of memory.
Memory is important in BGP because in a large network, such as the Internet,
memory can be a limiting factor. As more BGP entries populate the IP routing
table, more memory is required.
Example 2 show ip
bgp
R1>show ip bgp
BGP table version is 11, local router ID is 131.108.255.13
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*>i131.108.255.0/30 131.108.1.2 0 100 1000 i
* i 131.108.255.14 0 100 1000 i
*> 131.108.255.4/30 0.0.0.0 0 32768 i
* i 131.108.255.6 0 100 1000 i
*>i131.108.255.8/30 131.108.1.2 0 100 1000 i
* i 131.108.255.6 0 100 1000 i
*> 131.108.255.12/30 0.0.0.0 0 32768 i
* i 131.108.255.14 0 100 1000 i
*>i141.108.1.0/24 131.108.255.6 0 100 1000 i
*>i151.108.1.0/24 131.108.255.14 0 100 1000 i
Again, the BGP table version is displayed as 11 and the local router ID is
131.108.255.13. The various networks are listed along with the next hop
address, metric (MED), local preference (Locpref), weight, and the path. On the
left side (part of the status codes) indicates an internal BGP route and the i
on the right side of Example 2 indicates the origin. (i is for IGP, part of the
origin codes.)
If a BGP configuration change is completed on Cisco IOS routers, the BGP
peer session must be cleared. The command to clear all sessions is clear
ip bgp *. To clear a single peer router, use the clear ip bgp
peer-ip-address command.
Example 3. clear ip
bgp * and show ip
bgp on R1
R1#clear ip bgp ?
* Clear all connections
<1-65535> AS number of the peers
A.B.C.D BGP neighbor address to clear
dampening Clear route flap dampening information
flap-statistics Clear route flap statistics
peer-group Clear BGP connections of peer-group
R1#clear ip bgp *
R1#show ip bgp
BGP table version is 11, local router ID is 131.108.255.13
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*>i131.108.255.0/30 131.108.1.2 0 1000 1000 i
* i 131.108.255.14 0 1000 1000 i
*> 131.108.255.4/30 0.0.0.0 0 32768 i
* i 131.108.255.6 0 1000 1000 i
*>i131.108.255.8/30 131.108.1.2 0 1000 1000 i
* i 131.108.255.6 0 1000 1000 i
*> 131.108.255.12/30 0.0.0.0 0 32768 i
* i 131.108.255.14 0 1000 1000 i
*>i141.108.1.0/24 131.108.255.6 0 1000 1000 i
*>i151.108.1.0/24 131.108.255.14 0 100 1000 i
This tool displays a number of options, including clearing BGP sessions
based on AS numbers or remote peer address. On Cisco IOS routers, you must clear
the BGP sessions if you want a change to take place because BGP does not update
changes after a BGP session is established. You can, however, configure soft
configurations with the neighbor peer address soft-reconfiguration
inbound command, which enables you to make changes and not have to
clear the TCP peer, resulting in no downtime.
Example 4 show tcp
brief
R1#show tcp brief
TCB Local Address Foreign Address (state)
812CC228 131.108.255.5.11040 131.108.255.6.179 ESTAB
812CF508 131.108.1.1.11039 131.108.1.2.179 ESTAB
812D0054 131.108.255.13.11041 131.108.255.14.179 ESTAB
Router R1, as displayed in Example 4, has three TCP sessions in an
established state. The TCP port numbers are also listed. This command is useful
because you need to be certain that TCP is active at Layer 4 of the OSI model
when troubleshooting to discover why two BGP peers are not sending updates, for
example. The foreign addresses list the TCP port as 179, and the local address
is a number TCP generates. This tells you that R1 has three TCP sessions
active, and you can expect BGP to send updates and keepalives across each TCP
session.
Example 5. show tcp
brief on R1
R1#sh tcp brief
TCB Local Address Foreign Address (state)
812CF984 131.108.255.5.11042 131.108.255.6.179 ESTAB
812CCB20 131.108.1.1.11044 131.108.1.2.179 ESTAB
812CC6A4 131.108.255.13.11043 131.108.255.14.179 ESTAB
Example 6 debug ip
bgp keepalives on R1
R1#debug ip bgp keepalives
BGP keepalives debugging is on
4d01h: BGP: 131.108.255.6 sending KEEPALIVE
4d01h: BGP: 131.108.255.6 KEEPALIVE rcvd
4d01h: BGP: 131.108.255.14 sending KEEPALIVE
4d01h: BGP: 131.108.255.14 KEEPALIVE rcvd
4d01h: BGP: 131.108.1.2 sending KEEPALIVE
4d01h: BGP: 131.108.1.2 KEEPALIVE rcvd
R1 is sending and receiving keepalives to the three remote peers to ensure
that the remote routers are still active. Assume that R1 is reloaded.