Difference between revisions of "ExaBGP"

From HackerNet
Jump to: navigation, search
(Created page with "ExaBGP är en BGP route announcer som det går att scripta mot. =Installation= pip install exabgp =Konfiguration= nano conf.ini group TEST { router-id 172.16.2.1;...")
 
Line 5: Line 5:
  
 
=Konfiguration=
 
=Konfiguration=
  nano conf.ini
+
Exempel där man kan skicka in väldigt mycket routes till BGP.
  group TEST {
+
 
    router-id 172.16.2.1;
+
Script för att generera prefix: [http://www.blackhole-networks.com/OSPF_overload/bs-prefixes.py bs-prefixes.py]
 +
  chmod +x bs-prefixes.py
 +
 
 +
Script för att annonsera prefix
 +
touch announce.sh && chmod +x announce.sh
 +
announce.sh
 +
<syntaxhighlight lang="bash">
 +
#!/bin/sh
 +
 
 +
# ignore Control C
 +
# if the user ^C exabgp we will get that signal too, ignore it and let exabgp send us a SIGTERM
 +
TEMPFILE=/tmp/prefixes.bgp
 +
PREFIXES=50000
 +
BLOCK=128
 +
 
 +
trap '' SIGINT
 +
 
 +
# Dump our prefixs in a file for parsing a block at a time
 +
/path/to/bs-prefixes.py $PREFIXES > $TEMPFILE
 +
 
 +
# Pause a bit to let BGP sessions come up
 +
sleep 10
 +
 
 +
LINE=0
 +
while [ $LINE -lt $PREFIXES ]; do
 +
  LINE=$(( $LINE + $BLOCK ))
 +
  for pfx in `head -n $LINE $TEMPFILE | tail -n $BLOCK`; do
 +
      echo "announce route $pfx next-hop 10.0.0.0"
 +
  done
 +
  sleep 2
 +
done
 +
</syntaxhighlight>
 +
 
 +
Konfigurationsfil för exaBGP, edit ''exabgp.conf''
 +
 
 +
  neighbor 10.0.0.11 {
 +
  description "R2";
 +
  router-id 66.66.66.66;
 +
  local-address 10.0.0.10;
 +
  local-as 666;
 +
  peer-as 101;
 +
  hold-time 600;
 +
  graceful-restart;
 
   
 
   
    neighbor 172.16.2.128 {
+
  # advertise prefixes
        local-address 172.16.2.1;
+
  process service-1 {
         local-as 65000;
+
         run /path/to/announce.sh;
        peer-as 65000;
+
  }
    }
 
}
 
 
 
exabgp ./conf.ini
 
  
 +
Kör
 +
exabgp exabgp.conf
  
 
[[Category:Network]]
 
[[Category:Network]]

Revision as of 13:58, 12 March 2016

ExaBGP är en BGP route announcer som det går att scripta mot.

Installation

pip install exabgp

Konfiguration

Exempel där man kan skicka in väldigt mycket routes till BGP.

Script för att generera prefix: bs-prefixes.py

chmod +x bs-prefixes.py

Script för att annonsera prefix

touch announce.sh && chmod +x announce.sh

announce.sh

#!/bin/sh

# ignore Control C
# if the user ^C exabgp we will get that signal too, ignore it and let exabgp send us a SIGTERM
TEMPFILE=/tmp/prefixes.bgp
PREFIXES=50000
BLOCK=128

trap '' SIGINT

# Dump our prefixs in a file for parsing a block at a time
/path/to/bs-prefixes.py $PREFIXES > $TEMPFILE

# Pause a bit to let BGP sessions come up
sleep 10

LINE=0
while [ $LINE -lt $PREFIXES ]; do
   LINE=$(( $LINE + $BLOCK ))
   for pfx in `head -n $LINE $TEMPFILE | tail -n $BLOCK`; do
      echo "announce route $pfx next-hop 10.0.0.0"
   done
   sleep 2
done

Konfigurationsfil för exaBGP, edit exabgp.conf

neighbor 10.0.0.11 {
 description "R2";
 router-id 66.66.66.66;
 local-address 10.0.0.10;
 local-as 666;
 peer-as 101;
 hold-time 600;
 graceful-restart;

  # advertise prefixes
  process service-1 {
       run /path/to/announce.sh;
  }

Kör

exabgp exabgp.conf