예: BGP 계층의 다른 수준에서 라우팅 정책 적용
이 예는 간단한 네트워크 토폴로지에서 구성된 BGP를 보여주고 라우팅 정책이 BGP 구성의 다른 수준에서 적용될 때 어떻게 효과를 발휘하는지 설명합니다.
요구 사항
이 예를 구성하기 전에 디바이스 초기화를 제외한 특별한 구성은 필요하지 않습니다.
개요
BGP의 경우, 다음과 같이 정책을 적용할 수 있습니다:
BGP 글로벌
import
및export
문—[edit protocols bgp]
계층 수준에 이러한 문들을 포함합니다(라우팅 인스턴스의 경우,[edit routing-instances routing-instance-name protocols bgp]
계층 수준에 이러한 문들을 포함).그룹
import
및export
문—[edit protocols bgp group group-name]
·계층 수준에 이러한 문들을 포함합니다(라우팅 인스턴스의 경우,[edit routing-instances routing-instance-name protocols bgp group group-name]
계층 수준에 이러한 문들을 포함).피어
import
및export
문—[edit protocols bgp group group-name neighbor address]
계층 수준에 이러한 문들을 포함합니다(라우팅 인스턴스의 경우,[edit routing-instances routing-instance-name protocols bgp group group-name neighbor address]
계층 수준에 이러한 문들을 포함).
peer-level·import
또는 export
문은 그룹 import
또는 export
문보다 우선합니다. group-level import
또는 export
문은 글로벌 BGP import
또는 export
문보다 우선합니다.
이 예에서는 send-direct
라는 정책이 글로벌 수준에 적용되고, send-192.168.0.1
라는 또 다른 정책이 그룹 수준에 적용되며, send-192.168.20.1
라는 세 번째 정책이 neighbor 수준에서 적용됩니다.
user@host# show protocols bgp { local-address 172.16.1.1; export send-direct; group internal-peers { type internal; export send-192.168.0.1; neighbor 172.16.2.2 { export send-192.168.20.1; } neighbor 172.16.3.3; } group other-group { type internal; neighbor 172.16.4.4; } }
종종 잘못 이해되고 문제를 일으킬 수 있는 키 포인트는 이런 구성에서는 가장 명시적인 정책만 적용된다는 점입니다. neighbor 수준 정책은 그룹 수준 정책보다 더 명시적이며, 결과적으로 글로벌 정책보다도 더 명시적입니다.
neighbor 172.16.2.2는 send-192.168.20.1 정책의 적용만 받습니다. 더 구체적인 것이 없는 neighbor 172.16.3.3은 send-192.168.0.1 정책의 적용만 받습니다. 한편, 그룹 other-group의 neighbor 172.16.4.4는 그룹 또는 아웃 수준 정책이 없으므로 send-direct 정책을 사용합니다.
neighbor 172.16.2.2가 세 정책 모두의 기능을 수행해야 하는 경우, 다른 세 개의 기능을 포함하는 새로운 neighbor 수준 정책을 작성하고 적용하거나 기존 세 개의 정책을 모두 체인으로 neighbor 172.16.2.2에 적용할 수 있습니다.
토폴로지
그림 1은 샘플 네트워크를 표시합니다.

CLI 빠른 구성은(는) 그림 1 내 모든 디바이스의 구성을 보여줍니다.
섹션 #configuration__policy-bgp-apply-levels-st은 디바이스 R1의 단계를 설명합니다.
구성
CLI 빠른 구성
이 예를 빠르게 구성하려면, 아래 명령을 복사하여 텍스트 파일로 붙여 넣은 다음 모든 라인브레이크를 제거하고, 네트워크 구성을 일치하는 데 필요한 세부 사항을 바꾸고 [edit]
계층 수준에서 명령을 CLI로 복사해 붙여 넣습니다.
디바이스 R1
set interfaces fe-1/2/0 unit 0 description to-R2 set interfaces fe-1/2/0 unit 0 family inet address 10.10.10.1/30 set interfaces lo0 unit 0 family inet address 172.16.1.1/32 set protocols bgp local-address 172.16.1.1 set protocols bgp export send-direct set protocols bgp group internal-peers type internal set protocols bgp group internal-peers export send-static-192.168.0 set protocols bgp group internal-peers neighbor 172.16.2.2 export send-static-192.168.20 set protocols bgp group internal-peers neighbor 172.16.3.3 set protocols bgp group other-group type internal set protocols bgp group other-group neighbor 172.16.4.4 set protocols ospf area 0.0.0.0 interface lo0.0 passive set protocols ospf area 0.0.0.0 interface fe-1/2/0.0 set policy-options policy-statement send-direct term 1 from protocol direct set policy-options policy-statement send-direct term 1 then accept set policy-options policy-statement send-static-192.168.0 term 1 from protocol static set policy-options policy-statement send-static-192.168.0 term 1 from route-filter 192.168.0.0/24 orlonger set policy-options policy-statement send-static-192.168.0 term 1 then accept set policy-options policy-statement send-static-192.168.20 term 1 from protocol static set policy-options policy-statement send-static-192.168.20 term 1 from route-filter 192.168.20.0/24 orlonger set policy-options policy-statement send-static-192.168.20 term 1 then accept set routing-options static route 192.168.0.1/32 discard set routing-options static route 192.168.20.1/32 discard set routing-options router-id 172.16.1.1 set routing-options autonomous-system 17
디바이스 R2
set interfaces fe-1/2/0 unit 0 description to-R1 set interfaces fe-1/2/0 unit 0 family inet address 10.10.10.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.10.10.5/30 set interfaces lo0 unit 0 family inet address 172.16.2.2/32 set protocols bgp group internal-peers type internal set protocols bgp group internal-peers local-address 172.16.2.2 set protocols bgp group internal-peers neighbor 172.16.3.3 set protocols bgp group internal-peers neighbor 172.16.1.1 set protocols bgp group internal-peers neighbor 172.16.4.4 set protocols ospf area 0.0.0.0 interface lo0.0 passive 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 routing-options router-id 172.16.2.2 set routing-options autonomous-system 17
디바이스 R3
set interfaces fe-1/2/1 unit 0 description to-R2 set interfaces fe-1/2/1 unit 0 family inet address 10.10.10.6/30 set interfaces fe-1/2/2 unit 0 description to-R4 set interfaces fe-1/2/2 unit 0 family inet address 10.10.10.9/30 set interfaces lo0 unit 0 family inet address 172.16.3.3/32 set protocols bgp group internal-peers type internal set protocols bgp group internal-peers local-address 172.16.3.3 set protocols bgp group internal-peers neighbor 172.16.2.2 set protocols bgp group internal-peers neighbor 172.16.1.1 set protocols bgp group internal-peers neighbor 172.16.4.4 set protocols ospf area 0.0.0.0 interface lo0.0 passive set protocols ospf area 0.0.0.0 interface fe-1/2/1.0 set protocols ospf area 0.0.0.0 interface fe-1/2/2.0 set routing-options router-id 172.16.3.3 set routing-options autonomous-system 17
디바이스 R4
set interfaces fe-1/2/2 unit 0 description to-R3 set interfaces fe-1/2/2 unit 0 family inet address 10.10.10.10/30 set interfaces lo0 unit 0 family inet address 172.16.4.4/32 set protocols bgp group internal-peers type internal set protocols bgp group internal-peers local-address 172.16.4.4 set protocols bgp group internal-peers neighbor 172.16.2.2 set protocols bgp group internal-peers neighbor 172.16.1.1 set protocols bgp group internal-peers neighbor 172.16.3.3 set protocols ospf area 0.0.0.0 interface lo0.0 passive set protocols ospf area 0.0.0.0 interface fe-1/2/2.0 set routing-options router-id 172.16.4.4 set routing-options autonomous-system 17
절차
단계별 절차
다음 예는 구성 계층에서 다양한 수준의 탐색이 필요합니다. CLI 탐색에 관한 정보는 CLI 사용자 가이드에서 구성 모드에서 CLI 편집기 사용을 참조하십시오.
IS-IS 기본 경로 정책 구성:
디바이스 인터페이스를 구성합니다.
[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.10.10.1/30 user@R1# set lo0 unit 0 family inet address 172.16.1.1/32
인터페이스에서 OSPF 또는 다른 내부 게이트웨이 프로토콜(IGP)을 활성화합니다.
[edit protocols OSPF area 0.0.0.0] user@R1# set interface lo0.0 passive user@R1# set interface fe-1/2/0.0
정적 경로를 구성합니다.
[edit routing-options] user@R1# set static route 192.168.0.1/32 discard user@R1# set static route 192.168.20.1/32 discard
라우팅 정책을 활성화합니다.
[edit protocols policy-options] user@R1# set policy-statement send-direct term 1 from protocol direct user@R1# set policy-statement send-direct term 1 then accept user@R1# set policy-statement send-static-192.168.0 term 1 from protocol static user@R1# set policy-statement send-static-192.168.0 term 1 from route-filter 192.168.0.0/24 orlonger user@R1# set policy-statement send-static-192.168.0 term 1 then accept user@R1# set policy-statement send-static-192.168.20 term 1 from protocol static user@R1# set policy-statement send-static-192.168.20 term 1 from route-filter 192.168.20.0/24 orlonger user@R1# set policy-statement send-static-192.168.20 term 1 then accept
BGP를 구성하고 내보내기 정책을 적용합니다.
[edit protocols bgp] user@R1# set local-address 172.16.1.1 user@R1# set protocols bgp export send-direct user@R1# set group internal-peers type internal user@R1# set group internal-peers export send-static-192.168.0 user@R1# set group internal-peers neighbor 172.16.2.2 export send-static-192.168.20 user@R1# set group internal-peers neighbor 172.16.3.3 user@R1# set group other-group type internal user@R1# set group other-group neighbor 172.16.4.4
라우터 ID 및 AS(Autonomous System) 번호를 구성합니다.
[edit routing-options] user@R1# set router-id 172.16.1.1 user@R1# set autonomous-system 17
디바이스 구성을 완료하면 해당 구성을 커밋합니다.
[edit] user@R1# commit
결과
구성 모드에서 show interfaces
, show protocols
, show policy-options
및 show routing-options
명령을 입력하여 구성을 확인합니다. 출력 결과가 의도한 구성대로 표시되지 않으면 이 예의 지침을 반복하여 구성을 수정하십시오.
user@R1# show interfaces fe-1/2/0 { unit 0 { description to-R2; family inet { address 10.10.10.1/30; } } } lo0 { unit 0 { family inet { address 172.16.1.1/32; } } }
user@R1# show protocols bgp { local-address 172.16.1.1; export send-direct; group internal-peers { type internal; export send-static-192.168.0; neighbor 172.16.2.2 { export send-static-192.168.20; } neighbor 172.16.3.3; } group other-group { type internal; neighbor 172.16.4.4; } } ospf { area 0.0.0.0 { interface lo0.0 { passive; } interface fe-1/2/0.0; } }
user@R1# show policy-options policy-statement send-direct { term 1 { from protocol direct; then accept; } } policy-statement send-static-192.168.0 { term 1 { from { protocol static; route-filter 192.168.0.0/24 orlonger; } then accept; } } policy-statement send-static-192.168.20 { term 1 { from { protocol static; route-filter 192.168.20.0/24 orlonger; } then accept; } }
user@R1# show routing-options static { route 192.168.0.1/32 discard; route 192.168.20.1/32 discard; } router-id 172.16.1.1; autonomous-system 17;
검증
구성이 올바르게 작동하고 있는지 확인합니다.
BGP 경로 학습 확인
목적
라우팅 테이블 검사를 통해 BGP 내보내기 정책이 예상대로 작동하는지 확인합니다.
작업
user@R1> show route protocol direct inet.0: 11 destinations, 11 routes (11 active, 0 holddown, 0 hidden) + = Active Route, - = Last Active, * = Both 172.16.1.1/32 *[Direct/0] 1d 22:19:47 > via lo0.0 10.10.10.0/30 *[Direct/0] 1d 22:19:47 > via fe-1/2/0.0
user@R1> show route protocol static inet.0: 11 destinations, 11 routes (11 active, 0 holddown, 0 hidden) + = Active Route, - = Last Active, * = Both 192.168.0.1/32 *[Static/5] 02:20:03 Discard 192.168.20.1/32 *[Static/5] 02:20:03 Discard
user@R2> show route protocol bgp inet.0: 11 destinations, 11 routes (11 active, 0 holddown, 0 hidden) + = Active Route, - = Last Active, * = Both 192.168.20.1/32 *[BGP/170] 02:02:40, localpref 100, from 172.16.1.1 AS path: I, validation-state: unverified > to 10.10.10.1 via fe-1/2/0.0
user@R3> show route protocol bgp inet.0: 11 destinations, 11 routes (11 active, 0 holddown, 0 hidden) + = Active Route, - = Last Active, * = Both 192.168.0.1/32 *[BGP/170] 02:02:51, localpref 100, from 172.16.1.1 AS path: I, validation-state: unverified > to 10.10.10.5 via fe-1/2/1.0
user@R4> show route protocol bgp inet.0: 9 destinations, 11 routes (9 active, 0 holddown, 0 hidden) + = Active Route, - = Last Active, * = Both 172.16.1.1/32 [BGP/170] 1d 20:38:54, localpref 100, from 172.16.1.1 AS path: I, validation-state: unverified > to 10.10.10.9 via fe-1/2/2.0 10.10.10.0/30 [BGP/170] 1d 20:38:54, localpref 100, from 172.16.1.1 AS path: I, validation-state: unverified > to 10.10.10.9 via fe-1/2/2.0
의미
디바이스 R1에서 show route protocol direct
명령은 두 개의 직접 경로 (172.16.1.1/32 및 10.10.10.0/30)를 표시합니다. show route protocol static
명령은 두 개의 정적 경로 (192.168.0.1/32 및 192.168.20.1/32)를 표시합니다.
디바이스 R2에서 show route protocol bgp
명령은 디바이스 R2가 BGP를 통해 학습한 유일한 경로가 192.168.20.1/32 경로라고 표시합니다.
디바이스 R3에서 show route protocol bgp
명령은 디바이스 R3이 BGP를 통해 학습한 유일한 경로가 192.168.0.1/32 경로라고 표시합니다.
디바이스 R4에서 show route protocol bgp
명령은 디바이스 R4가 BGP를 통해 학습한 유일한 경로가 172.16.1.1/32 및 10.10.10.0/30 경로라고 표시합니다.
BGP 경로 수신 확인
목적
디바이스 R1에서 수신된 BGP 경로를 확인하여 BGP 내보내기 정책이 예상대로 작동하는지 확인합니다.
작업
user@R2> show route receive-protocol bgp 172.16.1.1 inet.0: 11 destinations, 11 routes (11 active, 0 holddown, 0 hidden) Prefix Nexthop MED Lclpref AS path * 192.168.20.1/32 172.16.1.1 100 I
user@R3> show route receive-protocol bgp 172.16.1.1 inet.0: 11 destinations, 11 routes (11 active, 0 holddown, 0 hidden) Prefix Nexthop MED Lclpref AS path * 192.168.0.1/32 172.16.1.1 100 I
user@R4> show route receive-protocol bgp 172.16.1.1 inet.0: 9 destinations, 11 routes (9 active, 0 holddown, 0 hidden) Prefix Nexthop MED Lclpref AS path 172.16.1.1/32 172.16.1.1 100 I 10.10.10.0/30 172.16.1.1 100 I
의미
디바이스 R2에서 route receive-protocol bgp 172.16.1.1
명령은 디바이스 R2가 디바이스 R1에서 단 하나의 BGP 경로인 192.168.20.1/32를 수신한 것을 보여줍니다.
디바이스 R3에서 route receive-protocol bgp 172.16.1.1
명령은 디바이스 R3이 디바이스 R1에서 단 하나의 BGP 경로인 192.168.0.1/32를 수신한 것을 보여줍니다.
디바이스 R4에서 route receive-protocol bgp 172.16.1.1
명령은 디바이스 R4가 디바이스 R1에서 두 개의 BGP 경로인 172.16.1.1/32 및 10.10.10.0/30을 수신한 것을 보여줍니다.
요약하자면, BGP에서 다른 CLI 계층에 여러 정책이 적용되면, 가장 구체적인 애플리케이션만 평가되며 다른 덜 구체적인 정책 애플리케이션은 제외됩니다. 이 부분은 이해되는 것처럼 보이지만 라우터 구성 중 쉽게 잊게 되며, neighbor 수준 정책이 글로벌 또는 그룹 수준 정책과 결합된다고 잘못 믿게 되면 정책 동작이 예상대로 이루어지지 않습니다.