Friday, March 18, 2011

Basic BGP Lab

Basic BGP Network

RT1 and RT2 in the figure above define each other as BGP neighbors, start an EBGP session, and advertise the networks and between them.

The router bgp {local-as-num} global configuration command identifies the local AS and enters into the BGP configuration mode. The BGP process must be informed of its AS for it to differentiate between EBGP and IBGP neighbors when BGP neighbors are configured. Only a single instance of BGP process can be configured on a router at a time.
Below shows the error message upon trying to initiate another instance of BGP process on RT1:
RT1(config)#router bgp 65002
BGP is already running; AS is 65001

The neighbor {ip-addr | peer-group-name} remote-as {as-num} BGP router subcommand identifies a BGP peer router with which the local BGP router will establish a BGP session. Neighbor must be explicitly configured with this command for BGP to establish an adjacency. The BGP process determines whether the communication with the neighbor is an EBGP or IBGP session using the as-num parameter. BGP initiates an IBGP session when the as-num specified in the router bgp and the neighbor remote-as BGP router subcommands is the same; and initiates an EBGP session when the value is different. The shutdown keyword can be specified to disable (administratively shut down) an existing BGP neighbor or peer group. When implementing major policy changes and changing multiple parameters to a neighbor router, it is required to administratively shut down the neighboring router, implement the changes, and then enable the neighboring router with the no neighbor {ip-addr | peer-group-name} shutdown to bring back the session.

The neighbor and network commands tell BGP where and what to advertise respectively. The network {net-num} [mask net-mask] BGP router subcommand defines a subnet or prefix in the IP routing table that is to be advertised by BGP. The net-mask identifies the subnet mask to be advertised by BGP. If the network mask is not specified, it is default to the classful mask.

The network BGP router subcommand defines the networks that a BGP router should originate, which is a different concept from the IGP network commands that start up an IGP to send and receive IGP updates on the matched interfaces, as well as advertise the matched networks. Without a network statement, BGP passes along the received advertisements from other routers, but does not originate any network advertisements itself. In BGP, the network listed in the network statement does not have to be directly connected, as it does not identify interfaces on the router as like in other IGPs.

The mask parameter is often being used as BGP-4 supports subnetting and supernetting. The list of network commands must include all the networks that an ASs want to advertise, not just those locally connected networks on the BGP router.

The network BGP router subcommand allows classless prefixes; a BGP router can advertise individual networks, subnets, and supernets. Note that the prefix must exactly match an entry (both address and mask) in the IP routing table. A static null route is often configured to create a supernet entry in the IP routing table in order to allow BGP to advertise the supernet.

If net-mask is not specified, the network command announces only the classful network number. At least one subnet of the specified major network must be present in the IP routing table to allow BGP to announce the classful network as a BGP router. However, when the net-mask is specified, an exact match to the network (both address and mask) must exist in the routing table for the network to be advertised.
Ex #1: The network mask command is configured by mistake. BGP looks for in the routing table. It might find, but it will never find Since the routing table does not contain a specific match upon the network, BGP does not announce the network to any peer.
Note: This example is just for demonstration purpose and actually cannot be configured.
Router(config-router)#network mask
% BGP: Incorrect network or mask configured
Ex #2: The network mask command is configured to advertise a CIDR block. BGP looks for in the routing table. It might find, but it will never find BGP does not announce the to any peer. The static route ip route Null0
can be configured for BGP to find an exact match in the routing table and therefore announces the network to any peer.

The show ip bgp summary EXEC command displays the status about all BGP connections:
RT1#sh ip bgp summary
BGP router identifier, local AS number 65001
BGP table version is 3, main routing table version 3
2 network entries using 202 bytes of memory
2 path entries using 96 bytes of memory
2 BGP path attribute entries using 120 bytes of memory
1 BGP AS-PATH entries using 24 bytes of memory
0 BGP route-map cache entries using 0 bytes of memory
0 BGP filter-list cache entries using 0 bytes of memory
BGP using 442 total bytes of memory
BGP activity 2/0 prefixes, 2/0 paths, scan interval 60 secs

Neighbor      V    AS MsgRcvd MsgSent  TblVer InQ OutQ Up/Down  State/PfxRcd    4 65002       6       6       3   0    0 00:01:54        1
* The BGP table version increments upon the changes in the BGP table.
* The TblVer indicates the last version of the BGP table that was sent to a neighbor.
* The InQ (in queue) indicates the number of messages from a neighbor that are waiting to be processed; the OutQ (out queue) indicates the number of messages queued up and waiting to be sent to a neighbor. TCP flow control prevents the local router from overwhelming a neighbor with a large update.
* The Up/Down indicates the length of time a neighbor has been in the current BGP state – established, active, or idle.
* The PfxRvd (prefix received) indicates the number of BGP network entries that have been received from a neighbor when the session is in the established state.

The show ip bgp neighbors [ip-addr] EXEC command displays detailed information about the TCP and BGP connections to all or a specified BGP peer:
RT1#sh ip bgp neighbors
BGP neighbor is,  remote AS 65002, external link
  BGP version 4, remote router ID
  BGP state = Established, up for 00:02:00
  Last read 00:00:00, hold time is 180, keepalive interval is 60 seconds
  Neighbor capabilities:
    Route refresh: advertised and received(old & new)
    Address family IPv4 Unicast: advertised and received
  Message statistics:
    InQ depth is 0
    OutQ depth is 0
                         Sent       Rcvd
    Opens:                  1          1
    Notifications:          0          0
    Updates:                1          1
    Keepalives:             5          5
    Route Refresh:          0          0
    Total:                  7          7
  Default minimum time between advertisement runs is 30 seconds

 For address family: IPv4 Unicast
  BGP table version 3, neighbor version 3
  Index 1, Offset 0, Mask 0x2
                                 Sent       Rcvd
  Prefix activity:               ----       ----
    Prefixes Current:               1          1 (Consumes 48 bytes)
    Prefixes Total:                 1          1
    Implicit Withdraw:              0          0
    Explicit Withdraw:              0          0
    Used as bestpath:             n/a          1
    Used as multipath:            n/a          0

                                   Outbound    Inbound
  Local Policy Denied Prefixes:    --------    -------
    Bestpath from this peer:              1        n/a
    Total:                                1          0
  Number of NLRIs in the update sent: max 1, min 0

  Connections established 1; dropped 0
  Last reset never
Connection state is ESTAB, I/O status: 1, unread input bytes: 0
Local host:, Local port: 179
Foreign host:, Foreign port: 29301
--- output omitted ---

The show ip bgp EXEC command displays entries in the BGP topology database (BGP table).
Specify a network number and subnet mask for more specific information about a particular network:
RT1#sh ip bgp
BGP table version is 3, local router ID is
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*>                  0         32768 i
*>               0             0 65002 i
RT1#sh ip bgp
BGP routing table entry for, version 2
Paths: (1 available, best #1, table Default-IP-Routing-Table)
Flag: 0x820
  Advertised to non peer-group peers:
  Local from (
      Origin IGP, metric 0, localpref 100, weight 32768, valid, sourced, local, best
RT1#sh ip bgp
BGP routing table entry for, version 3
Paths: (1 available, best #1, table Default-IP-Routing-Table)
Flag: 0x820
  Not advertised to any peer
  65002 from (
      Origin IGP, metric 0, localpref 100, valid, external, best
The status codes are shows at the beginning of each entry; and the ORIGIN codes are shown at the end of each entry.
* An s indicates that route summarization has been performed and the route is suppressed.
* A d indicates that the route is being dampened for going up and down (flapping) too often. Although the route is up at the moment, it is not advertised until the penalty has expired.
* An h (history) indicates that the route is unavailable and is probably down; historic information about the route exists, but a best route does not exist.
* An > indicates the best path for a route selected by the BGP best path selection algorithm; this route is offered to the IP routing table and advertised to other BGP neighbors.
* An i indicates the route is learned from an IBGP peer.
* The in the Next Hop column means that the local router has originated the route.
* The Path column contains the AS_PATH information. The first ASN listed is the adjacent AS that the route was learned from; and the last ASN is the originating AS. It the Path column is blank, the route is originated from the local AS.
* The last column indicates how the route was entered into BGP on the originating router. An i means that the originating router has used a network or redistribute command to introduce the route into BGP; an e means that the originating router has redistributed an EGP route into BGP; an ? means that the originating BGP process is unable to absolutely verify the availability of the route, as it is redistributed from an IGP into BGP.

No comments:

Post a Comment