1 Exemple de configuration des fonctions de base BGP
Exigences de mise en réseau
Comme le montre la figure 1-1 , le protocole BGP s'exécute entre les commutateurs; une connexion EBGP est établie entre SwitchA et SwitchB; Les connexions à maillage complet IBGP sont établies entre SwitchB, SwitchC et SwitchD.
Dans ce scénario, assurez-vous que STP est désactivé sur toutes les interfaces connectées. Si le protocole STP est activé et que les interfaces VLANIF des commutateurs sont utilisées pour construire un réseau en anneau de couche 3, une interface du réseau peut être bloquée. Par conséquent, les services de couche 3 sur le réseau ne peuvent pas s'exécuter normalement.
Figure 1-1 Schéma de réseau pour la configuration des fonctions de base BGP
Feuille de route de configuration
La feuille de route de configuration est la suivante:
1. Configurez les connexions IBGP entre SwitchB, SwitchC et SwitchD.
2 Configurez une connexion EBGP entre SwitchA et SwitchB.
Procédure
Étape 1 Créez des VLAN et ajoutez des interfaces aux VLAN correspondants.
# Configurez SwitchA. Les configurations de SwitchB, SwitchC et SwitchD sont similaires à la configuration de SwitchA.
<HUAWEI> system-view
[HUAWEI] sysname SwitchA
[SwitchA] vlan batch 10 50
[SwitchA] interface gigabitethernet 0/0/1
[SwitchA-GigabitEthernet0/0/1] port link-type trunk
[SwitchA-GigabitEthernet0/0/1] port trunk allow-pass vlan 10
[SwitchA-GigabitEthernet0/0/1] quit
[SwitchA] interface gigabitethernet 0/0/2
[SwitchA-GigabitEthernet0/0/2] port link-type trunk
[SwitchA-GigabitEthernet0/0/2] port trunk allow-pass vlan 50
[SwitchA-GigabitEthernet0/0/2] quit
Étape 2 Attribuez une adresse IP à chaque interface VLANIF.
# Configurez SwitchA. Les configurations de SwitchB, SwitchC et SwitchD sont similaires à la configuration de SwitchA.
[SwitchA] interface vlanif 10
[SwitchA-Vlanif10] ip address 192.168.1.2 24
[SwitchA-Vlanif10] quit
[SwitchA] interface vlanif 50
[SwitchA-Vlanif50] ip address 10.1.1.1 16
[SwitchA-Vlanif50] quit
Étape 3 Configurez les connexions IBGP.
# Configurez SwitchB.
[SwitchB] bgp 65009
[SwitchB-bgp] router-id 172.17.2.2
[SwitchB-bgp] peer 172.16.1.2 as-number 65009
[SwitchB-bgp] peer 172.16.3.2 as-number 65009
[SwitchB-bgp] quit
# Configurez SwitchC.
[SwitchC] bgp 65009
[SwitchC-bgp] router-id 172.17.3.3
[SwitchC-bgp] peer 172.16.3.1 as-number 65009
[SwitchC-bgp] peer 172.16.2.2 as-number 65009
[SwitchC-bgp] quit
# Configurez SwitchD.
[SwitchD] bgp 65009
[SwitchD-bgp] router-id 172.17.4.4
[SwitchD-bgp] peer 172.16.1.1 as-number 65009
[SwitchD-bgp] peer 172.16.2.1 as-number 65009
[SwitchD-bgp] quit
Étape 4 Configurez les connexions EBGP.
# Configurez SwitchA.
[SwitchA] bgp 65008
[SwitchA-bgp] router-id 172.17.1.1
[SwitchA-bgp] peer 192.168.1.1 as-number 65009
[SwitchA-bgp] quit
# Configurez SwitchB.
[SwitchB] bgp 65009
[SwitchB-bgp] peer 192.168.1.2 as-number 65008
[SwitchB-bgp] quit
# Vérifiez l'état des connexions BGP.
[SwitchB] display bgp peer
BGP local router ID : 172.17.2.2
Local AS number : 65009
Total number of peers : 3 Peers in established state : 3
Peer V AS MsgRcvd MsgSent OutQ Up/Down State PrefRcv
172.16.1.2 4 65009 49 62 0 00:44:58 Established 0
172.16.3.2 4 65009 56 56 0 00:40:54 Established 0
192.168.1.2 4 65008 49 65 0 00:44:03 Established 0
Vous pouvez voir que les connexions BGP entre SwitchB et tous les autres commutateurs sont configurées.
Étape 5 Configurez SwitchA pour publier l'itinéraire 10.1.0.0/16.
# Configurez SwitchA pour annoncer les itinéraires.
[SwitchA] bgp 65008
[SwitchA-bgp] ipv4-family unicast
[SwitchA-bgp-af-ipv4] network 10.1.0.0 255.255.0.0
[SwitchA-bgp-af-ipv4] quit
[SwitchA-bgp] quit
# Vérifiez la table de routage de SwitchA.
[SwitchA] display bgp routing-table
BGP Local router ID is 172.17.1.1
Status codes: * - valid, > - best, d - damped,
h - history, i - internal, s - suppressed, S - Stale
Origin : i - IGP, e - EGP, ? - incomplete
Total Number of Routes: 1
Network NextHop MED LocPrf PrefVal Path/Ogn
*> 10.1.0.0/16 0.0.0.0 0 0 i
# Vérifiez la table de routage de SwitchB.
[SwitchB] display bgp routing-table
BGP Local router ID is 172.17.2.2
Status codes: * - valid, > - best, d - damped,
h - history, i - internal, s - suppressed, S - Stale
Origin : i - IGP, e - EGP, ? - incomplete
Total Number of Routes: 1
Network NextHop MED LocPrf PrefVal Path/Ogn
*> 10.1.0.0/16 192.168.1.2 0 0 65008i
# Vérifiez la table de routage de SwitchC.
[SwitchC] display bgp routing-table
BGP Local router ID is 172.17.3.3
Status codes: * - valid, > - best, d - damped,
h - history, i - internal, s - suppressed, S - Stale
Origin : i - IGP, e - EGP, ? - incomplete
Total Number of Routes: 1
Network NextHop MED LocPrf PrefVal Path/Ogn
i 10.1.0.0/16 192.168.1.2 0 100 0 65008i
Selon la table de routage, vous pouvez voir que SwitchC a appris la route vers la destination 10.1.0.0 dans AS 65008, mais le saut suivant 192.168.1.2 est inaccessible. Par conséquent, cette route est invalide.
Étape 6 Configurez BGP pour importer des itinéraires directs.
# Configurez SwitchB.
[SwitchB] bgp 65009
[SwitchB-bgp] ipv4-family unicast
[SwitchB-bgp-af-ipv4] import-route direct
[SwitchB-bgp-af-ipv4] quit
[SwitchB-bgp] quit
# Vérifiez la table de routage BGP de SwitchA.
[SwitchA] display bgp routing-table
BGP Local router ID is 172.17.1.1
Status codes: * - valid, > - best, d - damped,
h - history, i - internal, s - suppressed, S - Stale
Origin : i - IGP, e - EGP, ? - incomplete
Total Number of Routes: 4
Network NextHop MED LocPrf PrefVal Path/Ogn
*> 10.1.0.0/16 0.0.0.0 0 0 i
*> 172.16.1.0/24 192.168.1.1 0 0 65009?
*> 172.16.3.0/24 192.168.1.1 0 0 65009?
192.168.1.0 192.168.1.1 0 0 65009?
# Vérifiez la table de routage de SwitchC.
[SwitchC] display bgp routing-table
BGP Local router ID is 172.17.3.3
Status codes: * - valid, > - best, d - damped,
h - history, i - internal, s - suppressed, S - Stale
Origin : i - IGP, e - EGP, ? - incomplete
Total Number of Routes: 4
Network NextHop MED LocPrf PrefVal Path/Ogn
*>i 10.1.0.0/16 192.168.1.2 0 100 0 65008i
*>i 172.16.1.0/24 172.16.3.1 0 100 0 ?
i 172.16.3.0/24 172.16.3.1 0 100 0 ?
*>i 192.168.1.0 172.16.3.1 0 100 0 ?
Vous pouvez voir que la route destinée à 10.1.0.0 devient valide et que le saut suivant est l'adresse de SwitchA.
# Effectuez l'opération ping pour vérifier la configuration.
[SwitchC] ping 10.1.1.1
PING 10.1.1.1: 56 data bytes, press CTRL_C to break
Reply from 10.1.1.1: bytes=56 Sequence=1 ttl=255 time=31 ms
Reply from 10.1.1.1: bytes=56 Sequence=2 ttl=255 time=47 ms
Reply from 10.1.1.1: bytes=56 Sequence=3 ttl=255 time=31 ms
Reply from 10.1.1.1: bytes=56 Sequence=4 ttl=255 time=16 ms
Reply from 10.1.1.1: bytes=56 Sequence=5 ttl=255 time=31 ms
--- 10.1.1.1 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 16/31/47 ms
----End
Fichiers de configuration
l Fichier de configuration SwitchA
#
sysname SwitchA
#
vlan batch 10 50
#
interface Vlanif10
ip address 192.168.1.2 255.255.255.0
#
interface Vlanif50
ip address 10.1.1.1 255.255.0.0
#
interface GigabitEthernet0/0/1
port link-type trunk
port trunk allow-pass vlan 10
#
interface GigabitEthernet0/0/2
port link-type trunk
port trunk allow-pass vlan 50
#
bgp 65008
router-id 172.17.1.1
peer 192.168.1.1 as-number 65009
#
ipv4-family unicast
undo synchronization
network 10.1.0.0 255.255.0.0
peer 192.168.1.1 enable
#
return
l Fichier de configuration SwitchB
#
sysname SwitchB
#
vlan batch 10 20 30
#
interface Vlanif10
ip address 192.168.1.1 255.255.255.0
#
interface Vlanif20
ip address 172.16.3.1 255.255.255.0
#
interface Vlanif30
ip address 172.16.1.1 255.255.255.0
#
interface GigabitEthernet0/0/1
port link-type trunk
port trunk allow-pass vlan 10
#
interface GigabitEthernet0/0/2
port link-type trunk
port trunk allow-pass vlan 20
#
interface GigabitEthernet0/0/3
port link-type trunk
port trunk allow-pass vlan 30
#
bgp 65009
router-id 172.17.2.2
peer 172.16.1.2 as-number 65009
peer 172.16.3.2 as-number 65009
peer 192.168.1.2 as-number 65008
#
ipv4-family unicast
undo synchronization
import-route direct
peer 172.16.1.2 enable
peer 172.16.3.2 enable
peer 192.168.1.2 enable
#
return
l Fichier de configuration SwitchC
#
sysname SwitchC
#
vlan batch 20 40
#
interface Vlanif20
ip address 172.16.3.2 255.255.255.0
#
interface Vlanif40
ip address 172.16.2.1 255.255.255.0
#
interface GigabitEthernet0/0/1
port link-type trunk
port trunk allow-pass vlan 20
#
interface GigabitEthernet0/0/2
port link-type trunk
port trunk allow-pass vlan 40
#
bgp 65009
router-id 172.17.3.3
peer 172.16.2.2 as-number 65009
peer 172.16.3.1 as-number 65009
#
ipv4-family unicast
undo synchronization
peer 172.16.2.2 enable
peer 172.16.3.1 enable
#
return
l Fichier de configuration SwitchD
#
sysname SwitchD
#
vlan batch 30 40
#
interface Vlanif30
ip address 172.16.1.2 255.255.255.0
#
interface Vlanif40
ip address 172.16.2.2 255.255.255.0
#
interface GigabitEthernet0/0/1
port link-type trunk
port trunk allow-pass vlan 30
#
interface GigabitEthernet0/0/2
port link-type trunk
port trunk allow-pass vlan 40
#
bgp 65009
router-id 172.17.4.4
peer 172.16.1.1 as-number 65009
peer 172.16.2.1 as-number 65009
#
ipv4-family unicast
undo synchronization
peer 172.16.1.1 enable
peer 172.16.2.1 enable
#
return