예를 들면 다음과 같습니다. 정책 서브루틴 구성
이 예는 라우팅 정책 일치 조건에서 정책 서브루틴의 사용을 보여줍니다.
요구 사항
이 예를 구성하기 전에 디바이스 초기화를 제외한 특별한 구성은 필요하지 않습니다.
개요
디바이스 R1에서 라는 main
정책이 구성됩니다.
user@R1# show policy-options policy-statement main { term subroutine-as-a-match { from policy subroutine; then accept; } term nothing-else { then reject; } }
이 주요 정책은 라는 서브루틴을 호출 subroutine
합니다.
user@R1# show policy-options policy-statement subroutine { term get-routes { from protocol static; then accept; } term nothing-else { then reject; } }
라우터는 정의된 방식으로 의 main
논리를 평가합니다. 의 from policy subroutine
일치 기준을 사용하면 라우팅 디바이스가 서브루틴을 찾을 수 있습니다. 서브루틴의 모든 약관은 일반적인 정책 처리 규칙을 따라 순서대로 평가됩니다. 이 예에서 라우팅 테이블 모든 정적 경로는 서브루틴과 수락 작업과 일치합니다. 이렇게 하면 디바이스에 긍정적인 일치가 발생했음을 알리는 원래 또는 호출 정책에 대한 진정한 결과를 반환합니다. 호출 정책의 작업이 실행되고 경로가 수락됩니다. 라우팅 테이블 다른 모든 경로는 서브루틴과 일치하지 않고 잘못된 결과를 호출 정책에 반환합니다. 디바이스는 경로의 main
두 번째 용어를 평가하고 경로를 거부합니다.
서브루틴의 동작은 실제로 특정 경로를 수락하거나 거부하지 않습니다. 서브루틴 작업은 true 또는 false 결과로만 변환됩니다. 그러나 경로의 속성을 수정하는 작업은 서브루틴의 결과와 관계없이 경로에 적용됩니다.
AS 64510의 디바이스 R1에는 여러 고객 경로가 있으며, 그 중 일부는 로컬로 구성된 정적 경로이며, 그 중 일부는 디바이스 R2 및 디바이스 R3에서 내부 BGP(IBGP)를 통해 수신됩니다. AS 64510은 AS 64511에서 디바이스 R4에 연결되어 있습니다. 이 정책은 main
디바이스 R1의 디바이스 R4와의 BGP 피어링 세션에서 내보내기 정책으로 적용됩니다. 이로 인해 디바이스 R1은 자체 정적 경로만 디바이스 R4로 보냅니다. 정책 main
으로 인해 디바이스 R1은 내부 피어인 디바이스 R2 및 디바이스 R3에서 수신한 경로를 보내지 않습니다.
정책 하위 라우팅을 사용할 때는 기본 EBGP 내보내기 정책은 학습한 모든 BGP 경로를 모든 EBGP 피어에 보급하는 것입니다. 이 기본 정책은 기본 정책과 서브루틴에서도 적용됩니다. 따라서 이 예에 표시된 대로, 기본 EBGP 내보내기 정책이 적용되지 않도록 하려면 기본 정책과 정책 서브루틴 모두에서 최종 용어로 종료 작업을 구성 then reject
해야 합니다. 이 예는 기본 정책 또는 정책 서브루틴에서 최종 then reject
용어가 누락되면 어떤 일이 발생하는지 보여줍니다.
토폴로지
그림 1 은 샘플 네트워크를 보여줍니다.

CLI 빠른 구성 은(는) 의 모든 디바이스 그림 1에 대한 구성을 보여줍니다.
섹션 #configuration318__policy-subroutine-st 은 디바이스 R1의 단계를 설명합니다.
구성
CLI 빠른 구성
이 예를 빠르게 구성하려면, 아래 명령을 복사하여 텍스트 파일로 붙여 넣은 다음 모든 라인브러브를 제거하고, 네트워크 구성을 일치하는 데 필요한 세부 사항을 변경한 다음 계층 수준에서 명령을 CLI [edit]
로 복사해 붙여 넣습니다.
디바이스 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 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 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 main set protocols bgp group to_64511 neighbor 10.1.0.6 peer-as 64511 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 main term subroutine-as-a-match from policy subroutine set policy-options policy-statement main term subroutine-as-a-match then accept set policy-options policy-statement main term nothing-else then reject set policy-options policy-statement subroutine term get-routes from protocol static set policy-options policy-statement subroutine term get-routes then accept set policy-options policy-statement subroutine term nothing-else then reject 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 router-id 192.168.0.1 set routing-options autonomous-system 64510
디바이스 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 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 term 1 from protocol static set policy-options policy-statement send-static 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 router-id 192.168.0.2 set routing-options autonomous-system 64510
디바이스 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 set protocols bgp group int neighbor 192.168.0.2 set protocols ospf area 0.0.0.0 interface fe-1/2/2.6 set protocols ospf area 0.0.0.0 interface fe-1/2/0.4 set protocols ospf area 0.0.0.0 interface lo0.0 passive set policy-options policy-statement send-static from protocol static set policy-options policy-statement send-static 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 router-id 192.168.0.3 set routing-options autonomous-system 64510
디바이스 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
절차
단계별 절차
다음 예는 구성 계층에서 다양한 수준의 탐색이 필요합니다. CLI 탐색에 대한 정보는 Junos OS CLI 사용자 가이드에서 을(를) 참조하십시오구성 모드에서 CLI 편집기 사용.
디바이스 R1 구성:
디바이스 인터페이스를 구성합니다.
[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 lo0 unit 0 family inet address 192.168.0.1/32
디바이스 R2 및 디바이스 R3에 대한 내부 BGP(IBGP) 연결을 구성합니다.
[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
디바이스 R4에 대한 EBGP 연결을 구성합니다.
[edit protocols bgp group to_64511] user@R1# set type external user@R1# set export main user@R1# set neighbor 10.1.0.6 peer-as 64511
디바이스 R2 및 디바이스 R3에 대한 OSPF 연결을 구성합니다.
[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
정책
main
을(를) 구성합니다.[edit policy-options policy-statement main term subroutine-as-a-match] user@R1# set from policy subroutine user@R1# set then accept [edit policy-options policy-statement main term nothing-else] user@R1# set then reject
정책
subroutine
을(를) 구성합니다.[edit policy-options policy-statement subroutine term get-routes] user@R1# set from protocol static user@R1# set then accept [edit policy-options policy-statement subroutine term nothing-else] user@R1# set then reject
172.16.5.0/24 네트워크에 대한 정적 경로를 구성합니다.
[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
AS(Autonomous System) 번호와 라우터 ID를 구성합니다.
[edit routing-options] user@R1# set router-id 192.168.0.1 user@R1# set autonomous-system 64510
결과
구성 모드에서 , , show protocols
show policy-options
및 show routing-options
명령을 입력show interfaces
하여 구성을 확인합니다. 출력에 의도한 구성이 표시되지 않으면 이 예의 지침을 반복하여 구성을 수정합니다.
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; } } } 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; neighbor 192.168.0.2; neighbor 192.168.0.3; } group to_64511 { type external; export main; neighbor 10.1.0.6 { peer-as 64511; } } } 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 main { term subroutine-as-a-match { from policy subroutine; then accept; } term nothing-else { then reject; } } policy-statement subroutine { term get-routes { from protocol static; then accept; } term nothing-else { then reject; } }
user@R1# show routing-options static { route 172.6.1.16/28 discard; route 172.6.1.32/28 discard; route 172.6.1.48/28 discard; route 172.6.1.64/28 discard; } router-id 192.168.0.1; autonomous-system 64510;
디바이스 구성이 완료되면 구성 모드에서 을(를) 입력합니다 commit
.
확인
구성이 제대로 작동하는지 확인합니다.
디바이스 R1에서 경로 확인
목적
디바이스 R1에서 라우팅 테이블 정적 경로를 확인합니다.
실행
user@R1> show route protocol static inet.0: 23 destinations, 23 routes (23 active, 0 holddown, 0 hidden) + = Active Route, - = Last Active, * = Both 172.16.1.16/28 *[Static/5] 1d 02:02:13 Discard 172.16.1.32/28 *[Static/5] 1d 02:02:13 Discard 172.16.1.48/28 *[Static/5] 1d 02:02:13 Discard 172.16.1.64/28 *[Static/5] 1d 02:02:13 Discard
의미
디바이스 R1에는 4개의 정적 경로가 있습니다.
디바이스 R4에 대한 경로 보급 확인
목적
디바이스 R1에서 정적 경로가 디바이스 R4에 보급되는지 확인합니다.
실행
user@R1> show route advertising-protocol bgp 10.1.0.6 inet.0: 23 destinations, 23 routes (23 active, 0 holddown, 0 hidden) Prefix Nexthop MED Lclpref AS path * 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
의미
예상대로 디바이스 R1은 디바이스 R4에 정적 경로만 보급합니다.
기본 BGP 내보내기 정책 실험
목적
정책 또는 정책 main
subroutine
에서 마지막 then reject
용어를 제거하면 어떤 일이 발생할 수 있는지 확인합니다.
실행
디바이스 R1에서 정책
main
의 마지막 용어를 비활성화합니다.[edit policy-options policy-statement main] user@R1# deactivate term nothing-else user@R1# commit
디바이스 R1에서 디바이스 R4에 보급되는 경로를 확인합니다.
user@R1> show route advertising-protocol bgp 10.1.0.6 inet.0: 23 destinations, 23 routes (23 active, 0 holddown, 0 hidden) Prefix Nexthop MED Lclpref AS path * 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.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.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
이제 디바이스 R1의 모든 BGP 경로가 디바이스 R4로 전송됩니다. 처리가 정책
main
으로 반환된 후 기본 BGP 내보내기 정책이 효력을 발휘하기 때문입니다.디바이스 R1에서 정책의 마지막 용어를 다시 활성화하고 정책
main
subroutine
의 마지막 용어를 비활성화합니다.[edit policy-options policy-statement main] user@R1# activate term nothing-else [edit policy-options policy-statement subroutine] user@R1# deactivate term nothing-else user@R1# commit
디바이스 R1에서 디바이스 R4에 보급되는 경로를 확인합니다.
user@R1> show route advertising-protocol bgp 10.1.0.6 inet.0: 23 destinations, 23 routes (23 active, 0 holddown, 0 hidden) Prefix Nexthop MED Lclpref AS path * 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.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.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
이제 디바이스 R1의 모든 BGP 경로가 디바이스 R4로 전송됩니다. 처리가 정책
main
으로 반환되기 전에 기본 BGP 내보내기 정책이 정책에subroutine
적용되기 때문입니다.
의미
기본 BGP 내보내기 정책이 적용되지 않도록 하려면 기본 정책 및 참조된 모든 하위 경로에 최종 then reject
용어를 포함해야 합니다.