Auf dieser Seite
Beispiel: Konfigurieren der Priorität für Routenpräfixe in der RPD-Infrastruktur
In diesem Beispiel wird gezeigt, wie die Priorität für Routenpräfixe in der RPD-Infrastruktur für die Protokolle OSPF, LDP und BGP konfiguriert wird.
Anforderungen
In diesem Beispiel werden die folgenden Hardware- und Softwarekomponenten verwendet:
Drei Router in einer Kombination aus ACX-Serie, M-Serie, MX-Serie, PTX-Serie und T-Serie.
Junos OS, Version 16.1 oder höher, läuft auf allen Geräten.
Bevor Sie beginnen:
Konfigurieren Sie die Geräteschnittstellen.
Konfigurieren Sie die folgenden Protokolle:
BGP
MPLS
OSPF
LDP
Überblick
In einem Netzwerk mit einer großen Anzahl von Routen ist es manchmal wichtig, die Reihenfolge zu steuern, in der die Routen aktualisiert werden, um eine bessere Konvergenz zu erzielen und differenzierte Dienste bereitzustellen. Die Präfix-Priorisierung hilft Benutzern, bestimmte Routen/Präfixe gegenüber anderen zu priorisieren und die Kontrolle über die Reihenfolge zu haben, in der Routen im RIB (Routing-Tabelle) und im FIB (Weiterleitungstabelle) aktualisiert werden. In Junos OS Version 16.1 und höher können Sie die Reihenfolge steuern, in der die Routen von LDP/OSPF auf rpd und rpd auf kernel aktualisiert werden. Sie können eine Priorität für high
oder low
durch die vorhandene Importrichtlinie in den Protokollen festlegen. Bei einer Änderung der Topologie werden in der Routingtabelle zuerst Präfixe mit hoher Priorität aktualisiert, gefolgt von Präfixen mit niedriger Priorität. Im Allgemeinen werden Routen, denen nicht explizit eine Priorität zugewiesen ist, als mittlere Priorität behandelt. Innerhalb der gleichen Prioritätsstufe werden die Routen weiterhin in lexikografischer Reihenfolge aktualisiert.
In diesem Beispiel befindet sich das Routing-Gerät im Bereich 0.0.0.0, wobei das Interface ge-1/3/0 mit dem Nachbargerät verbunden ist. Sie konfigurieren drei Import-Routing-Richtlinien: next-hop-self, ospf-prio und prio_for_bgp. Die Routing-Richtlinie next-hop-self akzeptiert Routen von BGP. Für die OSPF-Routing-Richtlinie werden Routen, die 172.16.25.3/32 entsprechen, zuerst installiert, da sie die Priorität "Hoch" haben. LDP importiert Routen aus OSPF. Für die BGP-Priorisierung werden Routen, die mit 172.16.50.1/32 übereinstimmen, zuerst installiert, da sie die Priorität "Hoch" haben. Routen, die diesen Präfixen zugeordnet sind, werden in der Routing-Tabelle in der Reihenfolge der angegebenen Priorität des Präfixes installiert.
Topologie
Abbildung 1 zeigt die Beispieltopologie.

Konfiguration
CLI-Schnellkonfiguration
Um dieses Beispiel schnell zu konfigurieren, kopieren Sie die folgenden Befehle, fügen Sie sie in eine Textdatei ein, entfernen Sie alle Zeilenumbrüche, ändern Sie alle Details, die für Ihre Netzwerkkonfiguration erforderlich sind, kopieren Sie die Befehle und fügen Sie sie in die CLI auf Hierarchieebene [edit] ein, und geben Sie sie dann im Konfigurationsmodus ein commit
.
R1
set interfaces ge-1/3/0 unit 0 family inet address 172.16.12.1/24 set interfaces ge-1/3/0 unit 0 family mpls set interfaces lo0 unit 0 family inet address 172.16.25.1/32 set protocols mpls interface ge-1/3/0.0 set protocols bgp group prio_internal type internal set protocols bgp group prio_internal local-address 172.16.25.1 set protocols bgp group prio_internal import prio_for_bgp set protocols bgp group prio_internal neighbor 172.16.25.3 family inet unicast set protocols bgp group prio_internal neighbor 172.16.25.3 export next-hop-self sset protocols ospf import ospf_prio set protocols ospf area 0.0.0.0 interface ge-1/3/0.0 set protocols ospf area 0.0.0.0 interface lo0.0 passive set protocols ldp interface ge-1/3/0.0 set protocols ldp interface lo0.0 set policy-options policy-statement next-hop-self term nhself from protocol bgp set policy-options policy-statement next-hop-self term nhself then next-hop self set policy-options policy-statement next-hop-self term nhself then accept set policy-options policy-statement ospf_prio term ospf_ldp from protocol ospf set policy-options policy-statement ospf_prio term ospf_ldp from route-filter 172.16.25.3/32 exact set policy-options policy-statement ospf_prio term ospf_ldp then priority high set policy-options policy-statement ospf_prio term ospf_ldp then accept set policy-options policy-statement prio_for_bgp term bgp_prio from protocol bgp set policy-options policy-statement prio_for_bgp term bgp_prio from route-filter 172.16.50.1/32 exact set policy-options policy-statement prio_for_bgp term bgp_prio then priority high set routing-options nonstop-routing set routing-options router-id 172.16.25.1 set routing-options autonomous-system 2525
R2
set interfaces ge-1/0/5 unit 0 family inet address 172.16.12.2/24 set interfaces ge-1/0/5 unit 0 family mpls set interfaces ge-1/3/0 unit 0 family inet address 172.16.23.2/24 set interfaces ge-1/3/0 unit 0 family mpls set interfaces lo0 unit 0 family inet address 172.16.25.2/32 set protocols mpls interface ge-1/0/5.0 set protocols mpls interface ge-1/3/0.0 set protocols ospf area 0.0.0.0 interface lo0.0 passive set protocols ospf area 0.0.0.0 interface ge-1/0/5.0 set protocols ospf area 0.0.0.0 interface ge-1/3/0.0 set protocols ldp interface ge-1/0/5.0 set protocols ldp interface ge-1/3/0.0 set protocols ldp interface lo0.0 set routing-options nonstop-routing set routing-options router-id 172.16.25.2 set routing-options autonomous-system 2525
R3
set interfaces ge-1/0/1 unit 0 family inet address 172.16.23.3/24 set interfaces ge-1/0/1 unit 0 family mpls set interfaces lo0 unit 0 family inet address 172.16.25.3/32 set protocols mpls interface ge-1/0/1.0 set protocols bgp group prio_internal type internal set protocols bgp group prio_internal local-address 172.16.25.3 set protocols bgp group prio_internal neighbor 172.16.25.1 family inet unicast set protocols bgp group prio_internal neighbor 172.16.25.1 export next-hop-self set protocols bgp group prio_internal neighbor 172.16.25.1 export static_to_bgp set protocols ospf area 0.0.0.0 interface lo0.0 passive set protocols ospf area 0.0.0.0 interface ge-1/0/1.0 set protocols ldp interface ge-1/0/1.0 set protocols ldp interface lo0.0 set policy-options policy-statement next-hop-self term nhself from protocol bgp set policy-options policy-statement next-hop-self term nhself then next-hop self set policy-options policy-statement next-hop-self term nhself then accept set policy-options policy-statement static_to_bgp term s_to_b from protocol static set policy-options policy-statement static_to_bgp term s_to_b from route-filter 172.16.50.1/32 exact set policy-options policy-statement static_to_bgp term s_to_b from route-filter 172.16.50.2/32 exact set policy-options policy-statement static_to_bgp term s_to_b then accept set routing-options nonstop-routing set routing-options static route 172.16.50.1/32 receive set routing-options static route 172.16.50.2/32 receive set routing-options router-id 172.16.25.3 set routing-options autonomous-system 2525
Konfigurieren von Gerät R1
Schritt-für-Schritt-Anleitung
Im folgenden Beispiel müssen Sie durch verschiedene Ebenen in der Konfigurationshierarchie navigieren. Informationen zum Navigieren in der CLI finden Sie Verwenden des CLI-Editors im Konfigurationsmodus im CLI-Benutzerhandbuch.
So konfigurieren Sie Gerät R1:
Konfigurieren Sie die Schnittstellen.
[edit interfaces]
user@R1# set interfaces ge-1/3/0 unit 0 family inet address 172.16.12.1/24 user@R1# set interfaces ge-1/3/0 unit 0 family mpls user@R1# set interfaces lo0 unit 0 family inet address 172.16.25.1/32Weisen Sie dem Gerät die Loopback-Adresse zu.
[edit lo0 unit 0 family]
user@R1# set address 172.16.25.1/32Konfigurieren Sie MPLS.
[edit protocols]
user@R1# set protocols mpls interface ge-1/3/0.0Konfigurieren Sie die Router-ID und das autonome System des Routers R1.
[edit routing-options]
user@R1# set router-id 172.16.7.7 user@R1# set autonomous-system 100Aktivieren Sie OSPF auf den Schnittstellen des Routers R1.
[edit protocols]
user@R1# set protocols ospf import ospf_prio user@R1# set protocols ospf area 0.0.0.0 interface ge-1/3/0.0 user@R1# set protocols ospf area 0.0.0.0 interface lo0.0 passiveKonfigurieren Sie LDP-Protokolle auf den Schnittstellen.
[edit protocols]
user@R1# set protocols ldp interface ge-1/3/0.0 user@R1# set protocols ldp interface lo0.0Konfigurieren Sie BGP.
[edit protocols]
user@R1# set protocols bgp group prio_internal type internal user@R1# set protocols bgp group prio_internal local-address 172.16.25.1 user@R1# set protocols bgp group prio_internal import prio_for_bgp user@R1# set protocols bgp group prio_internal neighbor 172.16.25.3 family inet unicast user@R1# set protocols bgp group prio_internal neighbor 172.16.25.3 export next-hop-selfKonfigurieren Sie die Richtlinienoptionen so, dass die Routen priorisiert werden. Die Richtlinie next-hop-self akzeptiert Routen von BGP. Sie konfigurieren drei Import-Routing-Richtlinien: next-hop-self, ospf-prio und prio_for_bgp. Die Routing-Richtlinie next-hop-self akzeptiert Routen von BGP. Für die ospf-prio-Routing-Richtlinie werden Routen, die 172.16.25.3/32 entsprechen, zuerst installiert, da sie die Priorität "Hoch" haben. LDP importiert Routen aus OSPF. Für prio_for_bgp Richtlinie werden Routen, die mit 172.16.50.1/32 übereinstimmen, zuerst installiert, da sie die Priorität "Hoch" haben.
[edit policy-options policy-statement]
user@R1# set policy-options policy-statement next-hop-self term nhself from protocol bgp user@R1# set policy-options policy-statement next-hop-self term nhself then next-hop self user@R1# set policy-options policy-statement next-hop-self term nhself then accept user@R1# set policy-options policy-statement ospf_prio term ospf_ldp from protocol ospf user@R1# set policy-options policy-statement ospf_prio term ospf_ldp from route-filter 172.16.25.3/32 exact set policy-options policy-statement ospf_prio term ospf_ldp then priority high set policy-options policy-statement ospf_prio term ospf_ldp then accept set policy-options policy-statement prio_for_bgp term bgp_prio from protocol bgp set policy-options policy-statement prio_for_bgp term bgp_prio from route-filter 172.16.50.1/32 exact set policy-options policy-statement prio_for_bgp term bgp_prio then priority high
Ergebnisse
Bestätigen Sie im Konfigurationsmodus Ihre Konfiguration, indem Sie die show interfacesBefehle , show protocols, show routing-optionsund show policy-options eingeben. Wenn die Ausgabe nicht die gewünschte Konfiguration anzeigt, wiederholen Sie die Anweisungen in diesem Beispiel, um die Konfiguration zu korrigieren.
[edit] user@R1# show interfaces ge-1/3/0 { unit 0 { family inet { address 172.16.12.1/24; } family mpls; } } lo0 { unit 0 { family inet { address address 172.16.25.1/32; } } }
[edit] user@R1# show protocols mpls { interface ge-1/3/0.0; } bgp { group prio_internal { type internal; local-address 172.16.25.1; import prio_for_bgp neighbor 172.16.25.3 { family inet { unicast; } export next-hop-self; } } } ospf { import ospf_prio; area 0.0.0.0 { interface ge-1/3/0.0; interface lo0.0 { passive; } } } ldp { interface ge-1/3/0.0; interface lo0.0; } }
[edit] user@R1# show routing-options nonstop-routing; router-id 172.16.25.1; autonomous-system 2525;
[edit] user@R1# show policy-options policy-statement next-hop-self { term nhself { from protocol bgp; then { next-hop self; accept; } } } policy-statement ospf_prio { term ospf_ldp { from { protocol ospf; route-filter 172.16.25.3/32 exact; } then { priority high; accept; } } } policy-statement prio_for_bgp { term bgp_prio { from { protocol bgp; route-filter 172.16.50.1/32 exact; } then priority high; } }
Wenn Sie mit der Konfiguration des Geräts fertig sind, geben Sie es im Konfigurationsmodus ein commit
.
Verifizierung
Vergewissern Sie sich, dass die Konfiguration ordnungsgemäß funktioniert.
- Überprüfen der Priorität für OSPF-Routen
- Überprüfen der Priorität für LDP-Routen
- Überprüfen der Priorität für BGP-Routen
Überprüfen der Priorität für OSPF-Routen
Zweck
Stellen Sie sicher, dass die Priorität für die erwartete Route in OSPF festgelegt ist.
Action!
Führen Sie den show ospf route 172.16.25.3/32 extensive
Befehl auf Gerät R1 im Betriebsmodus aus. Die Priorität "Hoch" wird auf die OSPF-Route 172.16.25.3 angewendet.
user@R1> show ospf route 172.16.25.3/32 extensive
Topology default Route Table:
Prefix Path Route NH Metric NextHop Nexthop
Type Type Type Interface Address/LSP
172.16.25.3 Intra Router IP 2 ge-1/3/0.0 172.16.12.2
area 0.0.0.0, origin 172.16.25.3, optional-capability 0x0
172.16.25.3/32 Intra Network IP 2 ge-1/3/0.0 172.16.12.2
area 0.0.0.0, origin 172.16.25.3, priority high
Bedeutung
Die Ausgabe zeigt, dass die Priorität high
für die OSPF-Route 172.16.25.3 angewendet wird.
Überprüfen der Priorität für LDP-Routen
Zweck
Überprüfen Sie, ob LDP von OSPF erbt.
Action!
Geben Sie im Betriebsmodus den show route 172.16.25.3
Befehl ein, um zu überprüfen, ob LDP Routen von OSPF geerbt hat.
user@R1> show route 172.16.25.3
inet.0: 24 destinations, 24 routes (24 active, 0 holddown, 0 hidden)
+ = Active Route, - = Last Active, * = Both
172.16.25.3/32 *[OSPF/10] 00:10:27, metric 2
> to 172.16.25.2 via ge-1/3/0.0
inet.3: 2 destinations, 2 routes (2 active, 0 holddown, 0 hidden)
+ = Active Route, - = Last Active, * = Both
172.16.25.3/32 *[LDP/9] 00:10:24, metric 1
> to 172.16.25.2 via ge-1/3/0.0, Push 299824
Geben Sie im Betriebsmodus den show route 172.16.25.3 extensive
Befehl ein, um zu überprüfen, ob LDP die Priorität geerbt hat.
user@R1> show route 172.16.25.3 extensive
inet.0: 24 destinations, 24 routes (24 active, 0 holddown, 0 hidden)
172.16.25.3/32 (1 entry, 1 announced)
State:<Flashall>
TSI:
KRT in-kernel 172.16.25.3/32 -> {172.16.12.2}
*OSPF Preference: 10
Next hop type: Router, Next hop index: 549
Address: 0xa463390
Next-hop reference count: 6
Next hop: 172.16.12.2 via ge-1/3/0.0, selected
Session Id: 0x0
State:<Active Int HighPriority>
Local AS: 2525
Age: 10:43 Metric: 2
Validation State: unverified
Area: 0.0.0.0
Task: OSPF
Announcement bits (4): 0-KRT 4-LDP 6-Resolve tree 2 7-Resolve_IGP_FRR task
AS path: I
inet.3: 2 destinations, 2 routes (2 active, 0 holddown, 0 hidden)
172.16.25.3/32 (1 entry, 1 announced)
State:<Flashall>
LDP Preference: 9
Next hop type: Router, Next hop index: 582
Address: 0xa477810
Next-hop reference count: 12
Next hop: 172.16.12.2 via ge-1/3/0.0, selected
Label operation: Push 299824
Label TTL action: prop-ttl
Load balance label: Label 299824: None;
Label element ptr: 0xa17ad00
Label parent element ptr: 0x0
Label element references: 1
Label element child references: 0
Label element lsp id: 0
Session Id: 0x0
State:<Active Int HighPriority>
Local AS: 2525
Age: 10:40 Metric: 1
Validation State: unverified
Task: LDP
Announcement bits (3): 2-Resolve tree 1 3-Resolve tree 2 4-Resolve_IGP_FRR task
AS path: I
Bedeutung
Die Ausgabe zeigt, dass LDP die Priorität high
für Route 172.16.25.3 von OSPF erbt.
Überprüfen der Priorität für BGP-Routen
Zweck
Stellen Sie sicher, dass die Priorität für die erwartete Route in BGP festgelegt ist.
Action!
Führen Sie auf Gerät R1 im Betriebsmodus den show route protocol bgp
Befehl aus, um die vom BGP gelernten Routen anzuzeigen.
user@R1> show route protocol bgp
inet.0: 24 destinations, 24 routes (24 active, 0 holddown, 0 hidden)
+ = Active Route, - = Last Active, * = Both
172.16.50.1/32 *[BGP/170] 00:11:24, localpref 100, from 172.16.25.3
AS path: I, validation-state: unverified
> to 172.16.12.2 via ge-1/3/0.0, Push 299824
172.16.50.2/32 *[BGP/170] 00:11:24, localpref 100, from 172.16.25.3
AS path: I, validation-state: unverified
> to 172.16.12.2 via ge-1/3/0.0, Push 299824
inet.3: 2 destinations, 2 routes (2 active, 0 holddown, 0 hidden)
mpls.0: 9 destinations, 9 routes (9 active, 0 holddown, 0 hidden)
Führen Sie den show route 172.16.50.1 extensive
Befehl auf Gerät R1 im Betriebsmodus aus. Hohe Priorität hat die BGP-Route 172.16.50.1.
user@R1> show route 172.16.50.1 extensive
inet.0: 24 destinations, 24 routes (24 active, 0 holddown, 0 hidden)
172.16.50.1/32 (1 entry, 1 announced)
TSI:
KRT in-kernel 172.16.50.1/32 -> {indirect(1048574)}
*BGP Preference: 170/-101
Next hop type: Indirect, Next hop index: 0
Address: 0xa487b10
Next-hop reference count: 4
Source: 172.16.25.3
Next hop type: Router, Next hop index: 582
Next hop: 172.16.12.2 via ge-1/3/0.0, selected
Label operation: Push 299824
Label TTL action: prop-ttl
Load balance label: Label 299824: None;
Label element ptr: 0xa17ad00
Label parent element ptr: 0x0
Label element references: 1
Label element child references: 0
Label element lsp id: 0
Session Id: 0x0
Protocol next hop: 172.16.25.3
Indirect next hop: 0xa4a9800 1048574 INH Session ID: 0x0
State: <Active Int Ext HighPriority>
Local AS: 2525 Peer AS: 2525
Age: 11:49 Metric2: 1
Validation State: unverified
Task: BGP_2525.172.16.25.3
Announcement bits (2): 0-KRT 6-Resolve tree 2
AS path: I (Atomic)
Accepted
Localpref: 100
Router ID: 172.16.25.3
Indirect next hops: 1
Protocol next hop: 172.16.25.3 Metric: 1
Indirect next hop: 0xa4a9800 1048574 INH Session ID: 0x0
Indirect path forwarding next hops: 1
Next hop type: Router
Next hop: 172.16.12.2 via ge-1/3/0.0
Session Id: 0x0
172.16.25.3/32 Originating RIB: inet.3
Metric: 1 Node path count: 1
Forwarding nexthops: 1
Nexthop: 172.16.12.2 via ge-1/3/0.0
Bedeutung
Die Ausgabe zeigt, dass die Priorität high
auf die BGP-Route 172.16.50.1 angewendet wird.