Introduzione
In questo documento viene descritto come configurare e verificare la funzione di annuncio condizionale del protocollo BGP (Border Gateway Protocol).
Prerequisiti
Requisiti
Cisco raccomanda la conoscenza di questo argomento:
Componenti usati
Il documento può essere consultato per tutte le versioni software o hardware.
Le informazioni discusse in questo documento fanno riferimento a dispositivi usati in uno specifico ambiente di emulazione. Su tutti i dispositivi menzionati nel documento la configurazione è stata ripristinata ai valori predefiniti. Se la rete è operativa, valutare attentamente eventuali conseguenze derivanti dall'uso dei comandi.
Premesse
La funzionalità di annuncio condizionale Border Gateway Protocol (BGP) offre un controllo aggiuntivo dell'annuncio delle route, a seconda dell'esistenza di altri prefissi nella tabella BGP.
La funzione di pubblicità condizionale BGP descritta in questo documento è stata introdotta nel software Cisco IOS® versione 11.1 e 11.2 ed è disponibile nelle versioni più recenti.
In genere, le route vengono propagate indipendentemente dall'esistenza di un percorso diverso. La funzionalità di annuncio condizionale BGP utilizza le parole chiave inexist-map e advertising-map del comando neighbor annuncio-map per tenere traccia delle route in base al prefisso della route. Se il prefisso route non è presente nell'output del comando non-exist-map, la route specificata dal comando annuncio-map viene annunciata. Questa funzionalità è utile per le reti multihomed, in cui alcuni prefissi vengono annunciati a uno dei provider solo se non sono presenti informazioni dell'altro provider (ciò indica un errore nella sessione di peering o una raggiungibilità parziale).
Gli annunci BGP condizionali vengono inviati in aggiunta agli annunci normali inviati da un router BGP ai relativi peer.
Convenzioni
Per ulteriori informazioni sulle convenzioni usate, consultare il documento Cisco sulle convenzioni nei suggerimenti tecnici.
Configurazione
In questa sezione vengono presentate le informazioni necessarie per configurare le funzionalità descritte più avanti nel documento.
Nota: Per ulteriori informazioni sui comandi menzionati in questo documento, usare lo strumento di ricerca dei comandi di Cisco IOS. Solo gli utenti Cisco registrati possono accedere agli strumenti e alle informazioni interne di Cisco.
Esempio di rete
Per la stesura di questo documento è stata utilizzata la configurazione di rete illustrata in questo diagramma.
In questo caso, l'interfaccia di loopback di R103 viene utilizzata per annunciare i numeri da 192.168.50.0/24 a R102. R102 dispone di una rete BGP, 172.16.16.0/24, annunciata per impostazione predefinita ai peer BGP (eBGP) esterni, R101 e R103.
Configurazione della rete
Con la funzione di annuncio condizionale BGP è ora possibile eseguire le seguenti attività su R102:
-
Se 192.168.50.0/24 è presente nella tabella BGP di R102, non pubblicizzare la rete 172.16.16.0/24 su R101.
-
Se 192.168.50.0/24 non esiste nella tabella BGP di R102, pubblicizzare la rete 172.16.16.0/24 su R101.
Con Cisco IOS versione 12.2T o successive, la parola chiave exist-map può essere utilizzata anche per eseguire queste attività:
-
Se nella tabella R102 BGP è presente 192.168.50.0/24, pubblicizzare la rete 172.16.16.0/24 su R101.
-
Se 192.168.50.0/24 non esiste nella tabella R102 BGP, non pubblicizzare la rete 172.16.16.0/24 su R101.
Configurare la funzionalità Annuncio pubblicitario condizionale
In questo documento vengono usate le seguenti configurazioni:
Nota: Nell'esempio viene illustrata la parola chiave non-exist-map. L'utilizzo della parola chiave exist-map è simile a questo.
R102 |
hostname R102
!
interface Loopback0
ip address 172.16.16.1 255.255.255.0
!
interface Serial8/0
ip address 10.10.10.2 255.255.255.0
!
interface Serial9/0
ip address 10.10.20.2 255.255.255.0
!
router bgp 2
bgp log-neighbor-changes
network 172.16.16.0 mask 255.255.255.0
network 172.31.130.0
neighbor 10.10.10.1 remote-as 1
neighbor 10.10.10.1 advertise-map ADVERTISE non-exist-map NON-EXIST
!--- Advertises the routes matched in the route-map ADVERTISE (172.16.16.0/24) !--- only if the routes matched in route-map NON-EXIST (192.168.50.0/24) !--- do not exist in the BGP table.
neighbor 10.10.20.3 remote-as 3
!
ip route 172.31.130.0 255.255.0.0 Null0
!
access-list 60 permit 172.16.16.0 0.0.0.255
access-list 65 permit 192.168.50.0 0.0.0.255
!
route-map NON-EXIST permit 10
match ip address 65
!
route-map ADVERTISE permit 10
match ip address 60
! |
R103 |
hostname R103
!
interface Loopback0
ip address 192.168.50.1 255.255.255.0
!
interface Serial9/0
ip address 10.10.20.3 255.255.255.0
!
router bgp 3
bgp log-neighbor-changes
network 192.168.50.0
neighbor 10.10.20.2 remote-as 2
! |
R101 |
hostname R101
!
interface Loopback0
ip address 10.200.200.1 255.255.255.0
!
interface Serial8/0
ip address 10.10.10.1 255.255.255.0
!
router bgp 1
bgp log-neighbor-changes
network 10.200.200.0
neighbor 10.10.10.2 remote-as 2
! |
Verifica della configurazione
Esempio 1
In questo esempio viene verificato l'aspetto di BGP quando il valore 192.168.50.0/24 è incluso nella tabella R102 BGP:
Verifica della configurazione
Verificare innanzitutto se 192.168.50.0/24 è presente nella tabella R102 BGP:
R102#show ip bgp
BGP table version is 6, local router ID is 172.16.16.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*> 172.16.16.0/24 0.0.0.0 0 32768 i
*> 172.31.130.0 0.0.0.0 0 32768 i
*> 192.168.50.0 10.10.20.3 0 0 3 i
*> 10.200.200.0 10.10.10.1 0 0 1 i
Poiché 192.168.50.0/24 è nella tabella R102 BGP, R102 non deve pubblicizzare 172.16.16.0/24 a R101.
R102#show ip bgp neighbors 10.10.10.1 advertised-routes
BGP table version is 6, local router ID is 172.16.16.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*> 172.31.130.0 0.0.0.0 0 32768 i
*> 192.168.50.0 10.10.20.3 0 0 3 i
!--- Note 172.16.16.0/24 is not advertised to neighbor 10.10.10.1.
R102#show ip bgp 172.16.16.0
BGP routing table entry for 172.16.16.0/24, version 6
Paths: (1 available, best #1, table Default-IP-Routing-Table)
Advertised to non peer-group peers:
!--- This is not advertised to R101.
10.10.20.3
Local
0.0.0.0 from 0.0.0.0 (172.16.16.1)
Origin IGP, metric 0, localpref 100, weight 32768, valid, sourced, local, best
Verificare quindi lo stato dell'annuncio condizionale in R102:
R102#show ip bgp neighbors 10.10.10.1
BGP neighbor is 10.10.10.1, remote AS 1, external link
BGP version 4, remote router ID 10.200.200.1
BGP state = Established, up for 02:27:07
Last read 00:00:07, hold time is 180, keepalive interval is 60 seconds
!--- Output suppressed.
For address family: IPv4 Unicast
BGP table version 6, neighbor version 6
Index 1, Offset 0, Mask 0x2
Condition-map NON-EXIST, Advertise-map ADVERTISE, status: Withdraw
1 accepted prefixes consume 36 bytes
Prefix advertised 3, suppressed 0, withdrawn 1
Number of NLRIs in the update sent: max 1, min 0
!--- Output suppressed.
L'output mostra che la pubblicità condizionale viene ritirata e che le reti che corrispondono alla route-map ADVERTISE non vengono annunciate al peer 10.10.10.1.
Per confermare che le route che corrispondono alla route-map ADVERTISE non sono annunciate a R101, controllare la tabella BGP su R101:
R101#show ip bgp 172.16.16.0
% Network not in table
Esempio 2
Nell'esempio viene mostrato l'aspetto di BGP quando la rete 192.168.50.0/24 non esiste nella tabella R102 BGP:
192.168.50.0/24 non esiste nella tabella R102 BGP
Le fasi sono:
1. Arrestare l'interfaccia di loopback 0 su R103 in modo che R103 non annunci più da 192.168.50.0/24 a R102.
R103(config)#interface loopback 0
R103(config-if)#shutdown
R103(config-if)#
03:29:36: %LINK-5-CHANGED: Interface Loopback0, changed state to administratively down
2. Verificare che R102 non conosca 192.168.50.0/24 e che la rete non sia inclusa nella tabella R102 BGP.
R102#show ip bgp
BGP table version is 8, local router ID is 172.16.16.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*> 172.16.16.0/24 0.0.0.0 0 32768 i
*> 172.31.130.0 0.0.0.0 0 32768 i
*> 10.200.200.0 10.10.10.1 0 0 1 i
!--- Note 192.168.50.0/24 is not present.
3. Osserva quanto tempo impiega l'annuncio condizionale per iniziare:
R102#debug ip bgp updates
*Mar 1 02:39:18.059: BGP(0): 10.10.20.3 rcv UPDATE about 192.168.50.0/24
-- withdrawn
*Mar 1 02:39:18.059: BGP(0): no valid path for 192.168.50.0/24
*Mar 1 02:39:18.079: BGP(0): nettable_walker 192.168.50.0/24 no best path
*Mar 1 02:39:18.219: BGP(0): 10.10.10.1 computing updates, afi 0, neighbor
version 10, table version 11, starting at 0.0.0.0
*Mar 1 02:39:18.219: BGP(0): 10.10.10.1 send unreachable 192.168.50.0/24
*Mar 1 02:39:18.219: BGP(0): 10.10.10.1 send UPDATE 192.168.50.0/24
-- unreachable
*Mar 1 02:39:18.219: BGP(0): 10.10.10.1 1 updates enqueued (average=27, maximum=27)
*Mar 1 02:39:18.219: BGP(0): 10.10.10.1 update run completed, afi 0, ran for 0ms,
neighbor version 10, start version 11, throttled to 11
*Mar 1 02:40:04.747: BPG(0): Condition NON-EXIST changes to Advertise
*Mar 1 02:40:04.747: BGP(0): net 172.16.16.0/24 matches ADV MAP ADVERTISE:
bump version to 12
*Mar 1 02:40:05.187: BGP(0): nettable_walker 172.16.16.0/24 route sourced
locally
*Mar 1 02:40:05.187: BGP(0): 10.10.10.1 computing updates, afi 0, neighbor
version 11, table version 12, starting at 0.0.0.0
*Mar 1 02:40:05.187: BGP(0): 10.10.10.1 172.16.16.0/24 matches advertise map
ADVERTISE, state: Advertise
*Mar 1 02:40:05.187: BGP(0): 10.10.10.1 send UPDATE (format) 172.16.16.0/24,
next 10.10.10.2, metric 0, path
*Mar 1 02:40:05.187: BGP(0): 10.10.10.1 1 updates enqueued (average=52, maximum=52)
*Mar 1 02:40:05.187: BGP(0): 10.10.10.1 update run completed, afi 0, ran for 0ms,
neighbor version 11, start version 12, throttled to 12
Nota: L'output di debug può variare in base alla versione del software utilizzata.
Il processo di annuncio condizionale viene attivato dal processo dello scanner BGP, che viene eseguito ogni 60 secondi. Ciò significa che il tempo massimo per l'attivazione della pubblicità condizionale è di 60 secondi. L'annuncio condizionale può avere effetto prima, a seconda di quando la route rilevata viene rimossa dalla tabella BGP e quando si verifica l'istanza successiva dello scanner BGP.
Eseguire questi comandi su R102 per verificare lo stato dell'annuncio condizionale su R102 per il router adiacente 10.10.10.1:
R102#show ip bgp neighbors 10.10.10.1
BGP neighbor is 10.10.10.1, remote AS 1, external link
BGP version 4, remote router ID 10.200.200.1
BGP state = Established, up for 02:45:27
Last read 00:00:27, hold time is 180, keepalive interval is 60 seconds
!--- Output suppressed.
For address family: IPv4 Unicast
BGP table version 12, neighbor version 12
Index 1, Offset 0, Mask 0x2
Condition-map NON-EXIST, Advertise-map ADVERTISE, status: Advertise
1 accepted prefixes consume 36 bytes
Prefix advertised 6, suppressed 0, withdrawn 4
Number of NLRIs in the update sent: max 1, min 0
!--- Output suppressed.
La tabella e la tabella di routing R101 BGP hanno il valore 172.16.16.0/24, come mostrato di seguito:
Nota: In questo output di esempio, vengono inviati gli annunci BGP condizionali (rete 172.16.16.0/24), oltre agli annunci BGP normali (rete 172.31.130.0/16) che un router BGP invia ai relativi peer.
R101#show ip bgp
BGP table version is 18, local router ID is 10.200.200.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*> 172.16.16.0/24 10.10.10.2 0 0 2 i
*> 172.31.130.0 10.10.10.2 0 0 2 i
*> 10.200.200.0 0.0.0.0 0 32768 i
R101#show ip route bgp
172.16.0.0/24 is subnetted, 1 subnets
B 172.16.16.0 [20/0] via 10.10.10.2, 00:09:32
B 172.31.130.0/16 [20/0] via 10.10.10.2, 02:48:46
Esempio 3
Questo esempio prevede la reinstallazione della rete 192.168.50.0/24 in R102 per verificare come BGP passa da Advertise a Withdraw.
Modalità di passaggio di BGP da Advertise a Withdraw
Per reinstallare 192.168.50.0/24, eseguire il no shutdown
comando per portare l'interfaccia loopback 0 su R103 su "UP".
R103(config)#interface loopback 0
R103(config-if)#no shutdown
R103(config-if)#
03:49:06: %LINK-3-UPDOWN: Interface Loopback0,
changed state to up
03:49:07: %LINEPROTO-5-UPDOWN: Line protocol on
Interface Loopback0, changed state to up
!--- R102 kicks in conditional advertisement the moment the
!--- conditional network is received again.
*Mar 1 02:51:42.227: BGP(0): 10.10.20.3 rcvd UPDATE w/ attr:
nexthop 10.10.20.3, origin i, metric 0, path 3
*Mar 1 02:51:42.227: BGP(0): 10.10.20.3 rcvd 192.168.50.0/24
*Mar 1 02:51:42.247: BGP(0): Revise route installing 192.168.50.0/24 ->
10.10.20.3 to main IP table
*Mar 1 02:51:42.379: BGP(0): 10.10.10.1 computing updates, afi 0,
neighbor version 12, table version 13, starting at 0.0.0.0
*Mar 1 02:51:42.379: BGP(0): 10.10.10.1 send UPDATE (format)
192.168.50.0/24, next 10.10.10.2, metric 0, path 3
*Mar 1 02:51:42.379: BGP(0): 10.10.10.1 1 updates enqueued
(average=47, maximum=47)
*Mar 1 02:51:42.379: BGP(0): 10.10.10.1 update run completed, afi 0,
ran for 0ms, neighbor version 12, start version 13, throttled to 13
*Mar 1 02:52:09.159: BPG(0): Condition NON-EXIST changes to Withdraw
*Mar 1 02:52:09.159: BGP(0): net 172.16.16.0/24 matches ADV MAP
ADVERTISE: bump version to 14
*Mar 1 02:52:09.499: BGP(0): nettable_walker 172.16.16.0/24 route
sourced locally
*Mar 1 02:52:11.559: BGP(0): 10.10.10.1 computing updates, afi 0,
neighbor version 13, table version 14, starting at 0.0.0.0
*Mar 1 02:52:11.559: BGP(0): 10.10.10.1 172.16.16.0/24 matches advertise
map ADVERTISE, state: Withdraw
*Mar 1 02:52:11.559: BGP(0): 10.10.10.1 send unreachable 172.16.16.0/24
*Mar 1 02:52:11.559: BGP(0): 10.10.10.1 send UPDATE 172.16.16.0/24 -- unreachable
*Mar 1 02:52:11.559: BGP(0): 10.10.10.1 1 updates enqueued (average=27, maximum=27)
*Mar 1 02:52:11.559: BGP(0): 10.10.10.1 update run completed, afi 0, ran for 0ms,
neighbor version 13, start version 14, throttled to 14
R102 non pubblicizza più i numeri da 172.16.16.0/24 a R101.
R102#show ip bgp neighbors 10.10.10.1 advertised-routes
BGP table version is 14, local router ID is 172.16.16.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*> 172.31.130.0 0.0.0.0 0 32768 i
*> 192.168.50.0 10.10.20.3 0 0 3 i
!--- Note 172.16.16.0/24 is not advertised.
R102#show ip bgp neighbors 10.10.10.1
BGP neighbor is 10.10.10.1, remote AS 1, external link
BGP version 4, remote router ID 10.200.200.1
BGP state = Established, up for 03:01:32
Last read 00:00:31, hold time is 180, keepalive interval is 60 seconds
Neighbor capabilities:
!--- Output supressed.
For address family: IPv4 Unicast
BGP table version 14, neighbor version 14
Index 1, Offset 0, Mask 0x2
Condition-map NON-EXIST, Advertise-map ADVERTISE, status: Withdraw
1 accepted prefixes consume 36 bytes
Prefix advertised 7, suppressed 0, withdrawn 5
Number of NLRIs in the update sent: max 1, min 0
!--- Output supressed.
Nota: In uno scenario reale, AS1 e AS3 sono connessi a Internet (Global BGP). Di conseguenza, la rete 192.168.50.0/24 può essere propagata attraverso una mesh bgp globale da AS3 alla tabella BGP AS1 (R101). AS1, a sua volta, può propagare il prefisso da 192.168.50.0 a R102 (a seconda del contratto politico tra AS1 e AS2). Se R101 propaga le route AS3 apprese dalla mesh BGP globale a R102, l'annuncio condizionale può avere esito negativo se non vengono effettuati controlli aggiuntivi nella mappa inesistente.
Per comprendere meglio il motivo per cui la pubblicità condizionale fallisce, prendete in considerazione questo scenario. AS1 apprende 192.168.50.0/24 dalla mesh bgp globale e annuncia da 192.168.50.0/24 a AS2 (R102). R102 apprende anche il prefisso 192.168.50.0/24 dal suo peer diretto a R103 (sul collegamento da R102 a R103). Quando il collegamento diretto tra R102 e R103 ha esito negativo, si prevede che il prefisso 192.168.50.0/24 cessi di esistere nella tabella BGP di R102 e che l'annuncio condizionale venga attivato e annunci il prefisso da 172.16.16.0/24 a R101. Tuttavia, poiché il prefisso 192.168.50.0/24 continua a esistere nella tabella BGP di R102 (appreso da R101), l'annuncio condizionale viene interrotto perché il prefisso nella mappa inesistente esiste ancora in R10 2 tabella BGP.
Per fare in modo che il prefisso 192.168.50.0/24 venga appreso solo dalla connessione diretta ad AS3 (da R102 a R103) affinché l'annuncio condizionale abbia inizio, aggiungere un'istruzione match as_path nella mappa inesistente che corrisponda al prefisso 192.168.50.0/24 appreso dalla connessione diretta (in questo caso AS 3). L'espressione regolare per questo caso è ^3 . Per ulteriori informazioni sulle espressioni regolari, vedere Utilizzo delle espressioni regolari in BGP. Tenere presente che non è possibile trovare una corrispondenza solo con il percorso as e non con il prefisso. La corrispondenza come percorso può solo integrare i criteri di corrispondenza per il prefisso corrispondente. In altre parole, non è possibile annunciare alcuni prefissi a un router adiacente se non esiste alcun prefisso da un determinato numero AS.
Di seguito è illustrata la nuova configurazione del server R102. Le aggiunte sono in grassetto.
R101 |
hostname R102
!
interface Loopback0
ip address 172.16.16.1 255.255.255.0
!
interface Serial8/0
ip address 10.10.10.2 255.255.255.0
!
interface Serial9/0
ip address 10.10.20.2 255.255.255.0
!
router bgp 2
bgp log-neighbor-changes
network 172.16.16.0 mask 255.255.255.0
network 172.31.130.0
neighbor 10.10.10.1 remote-as 1
neighbor 10.10.10.1 advertise-map ADVERTISE non-exist-map NON-EXIST
neighbor 10.10.20.3 remote-as 3
!
ip route 172.31.130.0 255.255.0.0 Null0
!
ip as-path access-list 1 permit ^3
!
access-list 60 permit 172.16.16.0 0.0.0.255
access-list 65 permit 192.168.50.0 0.0.0.255
!
route-map NON-EXIST permit 10
match ip address 65
match as-path 1
!
route-map ADVERTISE permit 10
match ip address 60
! |
Informazioni correlate