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 192.168.1.0/24 and 192.168.2.0/24 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
RT1(config)#

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 192.168.1.1 mask 255.255.255.0 command is configured by mistake. BGP looks for 192.168.1.1/24 in the routing table. It might find 192.168.1.0/24, but it will never find 192.168.1.1/24. Since the routing table does not contain a specific match upon the network, BGP does not announce the 192.168.1.1/24 network to any peer.
Note: This example is just for demonstration purpose and actually cannot be configured.
Router(config-router)#network 192.168.1.1 mask 255.255.255.0
% BGP: Incorrect network or mask configured
Router(config-router)#
Ex #2: The network 192.168.0.0 mask 255.255.0.0 command is configured to advertise a CIDR block. BGP looks for 192.168.0.0/16 in the routing table. It might find 192.168.1.0/24, but it will never find 192.168.0.0/16. BGP does not announce the
192.168.0.0/16 to any peer. The static route ip route 192.168.0.0 255.255.0.0 Null0
can be configured for BGP to find an exact match in the routing table and therefore announces the 192.168.0.0/16 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 192.168.1.1, 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
12.12.12.2    4 65002       6       6       3   0    0 00:01:54        1
RT1#
* 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 12.12.12.2,  remote AS 65002, external link
  BGP version 4, remote router ID 192.168.2.1
  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: 12.12.12.1, Local port: 179
Foreign host: 12.12.12.2, 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 192.168.1.1
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
*> 192.168.1.0      0.0.0.0                  0         32768 i
*> 192.168.2.0      12.12.12.2               0             0 65002 i
RT1#
RT1#sh ip bgp 192.168.1.0
BGP routing table entry for 192.168.1.0/24, version 2
Paths: (1 available, best #1, table Default-IP-Routing-Table)
Flag: 0x820
  Advertised to non peer-group peers:
  12.12.12.2
  Local
    0.0.0.0 from 0.0.0.0 (192.168.1.1)
      Origin IGP, metric 0, localpref 100, weight 32768, valid, sourced, local, best
RT1#
RT1#sh ip bgp 192.168.2.0
BGP routing table entry for 192.168.2.0/24, version 3
Paths: (1 available, best #1, table Default-IP-Routing-Table)
Flag: 0x820
  Not advertised to any peer
  65002
    12.12.12.2 from 12.12.12.2 (192.168.2.1)
      Origin IGP, metric 0, localpref 100, valid, external, best
RT1#
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 0.0.0.0 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