log "/home/ubuntu/bird-rs" all;

router id 192.168.5.3;

define myas = 65012;

protocol device { }

#####
# Protocol template

template bgp PEERS {
        local as myas;
        import all;
        export all;
        rs client;
}

####
# Actual Peers

### Exa1
protocol bgp Exa1 from PEERS {
        description "Exa1";
        neighbor 192.168.3.4 as 65010;
        import all;
}

protocol bgp Exa2 from PEERS {
        description "Exa2";
        neighbor 192.168.4.4 as 65010;
        import all;
}

####
# Export to exa not part of template

protocol bgp ExaOut {
        description "main exa";
        debug all;
        neighbor 192.168.5.4 as 65011;
        local as myas;
        source address 192.168.5.3;
        import all;
        export all;
        add paths;
        capabilities;
}


====================


cat exa1.conf
neighbor 192.168.3.3 {
  description "Exa1-bird";
  router-id 192.168.3.4;
  local-address 192.168.3.4;
  local-as 65010;
  peer-as 65012;
  hold-time 180;
  group-updates;

  family {
        ipv4 unicast;
  }

  capability path {
        add-path send/receive;
  }

        process multi {
                run /home/ubuntu/exa1.run;
                receive-routes;
                neighbor-changes;
        }

}


===========

cat exa1.run
#!/usr/bin/env python

import sys
import time

messages = [
#'announce route 192.168.100.0/24 next-hop 172.26.60.200 path-information 1.2.3.4',
#'announce route 192.168.100.0/24 next-hop 172.26.60.201 path-information 5.6.7.8',
'announce route 192.168.200.0/24 next-hop 192.168.3.4',
]

time.sleep(2)

while messages:
        message = messages.pop(0)
        sys.stdout.write( message + '\n')
        sys.stdout.flush()
        time.sleep(1)

while True:
        time.sleep(1)


============

cat exa2.conf
neighbor 192.168.4.3 {
  description "Advert to bird route-server";
  router-id 192.168.4.4;
  local-address 192.168.4.4;
  local-as 65010;
  peer-as 65012;
  hold-time 180;
  group-updates;

  family {
        ipv4 unicast;
  }

  capability path {
        add-path send/receive;
  }

        process multi {
                run /home/ubuntu/exa2.run;
                receive-routes;
                neighbor-changes;
        }

}


=============

cat exa2.run
#!/usr/bin/env python

import sys
import time

messages = [
#'announce route 192.168.100.0/24 next-hop 172.26.60.200 path-information 1.2.3.4',
#'announce route 192.168.100.0/24 next-hop 172.26.60.201 path-information 5.6.7.8',
'announce route 192.168.200.0/24 next-hop 192.168.4.4',
]

time.sleep(2)

while messages:
        message = messages.pop(0)
        sys.stdout.write( message + '\n')
        sys.stdout.flush()
        time.sleep(1)

while True:
        time.sleep(1)


==============

