Configurare BGP su Vultr con OpenBSD

Cloud Compute

La funzione BGP di Vultr ti consente di portare il tuo spazio IP personale e utilizzarlo in una qualsiasi delle nostre sedi, con un'istanza OpenBSD non è necessario alcun software aggiuntivo!

Iniziare

Per utilizzare BGP, è necessario il proprio spazio IP (v4 o v6). Se hai il tuo ASN, puoi usarlo o possiamo assegnarne uno privato.

Apri un ticket con le seguenti informazioni:

  • I tuoi intervalli IP
  • Il tuo ASN (se ne hai uno)
  • Un LOA per i tuoi intervalli IP (solo se non hai il tuo ASN)

Dopo aver configurato BGP sul tuo account, puoi procedere con la configurazione di BGP.

I nostri esempi utilizzeranno quanto segue:

  • ASN: 64512
  • Indirizzo IPv4 dell'istanza: 203.0.113.123
  • Indirizzo IPv6 dell'istanza: 2001: DB8: 1000 :: 1/64
  • Blocco IPv4: 198.51.100.0/24
  • Blocco IPv6: 2001: 0db8 :: / 32
  • Password BGP: hunter2

Impostazione BGP

OpenBSD viene fornito con bgpd(8)già installato e richiede solo alcune modifiche al file di configurazione per l'avvio.

Modifica rc.conf.local(8)per aggiungere la seguente riga per consentire l' bgpd(8)avvio del daemonrc.d(8)

bgpd_flags=

Un esempio completo di bgpd.conf(8)può essere trovato su /etc/examples/bgpd.confe contiene molte opzioni di configurazione extra che potresti aver bisogno.

Regola la configurazione di esempio seguente come richiesto e scrivi su /etc/bgpd.conf (assicurati che le autorizzazioni per questo file siano 600)

   AS 64512
    router-id 203.0.113.123

    listen on 127.0.0.1
    listen on ::1
    log updates
    network 198.51.100.0/24
    network 2001:0db8::/32

    neighbor 169.254.169.254 {
            remote-as               64515
            descr                   "Vultr IPv4"
            announce IPv4           unicast
            announce IPv6           none
            tcp md5sig password     hunter2
            multihop                2
            local-address           203.0.113.123
    }
    neighbor 2001:19f0:ffff::1 {
            remote-as               64515
            descr                   "Vultr IPv6"
            announce IPv4           none
            announce IPv6           unicast
            tcp md5sig password     hunter2
            multihop                2
            local-address           2001:DB8:1000::1
    }

Per assicurarsi che tutto sia in ordine, è possibile emettere il comando bgpd -f /etc/bgpd.conf -n. Se bgpd(ok)viene restituito, è possibile avviare il demone.

# rcctl enable bgpd
# rcctl start bgpd
bgpd(ok)

Per verificare lo stato delle sessioni BGP, dovrai utilizzare bgpctl(8). Ad esempio, per visualizzare una panoramica di base è possibile utilizzarebgpctl show summary

# bgpctl show summary
Neighbor                   AS    MsgRcvd    MsgSent  OutQ Up/Down  State/PrfRcvd
Vultr IPv6              64515        230        207     0 01:41:40      0
Vultr IPv4              64515        244        220     0 01:48:09      0

Per visualizzare informazioni dettagliate sull'uso di un vicino BPG bgpctl show neighbor

BGP neighbor is 2001:19f0:ffff::1, remote AS 64515, Multihop (2)
 Description: Vultr IPv6
  BGP version 4, remote router-id 45.63.102.186, using md5sig
  BGP state = Established, up for 01:46:45
  Last read 00:00:08, holdtime 90s, keepalive interval 30s
  Neighbor capabilities:
    Multiprotocol extensions: IPv6 unicast
    Route Refresh
    Graceful Restart: Timeout: 120, IPv6 unicast
    4-byte AS numbers

  Message statistics:
          Sent       Received  
  Opens                    1          1
  Notifications            0          0
  Updates                  2          1
  Keepalives             214        240
  Route Refresh            0          0
  Total                  217        242

  Update statistics:
          Sent       Received  
  Updates                  4          0
  Withdraws                0          0
  End-of-Rib               1          1

  Local host:  2001:DB8:1000::1, Local port:  38298
  Remote host:    2001:19f0:ffff::1, Remote port:   179

BGP neighbor is 169.254.169.254, remote AS 64515, Multihop (2)
 Description: Vultr IPv4
  BGP version 4, remote router-id 45.63.102.186, using md5sig
  BGP state = Established, up for 01:53:14
  Last read 00:00:14, holdtime 90s, keepalive interval 30s
  Neighbor capabilities:
    Multiprotocol extensions: IPv4 unicast
    Route Refresh
    Graceful Restart: Timeout: 120, IPv4 unicast
    4-byte AS numbers

  Message statistics:
          Sent       Received  
  Opens                    1          1
  Notifications            0          0
  Updates                  2          1
  Keepalives             227        253
  Route Refresh            0          0
  Total                  230        255

  Update statistics:
          Sent       Received  
  Updates                  4          0
  Withdraws                0          0
  End-of-Rib               1          1

  Local host:         203.0.113.123, Local port:  19824
  Remote host:      169.254.169.254, Remote port:   179

A questo punto possiamo iniziare ad assegnare i nostri indirizzi IP alle interfacce (ad es. Configurando /etc/hostname.lo1) in modo che le applicazioni possano essere configurate per l'ascolto su questi IP.

Se si intende utilizzare i propri indirizzi IP su più istanze, sarà necessario modificare le networkistruzioni su ciascuna istanza per annunciare un percorso più specifico per tali IP.

Istanza A

   AS 64512
    router-id 203.0.113.123

    listen on 127.0.0.1
    listen on ::1
    log updates
    network 198.51.100.0/24
    network 198.51.100.1/32
    network 2001:0db8::/32
    network 2001:0db8::/64

    neighbor 169.254.169.254 {
            remote-as               64515
            descr                   "Vultr IPv4"
            announce IPv4           unicast
            announce IPv6           none
            tcp md5sig password     hunter2
            multihop                2
            local-address           203.0.113.123
    }
    neighbor 2001:19f0:ffff::1 {
            remote-as               64515
            descr                   "Vultr IPv6"
            announce IPv4           none
            announce IPv6           unicast
            tcp md5sig password     hunter2
            multihop                2
            local-address           2001:DB8:1000::1
    }

Istanza B

   AS 64512
    router-id 203.0.113.124

    listen on 127.0.0.1
    listen on ::1
    log updates
    network 198.51.100.0/24
    network 198.51.100.2/32
    network 2001:0db8::/32
    network 2001:0db8:0001::/64

    neighbor 169.254.169.254 {
            remote-as               64515
            descr                   "Vultr IPv4"
            announce IPv4           unicast
            announce IPv6           none
            tcp md5sig password     hunter2
            multihop                2
            local-address           203.0.113.124
    }
    neighbor 2001:19f0:ffff::1 {
            remote-as               64515
            descr                   "Vultr IPv6"
            announce IPv4           none
            announce IPv6           unicast
            tcp md5sig password     hunter2
            multihop                2
            local-address           2001:DB8:1000::2
    }

Nota: non dimenticare di utilizzare una password diversa da quella a cui si fa riferimento in questo articolo.

Lascia un commento