Auf dieser Seite
Beispiel: Konfigurieren von Richtlinienketten und Routenfiltern
Eine Richtlinienkette ist die Anwendung mehrerer Richtlinien innerhalb eines bestimmten Abschnitts der Konfiguration. Ein Routenfilter ist eine Sammlung von Übereinstimmungspräfixen.
Anforderungen
Vor der Konfiguration dieses Beispiels ist keine spezielle Konfiguration erforderlich, die über die Geräteinitialisierung hinausgeht.
Überblick
Im Folgenden finden Sie ein Beispiel für eine Richtlinienkette, die auf BGP angewendet wird:
user@R1# show protocols bgp group int { type internal; local-address 192.168.0.1; export [ adv-statics adv-large-aggregates adv-small-aggregates ]; neighbor 192.168.0.2; neighbor 192.168.0.3; }
Die Richtlinien , und bilden zusätzlich zur standardmäßigen BGP-Richtlinie die Richtlinienkette, die auf die BGP-Peers von Gerät R1 angewendet wird.adv-statics
adv-large-aggregates
adv-small-aggregates
Zwei der Richtlinien veranschaulichen Routenfilter mit unterschiedlichen Übereinstimmungstypen. Die andere Richtlinie stimmt mit allen statischen Routen überein, sodass kein Routenfilter erforderlich ist.
user@R1# show policy-options policy-statement adv-large-aggregates { term between-16-and-18 { from { protocol aggregate; route-filter 172.16.0.0/16 upto /18; } then accept; } } policy-statement adv-small-aggregates { term between-19-and-24 { from { protocol aggregate; route-filter 172.16.0.0/16 prefix-length-range /19-/24; } then accept; } } policy-statement adv-statics { term statics { from protocol static; then accept; } }
Optional können Sie diese Richtlinienkette in eine einzelne Richtlinie mit mehreren Laufzeiten für die internen BGP-Peers (IBGP) umwandeln. Wenn Sie dies tun, geht einer der Vorteile einer Richtlinienkette verloren – die Möglichkeit, Richtlinien für verschiedene Zwecke wiederzuverwenden.
Abbildung 1 zeigt das Gerät R1 im AS 64510 mit seinen IBGP-Peers, Gerät R2 und Gerät R3 an. Das Gerät R1 verfügt auch über externe BGP-Verbindungen (EBGP) für das Gerät R4 in AS 64511 und das Gerät R5 in AS 64512. Die aktuelle administrative Richtlinie in AS 64510 besteht darin, die statischen Routen des Kunden nur an andere IBGP-Peers zu senden. Jeder EBGP-Peer, der einen Transitdienst bereitstellt, empfängt nur aggregierte Routen mit Maskenlängen von weniger als 18 Bit. Jeder EBGP-Peer, der Peering-Services bereitstellt, empfängt alle Kundenrouten und alle Aggregate, deren Maskenlänge größer als 19 Bit ist. Jeder Teil dieser administrativen Richtlinien wird in einer separaten Routingrichtlinie innerhalb der Konfigurationshierarchie konfiguriert.[edit policy-opitons]
Diese Richtlinien bieten den Administratoren von AS 64510 mehrere Konfigurationsoptionen für die Ankündigung von Routen an Peers.
Gerät R4 stellt einen Transitdienst für AS 64510 bereit, der es dem AS ermöglicht, den ihm zugewiesenen Routing-Speicherplatz im Internet anzukündigen. Andererseits ermöglicht der von Device R5 bereitgestellte Peering-Service dem AS 64510, den Datenverkehr für alle Kundenrouten direkt zwischen den autonomen Systemen (ASs) zu routen.
Topologie
Abbildung 1 zeigt das Beispielnetzwerk an.
CLI-Schnellkonfiguration Zeigt die Konfiguration für alle Geräte in Abbildung 1an.
Im Abschnitt Vorgehensweise werden die Schritte auf Gerät R1 beschrieben.#configuration283__policy-chains-st
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, und kopieren Sie dann die Befehle und fügen Sie sie in die CLI auf Hierarchieebene ein.[edit]
Gerät R1
set interfaces fe-1/2/0 unit 0 description to_R2 set interfaces fe-1/2/0 unit 0 family inet address 10.0.0.1/30 set interfaces fe-1/2/2 unit 0 description to_R3 set interfaces fe-1/2/2 unit 0 family inet address 10.0.0.5/30 set interfaces fe-1/2/3 unit 0 description to_R4 set interfaces fe-1/2/3 unit 0 family inet address 10.1.0.5/30 set interfaces fe-1/2/1 unit 0 description to_R5 set interfaces fe-1/2/1 unit 0 family inet address 10.0.0.10/30 set interfaces lo0 unit 0 family inet address 192.168.0.1/32 set protocols bgp group int type internal set protocols bgp group int local-address 192.168.0.1 set protocols bgp group int export adv-statics set protocols bgp group int export adv-large-aggregates set protocols bgp group int export adv-small-aggregates set protocols bgp group int neighbor 192.168.0.2 set protocols bgp group int neighbor 192.168.0.3 set protocols bgp group to_64511 type external set protocols bgp group to_64511 export adv-large-aggregates set protocols bgp group to_64511 neighbor 10.1.0.6 peer-as 64511 set protocols bgp group to_64512 type external set protocols bgp group to_64512 export adv-small-aggregates set protocols bgp group to_64512 export adv-statics set protocols bgp group to_64512 neighbor 10.0.0.9 peer-as 64512 set protocols ospf area 0.0.0.0 interface fe-1/2/0.0 set protocols ospf area 0.0.0.0 interface fe-1/2/2.0 set protocols ospf area 0.0.0.0 interface lo0.0 passive set policy-options policy-statement adv-large-aggregates term between-16-and-18 from protocol aggregate set policy-options policy-statement adv-large-aggregates term between-16-and-18 from route-filter 172.16.0.0/16 upto /18 set policy-options policy-statement adv-large-aggregates term between-16-and-18 then accept set policy-options policy-statement adv-small-aggregates term between-19-and-24 from protocol aggregate set policy-options policy-statement adv-small-aggregates term between-19-and-24 from route-filter 172.16.0.0/16 prefix-length-range /19-/24 set policy-options policy-statement adv-small-aggregates term between-19-and-24 then accept set policy-options policy-statement adv-statics term statics from protocol static set policy-options policy-statement adv-statics term statics then accept set routing-options static route 172.16.1.16/28 discard set routing-options static route 172.16.1.32/28 discard set routing-options static route 172.16.1.48/28 discard set routing-options static route 172.16.1.64/28 discard set routing-options aggregate route 172.16.0.0/16 set routing-options aggregate route 172.16.1.0/24 set routing-options router-id 192.168.0.1 set routing-options autonomous-system 64510
Gerät R2
set interfaces fe-1/2/0 unit 0 description to_R1 set interfaces fe-1/2/0 unit 0 family inet address 10.0.0.2/30 set interfaces fe-1/2/1 unit 0 description to_R3 set interfaces fe-1/2/1 unit 0 family inet address 10.1.0.1/30 set interfaces lo0 unit 0 family inet address 192.168.0.2/32 set protocols bgp group int type internal set protocols bgp group int local-address 192.168.0.2 set protocols bgp group int neighbor 192.168.0.1 export send-static-aggregate set protocols bgp group int neighbor 192.168.0.3 set protocols ospf area 0.0.0.0 interface fe-1/2/0.0 set protocols ospf area 0.0.0.0 interface fe-1/2/1.0 set protocols ospf area 0.0.0.0 interface lo0.0 passive set policy-options policy-statement send-static-aggregate term 1 from protocol static set policy-options policy-statement send-static-aggregate term 1 from protocol aggregate set policy-options policy-statement send-static-aggregate term 1 then accept set routing-options static route 172.16.2.16/28 discard set routing-options static route 172.16.2.32/28 discard set routing-options static route 172.16.2.48/28 discard set routing-options static route 172.16.2.64/28 discard set routing-options aggregate route 172.16.2.0/24 set routing-options aggregate route 172.16.0.0/16 set routing-options router-id 192.168.0.2 set routing-options autonomous-system 64510
Gerät R3
set interfaces fe-1/2/1 unit 0 description to_R2 set interfaces fe-1/2/1 unit 0 family inet address 10.1.0.2/30 set interfaces fe-1/2/2 unit 0 description to_R1 set interfaces fe-1/2/2 unit 0 family inet address 10.0.0.6/30 set interfaces lo0 unit 0 family inet address 192.168.0.3/32 set protocols bgp group int type internal set protocols bgp group int local-address 192.168.0.3 set protocols bgp group int neighbor 192.168.0.1 export send-static-aggregate set protocols bgp group int neighbor 192.168.0.2 set protocols ospf area 0.0.0.0 interface fe-1/2/2.0 set protocols ospf area 0.0.0.0 interface fe-1/2/1.0 set protocols ospf area 0.0.0.0 interface lo0.0 passive set policy-options policy-statement send-static-aggregate from protocol static set policy-options policy-statement send-static-aggregate from protocol aggregate set policy-options policy-statement send-static-aggregate then accept set routing-options static route 172.16.3.16/28 discard set routing-options static route 172.16.3.32/28 discard set routing-options static route 172.16.3.48/28 discard set routing-options static route 172.16.3.64/28 discard set routing-options aggregate route 172.16.0.0/16 set routing-options aggregate route 172.16.3.0/24 set routing-options router-id 192.168.0.3 set routing-options autonomous-system 64510
Gerät R4
set interfaces fe-1/2/3 unit 0 description to_R1 set interfaces fe-1/2/3 unit 0 family inet address 10.1.0.6/30 set interfaces lo0 unit 0 family inet address 192.168.0.4/32 set protocols bgp group ext type external set protocols bgp group ext peer-as 64510 set protocols bgp group ext neighbor 10.1.0.5 set routing-options autonomous-system 64511
Gerät R5
set interfaces fe-1/2/1 unit 0 description to_R1 set interfaces fe-1/2/1 unit 0 family inet address 10.0.0.9/30 set interfaces lo0 unit 0 family inet address 192.168.0.5/32 set protocols bgp group ext type external set protocols bgp group ext neighbor 10.0.0.10 peer-as 64510 set routing-options autonomous-system 64512
Verfahren
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 im Junos OS CLI-Benutzerhandbuch.Verwenden des CLI-Editors im Konfigurationsmodushttps://www.juniper.net/documentation/en_US/junos/information-products/pathway-pages/junos-cli/junos-cli.html
So konfigurieren Sie Gerät R1:
Konfigurieren Sie die Geräteschnittstellen.
[edit interfaces] user@R1# set fe-1/2/0 unit 0 description to_R2 user@R1# set fe-1/2/0 unit 0 family inet address 10.0.0.1/30 user@R1# set fe-1/2/2 unit 0 description to_R3 user@R1# set fe-1/2/2 unit 0 family inet address 10.0.0.5/30 user@R1# set fe-1/2/3 unit 0 description to_R4 user@R1# set fe-1/2/3 unit 0 family inet address 10.1.0.5/30 user@R1# set fe-1/2/1 unit 0 description to_R5 user@R1# set fe-1/2/1 unit 0 family inet address 10.0.0.10/30 user@R1# set lo0 unit 0 family inet address 192.168.0.1/32
Konfigurieren Sie die IBGP-Verbindungen zu Gerät R2 und Gerät R3.
[edit protocols bgp group int] user@R1# set type internal user@R1# set local-address 192.168.0.1 user@R1# set neighbor 192.168.0.2 user@R1# set neighbor 192.168.0.3
Wenden Sie die Exportrichtlinien für die internen Peers an.
[edit protocols bgp group int] user@R1# set export adv-statics user@R1# set export adv-large-aggregates user@R1# set export adv-small-aggregates
Konfigurieren Sie die EBGP-Verbindung zu Gerät R4.
[edit protocols bgp group to_64511] user@R1# set type external user@R1# set neighbor 10.1.0.6 peer-as 64511
Wenden Sie die Exportrichtlinie für Gerät R4 an.
[edit protocols bgp group to_64511] user@R1# set export adv-large-aggregates
Konfigurieren Sie die EBGP-Verbindung mit Gerät R5.
[edit protocols bgp group to_64512] user@R1# set type external user@R1# set neighbor 10.0.0.9 peer-as 64512
Wenden Sie die Exportrichtlinien für Gerät R5 an.
[edit protocols bgp group to_64512] user@R1# set export adv-small-aggregates user@R1# set export adv-statics
Konfigurieren Sie OSPF-Verbindungen zu Gerät R2 und Gerät R3.
[edit protocols ospf area 0.0.0.0] user@R1# set interface fe-1/2/0.0 user@R1# set interface fe-1/2/2.0 user@R1# set interface lo0.0 passive
Konfigurieren Sie die Routing-Richtlinien.
[edit policy-options policy-statement adv-large-aggregates term between-16-and-18] user@R1# set from protocol aggregate user@R1# set from route-filter 172.16.0.0/16 upto /18 user@R1# set then accept [edit policy-options policy-statement adv-small-aggregates term between-19-and-24] user@R1# set from protocol aggregate user@R1# set from route-filter 172.16.0.0/16 prefix-length-range /19-/24 user@R1# set then accept [edit policy-options policy-statement adv-statics term statics] user@R1# set from protocol static user@R1# set then accept
Konfigurieren Sie die statischen und aggregierten Routen.
[edit routing-options static] user@R1# set route 172.16.1.16/28 discard user@R1# set route 172.16.1.32/28 discard user@R1# set route 172.16.1.48/28 discard user@R1# set route 172.16.1.64/28 discard [edit routing-options aggregate] user@R1# set route 172.16.0.0/16 user@R1# set route 172.16.1.0/24
Konfigurieren Sie die AS-Nummer (Autonomous System) und die Router-ID.
[edit routing-options] user@R1# set router-id 192.168.0.1 user@R1# set autonomous-system 64510
Ergebnisse
Bestätigen Sie im Konfigurationsmodus Ihre Konfiguration, indem Sie die Befehle , , und eingeben.show interfaces
show protocols
show policy-options
show routing-options
Wenn die Ausgabe nicht die gewünschte Konfiguration anzeigt, wiederholen Sie die Anweisungen in diesem Beispiel, um die Konfiguration zu korrigieren.
user@R1# show interfaces fe-1/2/0 { unit 0 { description to_R2; family inet { address 10.0.0.1/30; } } } fe-1/2/2 { unit 0 { description to_R3; family inet { address 10.0.0.5/30; } } } fe-1/2/3 { unit 0 { description to_R4; family inet { address 10.1.0.5/30; } } } fe-1/2/1 { unit 0 { description to_R5; family inet { address 10.0.0.10/30; } } } lo0 { unit 0 { family inet { address 192.168.0.1/32; } } }
user@R1# show protocols bgp { group int { type internal; local-address 192.168.0.1; export [ adv-statics adv-large-aggregates adv-small-aggregates ]; neighbor 192.168.0.2; neighbor 192.168.0.3; } group to_64511 { type external; export adv-large-aggregates; neighbor 10.1.0.6 { peer-as 64511; } } group to_64512 { type external; export [ adv-small-aggregates adv-statics ]; neighbor 10.0.0.9 { peer-as 64512; } } } ospf { area 0.0.0.0 { interface fe-1/2/0.0; interface fe-1/2/2.0; interface lo0.0 { passive; } } }
user@R1# show policy-options policy-statement adv-large-aggregates { term between-16-and-18 { from { protocol aggregate; route-filter 172.16.0.0/16 upto /18; } then accept; } } policy-statement adv-small-aggregates { term between-19-and-24 { from { protocol aggregate; route-filter 172.16.0.0/16 prefix-length-range /19-/24; } then accept; } } policy-statement adv-statics { term statics { from protocol static; then accept; } }
user@R1# show routing-options static { route 172.16.1.16/28 discard; route 172.16.1.32/28 discard; route 172.16.1.48/28 discard; route 172.16.1.64/28 discard; } aggregate { route 172.16.0.0/16; route 172.16.1.0/24; } router-id 192.168.0.1; autonomous-system 64510;
Wenn Sie mit der Konfiguration des Geräts fertig sind, rufen Sie den Konfigurationsmodus auf .commit
Überprüfung
Vergewissern Sie sich, dass die Konfiguration ordnungsgemäß funktioniert.
- Überprüfen der Routenankündigung auf Gerät R4
- Überprüfen, woher die längeren Routen stammen
- Blockieren der spezifischeren Routen
- Überprüfen der Routenankündigung für Gerät R5
Überprüfen der Routenankündigung auf Gerät R4
Zweck
Stellen Sie auf Gerät R1 sicher, dass die Kundenrouten Gerät R4 angekündigt werden.
Was
user@R1> show route advertising-protocol bgp 10.1.0.6 inet.0: 29 destinations, 31 routes (29 active, 0 holddown, 0 hidden) Prefix Nexthop MED Lclpref AS path * 172.16.0.0/16 Self I * 172.16.2.0/24 Self I * 172.16.2.16/28 Self I * 172.16.2.32/28 Self I * 172.16.2.48/28 Self I * 172.16.2.64/28 Self I * 172.16.3.0/24 Self I * 172.16.3.16/28 Self I * 172.16.3.32/28 Self I * 172.16.3.48/28 Self I * 172.16.3.64/28 Self I
Bedeutung
Die Richtlinie wird auf die Peering-Sitzung mit Gerät R4 angewendet, um die aggregierten Routen mit einer Subnetzmaskenlänge zwischen 16 und 18 Bit anzukündigen.adv-large-aggregates
Die aggregierte Route 172.16.0.0/16 wird wie in der Verwaltungsrichtlinie definiert gesendet, aber eine Reihe anderer Routen mit größeren Subnetzmasken werden ebenfalls an Gerät R4 gesendet.
Überprüfen, woher die längeren Routen stammen
Zweck
Finden Sie auf Gerät R1 heraus, woher die anderen Routen kommen.
Was
user@R1> show route 172.16.3.16/28 inet.0: 29 destinations, 31 routes (29 active, 0 holddown, 0 hidden) + = Active Route, - = Last Active, * = Both 172.16.3.16/28 *[BGP/170] 20:16:00, localpref 100, from 192.168.0.3 AS path: I, validation-state: unverified > to 10.0.0.6 via fe-1/2/2.0
Bedeutung
Gerät R1 hat diesen Weg durch seine BGP-Sitzung mit Gerät R3 gelernt. Da es sich um eine aktive BGP-Route handelt, wird sie automatisch von der BGP-Standardrichtlinie angekündigt. Denken Sie daran, dass die Standardrichtlinie immer am Ende jeder Richtlinienkette angewendet wird. Was wir brauchen, ist eine Richtlinie, die die Werbung für die spezifischeren Routen verhindert.
Blockieren der spezifischeren Routen
Zweck
Erstellen Sie eine Richtlinie mit dem Namen , die alle Routen innerhalb des Adressraums 172.16.0.0 /16 ablehnt, deren Subnetzmaskenlänge mindestens 19 Bit beträgt.not-larger-than-18
Dadurch wird sichergestellt, dass alle Aggregate mit einer Maske zwischen 16 und 18 Bit angekündigt werden, wodurch das Ziel der Verwaltungsrichtlinie erreicht wird.
Was
Konfigurieren Sie auf Gerät R1 die Richtlinie.
not-larger-than-18
[edit policy-options policy-statement not-larger-than-18 term reject-greater-than-18-bits] user@R1# set from route-filter 172.16.0.0/16 prefix-length-range /19-/32 user@R1# set then reject
Wenden Sie die Richtlinie auf Gerät R1 auf die Peeringsitzung mit Gerät R4 an.
[edit protocols bgp group to_64511] user@R1# set export not-larger-than-18 user@R1# commit
Überprüfen Sie auf Gerät R1, welche Routen für Gerät R4 angekündigt werden.
user@R1> show route advertising-protocol bgp 10.1.0.6 inet.0: 29 destinations, 31 routes (29 active, 0 holddown, 0 hidden) Prefix Nexthop MED Lclpref AS path * 172.16.0.0/16 Self I
Bedeutung
Die Richtlinienkette funktioniert ordnungsgemäß. Nur die Route 172.16.0.0 /16 wird Gerät R4 angekündigt.
Überprüfen der Routenankündigung für Gerät R5
Zweck
Stellen Sie auf Gerät R1 sicher, dass die Kundenrouten Gerät R5 angekündigt werden.
Gerät R5 ist der EBGP-Peer von Gerät R1 in AS 64512. Die Verwaltungsrichtlinie besagt, dass dieser Peer nur aggregierte Routen mit einer Länge von mehr als 18 Bit und alle Kundenrouten empfängt. In Erwartung eines ähnlichen Problems wie auf Gerät R4 können Sie eine Richtlinie namens erstellen, die alle Aggregate mit Maskenlängen zwischen 16 und 18 Bit ablehnt.not-smaller- than-18
Was
Konfigurieren Sie auf Gerät R2 eine aggregierte Route für 172.16.128.0/17.
[edit routing-options aggregate] user@R2# set route 172.16.128.0/17 discard user@R2# commit
Überprüfen Sie auf Gerät R1, welche Routen für Gerät R5 angekündigt werden.
user@R1> show route advertising-protocol bgp 10.0.0.9 inet.0: 30 destinations, 32 routes (30 active, 0 holddown, 0 hidden) Prefix Nexthop MED Lclpref AS path * 172.16.1.0/24 Self I * 172.16.1.16/28 Self I * 172.16.1.32/28 Self I * 172.16.1.48/28 Self I * 172.16.1.64/28 Self I * 172.16.2.0/24 Self I * 172.16.2.16/28 Self I * 172.16.2.32/28 Self I * 172.16.2.48/28 Self I * 172.16.2.64/28 Self I * 172.16.3.0/24 Self I * 172.16.3.16/28 Self I * 172.16.3.32/28 Self I * 172.16.3.48/28 Self I * 172.16.3.64/28 Self I * 172.16.128.0/17 Self I
Die Gesamtroute 172.16.128.0/17 wird unter Verstoß gegen die Verwaltungsrichtlinien beworben
Konfigurieren Sie auf Gerät R1 die Richtlinie.
not-smaller-than-18
[edit policy-options policy-statement not-smaller-than-18 term reject-less-than-18-bits] user@R1# set from protocol aggregate user@R1# set from route-filter 172.16.0.0/16 upto /18 user@R1# set then reject
Wenden Sie die Richtlinie auf Gerät R1 auf die Peeringsitzung mit Gerät R5 an.
[edit protocols bgp group to_64512] user@R1# set export not-smaller-than-18 user@R1# commit
Überprüfen Sie auf Gerät R1, welche Routen für Gerät R5 angekündigt werden.
user@R1> show route advertising-protocol bgp 10.0.0.9 inet.0: 29 destinations, 31 routes (29 active, 0 holddown, 0 hidden) Prefix Nexthop MED Lclpref AS path * 172.16.1.0/24 Self I * 172.16.1.16/28 Self I * 172.16.1.32/28 Self I * 172.16.1.48/28 Self I * 172.16.1.64/28 Self I * 172.16.2.0/24 Self I * 172.16.2.16/28 Self I * 172.16.2.32/28 Self I * 172.16.2.48/28 Self I * 172.16.2.64/28 Self I * 172.16.3.0/24 Self I * 172.16.3.16/28 Self I * 172.16.3.32/28 Self I * 172.16.3.48/28 Self I * 172.16.3.64/28 Self I
Bedeutung
Die Richtlinienkette funktioniert ordnungsgemäß. Nur aggregierte Routen mit einer Länge von mehr als 18 Bit und alle Kundenrouten werden dem Gerät R5 angekündigt.