Configuring BGP

  1. Start BGP

    router{}edit conf myconfig
    router{conf:myconfig}rtg
    router{conf:myconfig-rtg}router bgp ASN
    
    ASN

    ASN of your local AS.

    Note

    You can alsop stop BGP:

    router{conf:myconfig-rtg}delete router bgp ASN
    
  2. Connect to a remote BGP router:

    router{conf:myconfig-rtg-bgp}neighbor A.B.C.D remote-as ASN
    
    A.B.C.D

    IPv4 address of the remote BGP router.

    ASN

    ASN of the remote BGP router.

    Note

    The remote BGP router should be a direct next hop of your local BGP router. Otherwise you are trying to configure a multihop BGP peering.

  3. Announce the network prefixes, which will be originated from your AS:

    router{conf:myconfig-rtg-bgp}network A.B.C.D/M
    
    A.B.C.D

    IPv4 prefix that will be announced by your BGP router.

    M

    Length of the mask of the A.B.C.D network.

    Note

    • The network prefix A.B.C.D/M should be an aggregated (summarized) prefix of the networks that you own and that you originate.Moreover, to avoid a routing loop, a black-hole route or a reject route should be configured.
    • The BGP network command has a different meaning than the RIP and OSPF v2 network command.
  4. Configure BGP 4:

    Let’s use the basic example of the figure below where rt1 belongs to the AS 65500, rt2 to the AS 65510, rt3 to the AS 65520 and rt4 to 65530.

../../../../../_images/your-first-bgp-4-configuration.png

Your first BGP 4 configuration

We suppose that:

  • rt1 has a peering with rt2 and rt3
  • rt2 has a peering with rt1 and rt4
  • rt3 has a peering with rt1 and rt4
  • rt4 has a peering with rt2 and rt3

The advertised networks are:

  • rt1 announces the network 192.168.1.0/24
  • rt2 announces the network 192.168.2.0/24
  • rt3 announces the network 192.168.3.0/24
  • rt4 announces the network 172.16.1.0/24

We will have the following configurations.

rt1

[...]
router bgp 65500
neighbor 10.1.1.3 remote-as 65520
neighbor 10.1.1.2 remote-as 65510
network 10.1.1.0/28
network 192.168.1.0/24
[...]

rt2

[...]
router bgp 65510
neighbor 10.1.1.4 remote-as 65530
neighbor 10.1.1.1 remote-as 65500
network 10.1.1.0/28
network 192.168.2.0/24
[...]

rt3

[...]
router bgp 65520
neighbor 10.1.1.4 remote-as 65530
neighbor 10.1.1.1 remote-as 65500
network 10.1.1.0/28
network 192.168.3.0/24
[...]

rt4

[...]
router bgp 65530
neighbor 10.1.1.3 remote-as 65520
neighbor 10.1.1.2 remote-as 65510
network 10.1.1.0/28
network 172.16.1.0/24
[...]
  1. Check the status of the BGP connection, type the command show routing ip bgp summary. This is the first thing to do to check whether the BGP session is ok.

    rt1{}show routing ip bgp summary
    BGP router identifier 192.168.1.1, local ASN 65500
    11 BGP AS-PATH entries
    0 BGP community entries
    
    Neighbor  V  AS     MsgRcvd  MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
    10.1.1.2  4  65510  35       35      0      0   0    00:26:10 4
    10.1.1.3  4  65520  22       21      0      0   0    00:15:33 4
    
    Total number of neighbors 2
    
  2. Check the output of the state column, it must be blank in case the BGP connection is established, otherwise it reflects the state of the BGP connection. The different BGP session states are studied later in the section.

    This command is very helpful and gives a summary of the different BGP sessions.

    From the output we can conclude that router rt1 has two BGP neighbors, one in AS 65510 the other in AS 65520, and that rt1 is receiving 4 prefixes from each neighbor (PfxRcd).

    For more information about a given session, use the detailed command show routing ip bgp neighbors A.B.C.D.

    This command gives detailed BGP information about a given neighbor

    rt1{}show routing ip bgp neighbors 10.1.1.3
    BGP neighbor is 10.1.1.3, remote AS 65520, local AS 65500, external link
      BGP version 4, remote router ID 192.168.3.1
      BGP state = Established, up for 00:28:54
      Last read 00:00:54, hold time is 180, keepalive interval is 60 seconds
      Neighbor capabilities:
        Route refresh: advertised and received (old and new)
        Address family IPv4 Unicast: advertised and received
      Received 35 messages, 0 notifications, 0 in queue
      Sent 34 messages, 0 notifications, 0 in queue
      Route refresh request: received 0, sent 0
      Minimum time between advertisement runs is 30 seconds
    
     For address family: IPv4 Unicast
      Community attribute sent to this neighbor (both)
      4 accepted prefixes
    
      Connections established 1; dropped 0
    Local host: 10.1.1.1, Local port: 3902
    Foreign host: 10.1.1.3, Foreign port: 179
    Nexthop: 10.1.1.1
    Nexthop global: ::
    Nexthop local: ::
    BGP connection: shared network
    Read thread: on Write thread: off
    
  3. Check that BGP state is ESTABLISHED (marked in bold in the previous output).