17.2. Setting up BGP4 with Zebra

The Border Gateway Protocol Version 4 (BGP4) is a dynamic routing protocol described in RFC 1771. It allows the distribution of reachability information, i.e. routing tables, to other BGP4 enabled nodes. It can either be used as EGP or IGP, in EGP mode each node must have its own Autonomous System (AS) number. BGP4 supports Classless Inter Domain Routing (CIDR) and route aggregation (merge multiple routes into one).

17.2.1. Network Map (Example)

The following network map is used for further examples. AS 1 and 50 have more neighbors but we only need to configure 1 and 50 as our neighbor. The nodes itself communicate over tunnels in this example but that is not a must.

Note: The AS numbers used in this example are reserved, please get your own AS from RIPE if you set up official peerings.

          | |
          |    AS: 23        |
            /             \
           /               \
          /                 \
------------------       ------------------
| |-------|   |
|    AS: 1       |       |    AS: 50      |
------------------       ------------------

17.2.2. Configuration (Example)

The following configuration is written for node, it is easy to adapt it for the other nodes.

It starts with some general stuff like hostname, passwords and debug switches:

! hostname
hostname anakin

! login password
password xxx

! enable password (super user mode)
enable password xxx

! path to logfile
log file /var/log/zebra/bgpd.log

! debugging: be verbose (can be removed afterwards)
debug bgp events
debug bgp filters
debug bgp fsm
debug bgp keepalives
debug bgp updates

Access list, used to limit the redistribution to private networks (RFC 1918).

! RFC 1918 networks
access-list local_nets permit
access-list local_nets permit
access-list local_nets permit
access-list local_nets deny any

Next step is to do the per AS configuration:

! Own AS number
router bgp 23

    ! IP address of the router
    bgp router-id

    ! announce our own network to other neighbors

    ! advertise all connected routes (= directly attached interfaces)
    redistribute connected

    ! advertise kernel routes (= manually inserted routes)
    redistribute kernel

Every 'router bgp' block contains a list of neighbors to which the router is connected to:

    neighbor remote-as 1
    neighbor distribute-list local_nets in
    neighbor   remote-as 50
    neighbor   distribute-list local_nets in

17.2.3. Checking Configuration

Note: vtysh is a multiplexer and connects all the Zebra interfaces together.

anakin# sh ip bgp summary 
BGP router identifier, local AS number 23
2 BGP AS-PATH entries
0 BGP community entries

Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd       4    50      35      40        0    0    0 00:28:40        1     4     1   27574   27644        0    0    0 03:26:04       14

Total number of neighbors 2
anakin# sh ip bgp neighbors
BGP neighbor is, remote AS 50, local AS 23, external link
  BGP version 4, remote router ID
  BGP state = Established, up for 00:29:01

Let's see which routes we got from our neighbors:

anakin# sh ip ro bgp 
Codes: K - kernel route, C - connected, S - static, R - RIP, O - OSPF,
       B - BGP, > - selected route, * - FIB route

B>* [20/0] via, tun0, 2d10h19m
B>* [20/0] via, tun0, 10:09:24
B>* [20/0] via, tun0, 2d10h27m
B>* [20/0] via, tun0, 10:09:24
B>* [20/0] via, tun0, 2d10h19m
B>* [20/0] via, tun0, 3d05h07m
B>* [20/0] via, tun0, 3d05h07m
B>* [20/0] via, tun0, 2d10h27m