GNS3 with ExaBGP Part 1

ExaBGP is a programatic tool that can be used to talk to other systems using BGP. There are quite a few cool applications available such as programattic blackhole route insertion, failover and other things, however my goal is to use ExaBGP to simulate a full internet routing table being offered to a router running in GNS3

There is a great introduction on how to initially setup ExaBGP on the PacketGeek which I am going to use as the basis for my SROS configuration.

ExaBGP will be running on my GNS3 host itself (Ubuntu 16.04.1 LTS) and we will connect to SR4 via tap1.

Simple GNS3 and ExaBGP Topology
Simple GNS3 and ExaBGP Topology

The Tap1 interface will be created as below (in a previous post I was using the tunctl commands to create a tunnel, however this is deprecated and ip based commands should be used.)

adam@gns3:~$ sudo ip tuntap add tap1 mode tap user gns3
adam@gns3:~$ sudo ip addr add 1.2.3.3/24 dev tap1
adam@gns3:~$ sudo ip link set tap1 up
adam@gns3:~$ ip addr show dev tap1
21: tap1:  mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 22:84:63:de:96:52 brd ff:ff:ff:ff:ff:ff
    inet 1.2.3.3/24 scope global tap1
       valid_lft forever preferred_lft forever
    inet6 fe80::2084:63ff:fede:9652/64 scope link
       valid_lft forever preferred_lft forever

SR4 is an SROS based router with a basic BGP config:

A:SR4# configure router
A:SR4>config>router# info
----------------------------------------------
#--------------------------------------------------
echo "IP Configuration"
#--------------------------------------------------
        interface "ExaBGP"
            address 1.2.3.4/24
            port 1/1/5
            no shutdown
        exit
        interface "system"
            address 10.10.10.4/32
            no shutdown
        exit
        autonomous-system 1234
#--------------------------------------------------
echo "BGP Configuration"
#--------------------------------------------------
        bgp
            group "ExaBGP"
                neighbor 1.2.3.3
                    peer-as 64512
                exit
            exit
            no shutdown
        exit
----------------------------------------------

Verify IP Connectivity:

A:SR4>config>router# ping 1.2.3.3 count 3
PING 1.2.3.3 56 data bytes
64 bytes from 1.2.3.3: icmp_seq=1 ttl=64 time=1.54ms.
64 bytes from 1.2.3.3: icmp_seq=2 ttl=64 time=1.62ms.
64 bytes from 1.2.3.3: icmp_seq=3 ttl=64 time=1.70ms.

---- 1.2.3.3 PING Statistics ----
3 packets transmitted, 3 packets received, 0.00% packet loss
round-trip min = 1.54ms, avg = 1.62ms, max = 1.70ms, stddev = 0.065ms

Assuming that we followed the ExaBGP installation procedure described in the Packet Geek’s page – we shall set up a very simple exabgp config

group test {
    router-id 1.2.3.3;
    neighbor 1.2.3.4 {
        local-address 1.2.3.3;
        local-as 64512;
        peer-as 1234;
    }
    process add-routes {
        run /usr/bin/python /home/adam/example.py;
    }
}

The configuration should be relatively self explanitory, where process add-routes comes to play is where a python script gets called to generate BGP messages.

#!/usr/bin/env python

from sys import stdout
from time import sleep

messages = [
'announce route 100.10.0.0/24 next-hop self',
'announce route 200.20.0.0/24 next-hop self'
]

sleep(5)

#Iterate through messages
for message in messages:
    stdout.write( message + '\n')
    stdout.flush()
    sleep(1)

#Loop endlessly to allow ExaBGP to continue running
while True:
    sleep(1)

Before we start, lets confirm the route-table on SR4

A:SR4# show router route-table

===============================================================================
Route Table (Router: Base)
===============================================================================
Dest Prefix[Flags]                            Type    Proto     Age        Pref
      Next Hop[Interface Name]                                    Metric
-------------------------------------------------------------------------------
1.2.3.0/24                                    Local   Local     00h15m36s  0
       ExaBGP                                                       0
10.10.10.4/32                                 Local   Local     00h19m44s  0
       system                                                       0
-------------------------------------------------------------------------------
No. of Routes: 2
Flags: n = Number of times nexthop is repeated
       B = BGP backup route available
       L = LFA nexthop available
       S = Sticky ECMP requested
===============================================================================

Nothing particularly surprising here. Let’s start exabgp.

A lot of logging information gets pushed out to the console but the last lines are the most interesting.

adam@gns3:~$ exabgp conf.ini
....
Mon, 07 Nov 2016 23:37:25 | INFO     | 18062  | processes     | Forked process add-routes
Mon, 07 Nov 2016 23:37:28 | INFO     | 18062  | network       | Connected to peer neighbor 1.2.3.4 local-ip 1.2.3.3 local-as 64512 peer-as 1234 router-id 1.2.3.3 family-allowed in-open (out)
Mon, 07 Nov 2016 23:37:30 | INFO     | 18062  | processes     | Command from process add-routes : announce route 100.10.0.0/24 next-hop self
Mon, 07 Nov 2016 23:37:30 | INFO     | 18062  | reactor       | Route added to neighbor 1.2.3.4 local-ip 1.2.3.3 local-as 64512 peer-as 1234 router-id 1.2.3.3 family-allowed in-open : 100.10.0.0/24 next-hop 1.2.3.3
Mon, 07 Nov 2016 23:37:31 | INFO     | 18062  | reactor       | Performing dynamic route update
Mon, 07 Nov 2016 23:37:31 | INFO     | 18062  | reactor       | Updated peers dynamic routes successfully
Mon, 07 Nov 2016 23:37:31 | INFO     | 18062  | processes     | Command from process add-routes : announce route 200.20.0.0/24 next-hop self
Mon, 07 Nov 2016 23:37:31 | INFO     | 18062  | reactor       | Route added to neighbor 1.2.3.4 local-ip 1.2.3.3 local-as 64512 peer-as 1234 router-id 1.2.3.3 family-allowed in-open : 200.20.0.0/24 next-hop 1.2.3.3
Mon, 07 Nov 2016 23:37:32 | INFO     | 18062  | reactor       | Performing dynamic route update
Mon, 07 Nov 2016 23:37:32 | INFO     | 18062  | reactor       | Updated peers dynamic routes successfully

Now lets check the route-table on SR4

A:SR4# show router route-table

===============================================================================
Route Table (Router: Base)
===============================================================================
Dest Prefix[Flags]                            Type    Proto     Age        Pref
      Next Hop[Interface Name]                                    Metric
-------------------------------------------------------------------------------
1.2.3.0/24                                    Local   Local     00h19m13s  0
       ExaBGP                                                       0
10.10.10.4/32                                 Local   Local     00h23m20s  0
       system                                                       0
100.10.0.0/24                                 Remote  BGP       00h02m36s  170
       1.2.3.3                                                      0
200.20.0.0/24                                 Remote  BGP       00h02m35s  170
       1.2.3.3                                                      0
-------------------------------------------------------------------------------
No. of Routes: 4
Flags: n = Number of times nexthop is repeated
       B = BGP backup route available
       L = LFA nexthop available
       S = Sticky ECMP requested
===============================================================================

So there we go, routing information has been pushed into SR4 via a script called by ExaBGP. Part Two will look at taking a data feed such as RIPE NCCs Routing Information Service and transforming it into something that ExaBGP can offer to a router.

Published by

Adam

Adam enjoys playing with and learning about networks and is based in Queensland, Australia.