Bgp » Historial » Versió 1
Agustí Moll Garcia, 16-04-2011 09:10
| 1 | 1 | Agustí Moll Garcia | h1. Bgp |
|---|---|---|---|
| 2 | |||
| 3 | #Apunts sobre BGP |
||
| 4 | ##Escenari |
||
| 5 | Disposo del següent escenari: |
||
| 6 | |||
| 7 | - Node MANET amb GSF (routerstation2): 10.229.193.6 |
||
| 8 | |||
| 9 | - Node MANET amb GSF (routerstation1): 10.228.193.4 / 10.0.1.4 |
||
| 10 | |||
| 11 | - Virtual amb openWRT (prova1): 10.0.1.2 / 10.0.0.2 |
||
| 12 | |||
| 13 | - Virtual amb openWRT (prova2): 10.0.0.3 |
||
| 14 | |||
| 15 | La conexió física és la següent: |
||
| 16 | |||
| 17 | RS2 ----- RS1 ----- prova1 ----- prova2 |
||
| 18 | |||
| 19 | Tant prova1 com prova2, representen supernodes de guifi en infraestrucutra. RS1 representa un node MANET frontera entre el núbol i guifi. |
||
| 20 | |||
| 21 | **L'objectiu és que prova2 vegi RS2 mitjançant una instància BGP publicada per RS1 a través de prova1** |
||
| 22 | |||
| 23 | RS2 i RS1 ja és veuen mitjançant BMX |
||
| 24 | |||
| 25 | |||
| 26 | ##Configuració BGP |
||
| 27 | 1. Primer instal·lem quagga en RS1 + prova1 + prova2 |
||
| 28 | {{{ opkg install quagga quagga-bgpd quagga-vtysh }}} |
||
| 29 | |||
| 30 | 2. Configurem /etc/quagga/zebra.conf |
||
| 31 | {{{ interface eth0 |
||
| 32 | ! |
||
| 33 | access-list vty permit 127.0.0.0/8 |
||
| 34 | ! |
||
| 35 | access-list vty deny any |
||
| 36 | ! |
||
| 37 | ip forwarding |
||
| 38 | ! |
||
| 39 | line vty |
||
| 40 | access-class vty |
||
| 41 | ! |
||
| 42 | }}} |
||
| 43 | Afegim totes les interfaces de cada màquina.... |
||
| 44 | |||
| 45 | 3. Configurem /etc/quagga/bgpd.conf |
||
| 46 | |||
| 47 | 3.1 RS1 |
||
| 48 | {{{hostname rs1 |
||
| 49 | router bgp 400 |
||
| 50 | bgp router-id 10.0.1.4 |
||
| 51 | network 10.228.193.6/32 |
||
| 52 | neighbor 10.0.1.2 remote-as 200 |
||
| 53 | }}} |
||
| 54 | |||
| 55 | 3.2 prova2 |
||
| 56 | {{{hostname prova2 |
||
| 57 | router bgp 300 |
||
| 58 | bgp router-id 10.0.0.3 |
||
| 59 | neighbor 10.0.0.2 remote-as 200 |
||
| 60 | }}} |
||
| 61 | |||
| 62 | 3.3 prova1 |
||
| 63 | {{{hostname prova1 |
||
| 64 | router bgp 200 |
||
| 65 | |||
| 66 | bgp router-id 10.0.0.2 |
||
| 67 | |||
| 68 | network 10.0.0.0/24 |
||
| 69 | network 10.0.1.0/24 |
||
| 70 | |||
| 71 | neighbor 10.0.0.3 remote-as 300 |
||
| 72 | neighbor 10.0.1.4 remote-as 400 |
||
| 73 | }}} |
||
| 74 | |||
| 75 | - `router bgp` -> El nom del AS |
||
| 76 | |||
| 77 | - `network` -> La xarxa a publicar |
||
| 78 | |||
| 79 | - `neighbor` -> Els veins amb qui ens comuniquem |
||
| 80 | |||
| 81 | |||
| 82 | {{{/etc/init.d/quagga start}}} |
||
| 83 | |||
| 84 | |||
| 85 | ##Proves |
||
| 86 | |||
| 87 | Des de prova2: |
||
| 88 | {{{ip route show |
||
| 89 | 10.228.193.6 via 10.0.0.2 dev eth1 proto zebra |
||
| 90 | 10.0.0.0/24 dev eth1 proto kernel scope link src 10.0.0.3 |
||
| 91 | 10.0.1.0/24 via 10.0.0.2 dev eth1 proto zebra |
||
| 92 | 192.168.10.0/24 dev br-lan proto kernel scope link src 192.168.10.3 |
||
| 93 | 10.3.3.0/24 dev eth1 proto kernel scope link src 10.3.3.1 |
||
| 94 | 172.20.0.0/14 via 10.0.0.2 dev eth1 proto zebra |
||
| 95 | 1.0.0.0/8 dev eth0 proto kernel scope link src 1.1.1.1 |
||
| 96 | default via 192.168.10.1 dev br-lan |
||
| 97 | }}} |
||
| 98 | |||
| 99 | Com es pot veure, des de prova dos veiem 10.228.193.6, que és la IP de RS2, per tant el recorregut dels paquets seria: |
||
| 100 | {{{prova2 ---bgp---> prova1 ---bgp---> RS1 ---bmx---> RS2 }}} |
||
| 101 | |||
| 102 | ##Implamtació a GSF |
||
| 103 | |||
| 104 | Bé, ja hem conseguit que el node MANET frontera sigui capaç de publicar una IP del seu núvol. |
||
| 105 | |||
| 106 | Però ens queda resoldre la pregunta: Cóm fem això dinàmic? |
||
| 107 | |||
| 108 | Amb l'aplicació vtysh podem fer el següent per afegir dinàmicament una nova ruta (10.228.193.7/32), i eliminar l'anterior (10.228.193.6/32) |
||
| 109 | |||
| 110 | {{{vtysh |
||
| 111 | configure terminal |
||
| 112 | router bgp 400 |
||
| 113 | network 10.228.193.7/32 |
||
| 114 | no network 10.228.193.6/32 |
||
| 115 | end |
||
| 116 | write memory |
||
| 117 | exit |
||
| 118 | }}} |
||
| 119 | |||
| 120 | Seria el mateix que executar aquesta comanda bash: |
||
| 121 | {{{printf `configure terminal\nrouter bgp 400\nnetwork 10.228.193.7/32\nno network 10.228.193.6/32\nend\nwrite memory\ne |
||
| 122 | xit\n` | vtysh |
||
| 123 | }}} |
||
| 124 | |||
| 125 | Mola bastant eh!! |
||
| 126 | |||
| 127 | Per tant és podria fer un script executat cada X temps (diguem 10 minuts?). Que recullís les IPs vistes mitjançant BMX, i ho publiques al BGP, d'aquesta manera des de GUIFI ens podran veure i enrutar directament cap a nosaltres. I el més important, podrem disposar de varis nodes frontera :-D |
||
| 128 | |||
| 129 | ##Referències |
||
| 130 | |||
| 131 | - http://www.quagga.net/docs/quagga.html |
||
| 132 | - http://martybugs.net/wireless/openwrt/quagga.cgi |
||
| 133 | - http://www.mcmcse.com/cisco/guides/bgp_neighbor_process.shtml |