picobgp

     ● non-compliant-bgp
     ● routing advertising
     ● tolopogy update
     ● tiny and easy to use



                          for picobgp v0.2


CC-BY: Claudio Mignanti (2012)
picobgp - Take over of your vpn

picobgp was written to automatically setup routing inside a vpn,
but can be used also in a generic net.

Suppose that you have some vpn peers, serverA and your
laptop.
Now serverA is also part of a local lan, say 10.0.8.0/24 and you
want that your laptop can reach all the serverA-lan with
minimus effort.

picobgp can help you!
192.168.6.1



              192.168.6.2



        10.0.8.9
vpn0: 192.168.6.1



           vpn0:192.168.6.2



       eth0: 10.0.8.9
vpn0: 192.168.6.1

    # pbgp -i vpn0

                                    vpn0:192.168.6.2



# pbgp -i vpn0 -s 10.0.8.0/24   eth0: 10.0.8.9
picobgp - command args

picobgp DOESN'T support             Supported args in v0.2 are:
configuration with files but only
by cmdline args.                      -1
                                          one-shot advertising
Supported args in v0.1 are:            (useful inside script)
-i <interface>                         -c
   Specify the outgoing interface         cascade
-s x.x.x.x/y                           annunce the subnet received.
   Specify the subnet               This option can lead to routing
   (option can be repeated for      loop!
each subnet)                        KEEP your network in tree
                                    forms!!!
and don't forgot to...

.. enable routing on your servers


echo 1 | sudo tee /proc/sys/net/ipv4/ip_forward
# pbgp -i eth0 -s 10.1.1.9/29


eth1: 10.1.1.1
                      # pbgp -i eth1 -s 192.168.1.0/24

                      # pbgp -i eth0 -s 10.1.1.0/29
eth0: 192.168.1.2
                      NetbookB cannot access 10.1.1.9/29



                       # pbgp -i eth0

            A more complex example
# pbgp -i eth0 -s 10.1.1.9/29


  eth1: 10.1.1.1
                        # pbgp -i eth1 -s 192.168.1.0/24

                        # pbgp -c -i eth0 -s 10.1.1.0/29
  eth0: 192.168.1.2
                      ServerB announce also ServerA subnet



                         # pbgp -i eth0

On v0.1+ the -c option allow the propagation of
                   subnets
picobgp as daemon

Daemon mode un-supported for choice.

# ./pbgp -cs 1.1.1.0/24 & >/dev/null 2>&1

is what you are looking for...


Do you like to know why this choice?
picobgp inside scripts

We want to annouce a given subnet if a host inside the
subnet reply to ping
#!/bin/bash

while 1; do
  ping -c 1 192.168.1.9 && pbgp -1s 192.168.1.0/24
  sleep 5
done


-1 option is one-shot and die mode (thanks Clauz for the idea)
Behind the scene

The bgpmsg struct is            In update_rt() function this
inizialized with the program    structure is used to inizialize
args and than spammed on        a struct rtentry and then
iface broadcast address         passed to a ioctl that
every 3 seconds.                manipolate the kernel route
                                table.
typedef struct sbgpmsg {        ioctl (sd, SIOCADDRT, &rtentry);
     struct in_addr addr;
     struct in_addr netmask;    If a subnet is not spammed
     struct in_addr loc_addr;   for more that 10 secs the
     time_t l_update;           route entry is deleted.
} bgpmsg;
what's next?!?!??!

KNOW ISSUE for v0.1:            TODO:
* msg are broadcast using         ideas?
255.255.255.255 and is not
using the effective broadcast
address of the passed
interface
* DELRT show be bogus
Use picobgp for redundant gateway

HostA has 10.0.1.9 inside it
LAN 10.0.1.0/24 and the gws
are 10.0.1.1 and 10.0.1.2

We want to setup the route

Picobgp - A simple deamon for routing advertising

  • 1.
    picobgp ● non-compliant-bgp ● routing advertising ● tolopogy update ● tiny and easy to use for picobgp v0.2 CC-BY: Claudio Mignanti (2012)
  • 2.
    picobgp - Takeover of your vpn picobgp was written to automatically setup routing inside a vpn, but can be used also in a generic net. Suppose that you have some vpn peers, serverA and your laptop. Now serverA is also part of a local lan, say 10.0.8.0/24 and you want that your laptop can reach all the serverA-lan with minimus effort. picobgp can help you!
  • 4.
    192.168.6.1 192.168.6.2 10.0.8.9
  • 5.
    vpn0: 192.168.6.1 vpn0:192.168.6.2 eth0: 10.0.8.9
  • 6.
    vpn0: 192.168.6.1 # pbgp -i vpn0 vpn0:192.168.6.2 # pbgp -i vpn0 -s 10.0.8.0/24 eth0: 10.0.8.9
  • 7.
    picobgp - commandargs picobgp DOESN'T support Supported args in v0.2 are: configuration with files but only by cmdline args. -1 one-shot advertising Supported args in v0.1 are: (useful inside script) -i <interface> -c Specify the outgoing interface cascade -s x.x.x.x/y annunce the subnet received. Specify the subnet This option can lead to routing (option can be repeated for loop! each subnet) KEEP your network in tree forms!!!
  • 8.
    and don't forgotto... .. enable routing on your servers echo 1 | sudo tee /proc/sys/net/ipv4/ip_forward
  • 9.
    # pbgp -ieth0 -s 10.1.1.9/29 eth1: 10.1.1.1 # pbgp -i eth1 -s 192.168.1.0/24 # pbgp -i eth0 -s 10.1.1.0/29 eth0: 192.168.1.2 NetbookB cannot access 10.1.1.9/29 # pbgp -i eth0 A more complex example
  • 10.
    # pbgp -ieth0 -s 10.1.1.9/29 eth1: 10.1.1.1 # pbgp -i eth1 -s 192.168.1.0/24 # pbgp -c -i eth0 -s 10.1.1.0/29 eth0: 192.168.1.2 ServerB announce also ServerA subnet # pbgp -i eth0 On v0.1+ the -c option allow the propagation of subnets
  • 11.
    picobgp as daemon Daemonmode un-supported for choice. # ./pbgp -cs 1.1.1.0/24 & >/dev/null 2>&1 is what you are looking for... Do you like to know why this choice?
  • 12.
    picobgp inside scripts Wewant to annouce a given subnet if a host inside the subnet reply to ping #!/bin/bash while 1; do ping -c 1 192.168.1.9 && pbgp -1s 192.168.1.0/24 sleep 5 done -1 option is one-shot and die mode (thanks Clauz for the idea)
  • 13.
    Behind the scene Thebgpmsg struct is In update_rt() function this inizialized with the program structure is used to inizialize args and than spammed on a struct rtentry and then iface broadcast address passed to a ioctl that every 3 seconds. manipolate the kernel route table. typedef struct sbgpmsg { ioctl (sd, SIOCADDRT, &rtentry); struct in_addr addr; struct in_addr netmask; If a subnet is not spammed struct in_addr loc_addr; for more that 10 secs the time_t l_update; route entry is deleted. } bgpmsg;
  • 14.
    what's next?!?!??! KNOW ISSUEfor v0.1: TODO: * msg are broadcast using ideas? 255.255.255.255 and is not using the effective broadcast address of the passed interface * DELRT show be bogus
  • 15.
    Use picobgp forredundant gateway HostA has 10.0.1.9 inside it LAN 10.0.1.0/24 and the gws are 10.0.1.1 and 10.0.1.2 We want to setup the route