예: 라우팅 정책을 사용하여 BGP 경로에 대한 기본 설정 값 지정
이 예에서는 라우팅 정책을 사용하여 BGP에서 학습된 경로에 대한 기본 설정을 지정하는 방법을 보여 줍니다. 라우팅 정보는 여러 소스에서 학습할 수 있습니다. 여러 소스에서 학습된 동등하게 특정한 경로 간의 연결을 끊기 위해 각 소스에는 선호 값이 있습니다. 정적 경로와 같은 명시적 관리 작업을 통해 학습된 경로는 BGP 또는 OSPF와 같은 라우팅 프로토콜에서 학습한 경로보다 선호됩니다. 일부 공급업체에서는 이 개념을 관리 거리 라고 합니다.
요구 사항
이 예제를 구성하기 전에 디바이스 초기화 이외의 특별한 구성은 필요하지 않습니다.
개요
라우팅 정보는 정적 구성, BGP 또는 IGP(Interior Gateway Protocol) 등을 통해 여러 소스에서 학습할 수 있습니다. Junos OS가 경로의 기본 설정을 활성 경로로 결정할 때, 가장 낮은 선호도를 가진 경로를 활성 경로로 선택하고 이 경로를 포워딩 테이블에 설치합니다. 기본적으로 라우팅 소프트웨어는 BGP에서 시작된 경로에 기본 설정 170을 할당합니다. 모든 라우팅 프로토콜 중에서 BGP의 기본 선호 값이 가장 높으며, 이는 BGP에서 학습한 경로가 활성 경로가 될 가능성이 가장 낮다는 것을 의미합니다.
일부 벤더는 외부 BGP(EBGP)에 대해 20, 내부 BGP(IGBP)에 대해 200의 선호도(거리)를 가지고 있습니다. Junos OS는 EBGP와 IBGP 모두에 동일한 값(170)을 사용합니다. 그러나 Junos OS는 항상 IBGP 경로보다 EBGP 경로를 선호하기 때문에 벤더 간의 이러한 차이는 운영에 영향을 미치지 않습니다.
공급업체가 다른 또 다른 영역은 BGP 거리와 비교한 IGP 거리입니다. 예를 들어, 일부 벤더는 OSPF 경로에 110의 거리를 할당합니다. 이는 EBGP 거리 20보다 높으며, 동등한 OSPF 경로를 통해 EBGP 경로를 선택하게 됩니다. 동일한 시나리오에서 Junos OS는 내부 OSPF 경로에 대한 기본 선호 10과 외부 OSPF 경로에 대한 기본 선호 150 때문에 OSPF 경로를 선택하며, 이는 모두 모든 BGP 경로에 할당된 기본 설정인 170보다 낮습니다.
이 예에서는 특정 다음 홉의 경로를 일치시키고 기본 설정을 지정하는 라우팅 정책을 보여 줍니다. 경로가 첫 번째 용어와 일치하지 않으면 두 번째 용어로 평가됩니다.
토폴로지
샘플 네트워크에서 디바이스 R1 및 디바이스 R3은 디바이스 R2와 EBGP 세션을 갖습니다.
디바이스 R2에서 가져오기 정책은 다음 작업을 수행합니다.
다음 홉 10.0.0.1(디바이스 R1)에서 BGP를 통해 수신된 경로의 경우 경로 기본 설정을 10으로 설정합니다.
다음 홉 10.1.0.2(디바이스 R3)에서 BGP를 통해 수신된 경로의 경우 경로 기본 설정을 15로 설정합니다.
그림 1은 샘플 네트워크를 표시합니다.

CLI 빠른 구성은(는) 그림 1 내 모든 디바이스의 구성을 보여줍니다.
섹션 #configuration178__bgp-preference-policy-st은 디바이스 R2의 단계를 설명합니다.
구성
CLI 빠른 구성
이 예를 빠르게 구성하려면, 아래 명령을 복사하여 텍스트 파일로 붙여 넣은 다음 모든 라인브레이크를 제거하고, 네트워크 구성을 일치하는 데 필요한 세부 사항을 바꾸고 [edit]
계층 수준에서 명령을 CLI로 복사해 붙여 넣습니다.
디바이스 R1
set interfaces fe-1/2/0 unit 0 family inet address 10.0.0.1/30 set interfaces lo0 unit 0 family inet address 192.168.0.1/32 set protocols bgp group ext type external set protocols bgp group ext export send-direct set protocols bgp group ext peer-as 200 set protocols bgp group ext neighbor 10.0.0.2 set policy-options policy-statement send-direct term 1 from protocol direct set policy-options policy-statement send-direct term 1 then accept set routing-options autonomous-system 100
디바이스 R2
set interfaces fe-1/2/0 unit 0 family inet address 10.0.0.2/30 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 ext type external set protocols bgp group ext import set-preference set protocols bgp group ext export send-direct set protocols bgp group ext neighbor 10.0.0.1 peer-as 100 set protocols bgp group ext neighbor 10.1.0.2 peer-as 300 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 set-preference term term1 from protocol bgp set policy-options policy-statement set-preference term term1 from next-hop 10.0.0.1 set policy-options policy-statement set-preference term term1 then preference 10 set policy-options policy-statement set-preference term term2 from protocol bgp set policy-options policy-statement set-preference term term2 from next-hop 10.1.0.2 set policy-options policy-statement set-preference term term2 then preference 15 set routing-options autonomous-system 200
디바이스 R3
set interfaces fe-1/2/1 unit 0 family inet address 10.1.0.2/30 set interfaces lo0 unit 0 family inet address 192.168.0.3/32 set protocols bgp group ext type external set protocols bgp group ext export send-direct set protocols bgp group ext peer-as 200 set protocols bgp group ext neighbor 10.1.0.1 set policy-options policy-statement send-direct term 1 from protocol direct set policy-options policy-statement send-direct term 1 then accept set routing-options autonomous-system 300
절차
단계별 절차
다음 예는 구성 계층에서 다양한 수준의 탐색이 필요합니다. CLI 탐색 관련 정보는 Junos OS CLI 사용자 가이드의 구성 모드에서의 CLI 편집기 사용을 참조하십시오.
디바이스 R2 구성:
디바이스 인터페이스를 구성합니다.
[edit interfaces] user@R2# set fe-1/2/0 unit 0 family inet address 10.0.0.2/30 user@R2# set fe-1/2/1 unit 0 family inet address 10.1.0.1/30 user@R2# set lo0 unit 0 family inet address 192.168.0.2/32
로컬 AS(Autonomous System)를 구성합니다.
[edit routing-options] user@R2# set autonomous-system 200
직접 경로를 전송하는 라우팅 정책을 구성합니다.
[edit policy-options policy-statement send-direct term 1] user@R2# set from protocol direct user@R2# set then accept
수신된 경로의 기본 설정을 변경하는 라우팅 정책을 구성합니다.
[edit policy-options policy-statement set-preference] user@R2# set term term1 from protocol bgp user@R2# set term term1 from next-hop 10.0.0.1 user@R2# set term term1 then preference 10 user@R2# set term term2 from protocol bgp user@R2# set term term2 from next-hop 10.1.0.2 user@R2# set term term2 then preference 15
디바이스 R2와의 외부 피어링을 구성합니다.
[edit protocols bgp group ext] user@R2# set type external user@R2# set export send-direct user@R2# set neighbor 10.0.0.1 peer-as 100 user@R2# set neighbor 10.1.0.2 peer-as 300
set-preference
정책을 가져오기 정책으로 적용합니다.이는 디바이스 R2의 라우팅 테이블에 영향을 미치며 디바이스 R1 및 디바이스 R3에는 영향을 미치지 않습니다.
[edit protocols bgp group ext] user@R2# set import set-preference
결과
구성 모드에서 show interfaces
, show protocols
, show policy-options
및 show routing-options
명령을 입력하여 구성을 확인합니다. 출력 결과가 의도한 구성대로 표시되지 않으면 이 예의 지침을 반복하여 구성을 수정하십시오.
user@R2# show interfaces fe-1/2/0 { unit 0 { family inet { address 10.0.0.2/30; } } } fe-1/2/1 { unit 0 { family inet { address 10.1.0.1/30; } } } lo0 { unit 0{ family inet { address 192.168.0.2/32; } } }
user@R2# show protocols bgp { group ext { type external; import set-preference; export send-direct; neighbor 10.0.0.1 { peer-as 100; } neighbor 10.1.0.2 { peer-as 300; } } }
user@R2# show policy-options policy-statement send-direct { term 1 { from protocol direct; then accept; } } policy-statement set-preference { term term1 { from { protocol bgp; next-hop 10.0.0.1; } then { preference 10; } } term term2 { from { protocol bgp; next-hop 10.1.0.2; } then { preference 15; } } }
user@R2# show routing-options autonomous-system 200;
디바이스 구성을 마쳤으면 구성 모드에서 commit
을(를) 입력합니다.
검증
구성이 올바르게 작동하고 있는지 확인합니다.
기본 설정 확인
목적
디바이스 R1 및 디바이스 R2의 라우팅 테이블이 디바이스 R1이 구성된 EBGP 기본 설정 8을 사용하고 디바이스 R2가 기본 EBGP 기본 설정 170을 사용한다는 사실을 반영하는지 확인합니다.
작업
운영 모드에서 show route protocols bgp
명령을 입력합니다.
user@R2> show route protocols bgp inet.0: 7 destinations, 9 routes (7 active, 0 holddown, 0 hidden) + = Active Route, - = Last Active, * = Both 10.0.0.0/30 [BGP/10] 04:42:23, localpref 100 AS path: 100 I, validation-state: unverified > to 10.0.0.1 via fe-1/2/0.0 10.1.0.0/30 [BGP/15] 04:42:23, localpref 100 AS path: 300 I, validation-state: unverified > to 10.1.0.2 via fe-1/2/1.0 192.168.0.1/32 *[BGP/10] 04:42:23, localpref 100 AS path: 100 I, validation-state: unverified > to 10.0.0.1 via fe-1/2/0.0 192.168.0.3/32 *[BGP/15] 04:42:23, localpref 100 AS path: 300 I, validation-state: unverified > to 10.1.0.2 via fe-1/2/1.0
의미
출력 결과, 디바이스 R2에서 디바이스 R3에서 학습한 경로에 대한 선호 값이 15로 변경되었고, 디바이스 R1에서 학습된 경로에 대한 선호 값이 10으로 변경되었음을 보여줍니다.