예: AS 경로 접두에 대한 라우팅 정책 구성
이 예는 BGP에 의해 보급되는 특정 경로에서 AS 경로 앞에 추가하도록 라우팅 정책을 구성하는 방법을 보여줍니다.
요구 사항
시작하기 전에 라우터 인터페이스와 프로토콜이 올바르게 구성되었는지 확인하십시오. 이 문서에 사용된 인터페이스 및 BGP 프로토콜 구성을 제공합니다.
이 예는 Junos 릴리스 22.1R1에서 업데이트 및 재검증되었습니다.
개요
이 예에서는 라는 prependpolicy1 라우팅 정책과 라는 용어 prependterm1를 생성합니다. 라우팅 정책은 마스크 길이가 지정된 마스크와 같거나 긴 경우 172.16.0.0/12, 192.168.0.0/16, 10.0.0.0/8 접두사와 일치하는 경로에 AS 번호 65001을 세 번 추가합니다. 그 결과 경로의 마스크 길이가 지정된 네트워크 마스크와 같거나 길 때 일치가 발생합니다. 이 prependpolicy1 정책은 AS 65001의 R1에서 AS 번호 65000의 R2로 보급되는 BGP 경로에 대한 내보내기 정책으로 적용됩니다. 지정된 접두사 범위와 일치하지 않는 경로는 AS 경로 접두가 발생하지 않습니다.
토폴로지
토폴로지에서 EBGP 피어링은 R1과 R2 사이에 구성됩니다. 10.1.23.0/24 서브넷 주소에 대한 직접 인터페이스 피어링이 사용됩니다. R1은 AS 번호 65001에 속하며, R2에 보급될 때 일치하는 특정 경로 집합에 AS 번호를 추가하도록 구성됩니다.
AS 경로에 AS 번호를 추가하면 경로가 포워딩을 위해 선택될 가능성이 줄어듭니다. 이는 AS 65001의 소유자가 AS 65000의 운영자로부터 수신하는 수신 트래픽의 양을 줄이기 위해 수행할 수 있습니다.
이 예에서는 내보내기 정책을 통해 AS 경로 앞에 추가하는 것을 보여줍니다. 또한 가져오기 정책을 사용하여 속성 조작을 위한 경로를 일치시킬 수 있습니다. 일반적으로 로컬 AS 번호만 경로 앞에 추가하는 것이 가장 좋습니다. 원격 네트워크에 속하는 AS 번호 앞에 추가하면 예기치 않은 결과가 발생할 수 있습니다.
BGP 경로 선택에 대한 자세한 내용은 BGP 경로 선택 이해를 참조하십시오.
구성
절차
CLI 빠른 구성
이 섹션에서는 R1 디바이스의 구성에 중점을 둡니다. 이 예에 사용된 모든 디바이스의 전체 구성은 부록을 참조하십시오.
이 예제를 빠르게 구성하려면 다음 명령을 복사하여 텍스트 파일에 붙여 넣고 줄 바꿈을 제거한 다음 네트워크 구성과 일치하는 데 필요한 세부 정보를 변경한 다음 명령을 복사하여 [edit] 계층 수준의 CLI에 붙여넣습니다.
이 예에서는 R1에서 사용되지 않는 인터페이스에 세 개의 테스트 접두사를 할당합니다. 네 번째 테스트 접두사가 R1의 루프백 주소에 할당됩니다. 이는 BGP에 보급될 수 있는 4개의 직접 경로를 제공합니다. 주니퍼 정책은 및 route-filter 명령 protocol direct 문의 조합을 사용하여 AS 경로 접두사가 추가되는 접두사를 제어합니다.
set system host-name R1 set interfaces xe-0/0/0:1 unit 0 family inet address 10.1.23.1/24 set interfaces xe-0/0/0:0 unit 0 family inet address 10.255.1.1/30 set interfaces xe-0/0/0:0 unit 0 family inet address 172.16.0.1/24 set interfaces xe-0/0/0:0 unit 0 family inet address 10.200.1.1/24 set interfaces lo0 unit 0 family inet address 192.168.0.1/32 set policy-options policy-statement prependpolicy1 term prependterm1 from protocol direct set policy-options policy-statement prependpolicy1 term prependterm1 from route-filter 172.16.0.0/16 orlonger set policy-options policy-statement prependpolicy1 term prependterm1 from route-filter 192.168.0.0/24 orlonger set policy-options policy-statement prependpolicy1 term prependterm1 from route-filter 10.255.1.0/24 orlonger set policy-options policy-statement prependpolicy1 term prependterm1 then as-path-prepend "65001 65001 65001" set policy-options policy-statement prependpolicy1 term prependterm1 then accept set policy-options policy-statement prependpolicy1 term else from protocol direct set policy-options policy-statement prependpolicy1 term else from route-filter 10.200.0.0/16 orlonger set policy-options policy-statement prependpolicy1 term else then accept set routing-options autonomous-system 65001 set routing-options router-id 192.168.0.1 set protocols bgp group ebgp type external set protocols bgp group ebgp export prependpolicy1 set protocols bgp group ebgp peer-as 65000 set protocols bgp group ebgp neighbor 10.1.23.2
단계별 절차
다음 단계를 수행하려면 구성 계층에서 다양한 수준을 탐색해야 합니다. 자세한 내용은 Junos OS CLI 사용자 가이드의 구성 모드에서 CLI 편집기 사용을 참조하십시오.
특정 경로에 AS 번호를 추가하는 라우팅 정책을 생성하려면 다음을 수행합니다.
-
피어링 및 루프백 인터페이스를 구성합니다.
user@R1# [edit] set interfaces xe-0/0/0:1 unit 0 family inet address 10.1.23.1/24 set interfaces lo0 unit 0 family inet address 192.168.0.1/32
-
AS 번호, RID 및 외부 BGP 피어 그룹을 구성합니다. 다음 단계에서 정책을 정의 prependpolicy1 합니다. 이 정책은 내보내기 정책으로 적용되어 R1이 보급하는 경로에 영향을 줍니다.
user@R1# [edit] set routing-options autonomous-system 65001 set routing-options router-id 192.168.0.1 set protocols bgp group ebgp type external set protocols bgp group ebgp export prependpolicy1 set protocols bgp group ebgp peer-as 65000 set protocols bgp group ebgp neighbor 10.1.23.2
-
정책을 구성합니다 prependpolicy1 . 경로 필터 문에 switch를
or-longer사용하면 마스크 길이가 지정된 마스크와 같거나 더 길 때 일치할 수 있습니다. 접두사와 마스크 길이가 같을 때만 일치와 같은exact다른 옵션도 있습니다. 이 용어는 else 용어와 prependterm1 일치하지 않는 경로가 용어와 일치 else 하여 AS 경로 앞에 추가되지 않고 어떻게 보급되는지 보여줍니다.user@R1# [edit] set policy-options policy-statement prependpolicy1 term prependterm1 from protocol direct set policy-options policy-statement prependpolicy1 term prependterm1 from route-filter 172.16.0.0/16 orlonger set policy-options policy-statement prependpolicy1 term prependterm1 from route-filter 192.168.0.0/24 orlonger set policy-options policy-statement prependpolicy1 term prependterm1 from route-filter 10.255.1.0/24 orlonger set policy-options policy-statement prependpolicy1 term prependterm1 then as-path-prepend "65001 65001 65001" set policy-options policy-statement prependpolicy1 term prependterm1 then accept set policy-options policy-statement prependpolicy1 term else from protocol direct set policy-options policy-statement prependpolicy1 term else from route-filter 10.200.0.0/16 orlonger set policy-options policy-statement prependpolicy1 term else then accept
참고:여러 개의 AS 번호를 입력할 때는 각 숫자를 공백으로 구분해야 합니다. AS 번호 문자열을 큰따옴표로 묶습니다.
-
테스트 경로를 정의합니다. 샘플 토폴로지에서는 작동 중인 미사용 인터페이스에 접두사를 할당합니다. 이는 BGP가 내보내기 정책의 작동을 테스트하기 위해 보급할 직접 경로를 제공합니다.
user@R1# [edit] set interfaces xe-0/0/0:0 unit 0 family inet address 10.255.1.1/30 set interfaces xe-0/0/0:0 unit 0 family inet address 172.16.0.1/24 set interfaces xe-0/0/0:0 unit 0 family inet address 10.200.1.1/24
결과
구성 모드에서 show policy-options, show protocols bgp, show routing-options 및 show interfaces 명령을 입력하여 구성을 확인합니다. 출력에 의도한 구성이 표시되지 않으면 이 예의 구성 지침을 반복하여 수정합니다.
user@R1#[edit]
user@R1# show policy-options
policy-statement prependpolicy1 {
term prependterm1 {
from {
protocol direct;
route-filter 172.16.0.0/16 orlonger;
route-filter 192.168.0.0/24 orlonger;
route-filter 10.255.1.0/24 orlonger;
}
then {
as-path-prepend "65001 65001 65001";
accept;
}
}
term else {
from {
protocol direct;
route-filter 10.200.0.0/16 orlonger;
}
then accept;
}
}
[edit]
user@R1# show protocols bgp
group ebgp {
type external;
export direct;
peer-as 65000;
neighbor 10.1.23.2;
}
[edit]
user@R1# show routing-options
autonomous-system 65001;
router-id 192.168.0.1
user@R1# show interfaces xe-0/0/0:0
unit 0 {
family inet {
address 10.255.1.1/30;
address 172.16.0.1/24;
address 10.200.1.1/24;
}
}
[edit]
user@R1# show interfaces xe-0/0/0:1
unit 0 {
family inet {
address 10.1.23.1/24;
}
}
[edit]
user@R1# show interfaces lo0
unit 0 {
family inet {
address 192.168.0.1/32;
}
}
R1 디바이스 구성이 완료되면 구성 모드에서 commit 을 입력합니다.
검증
구성이 제대로 작동하는지 확인하려면 다음 작업을 수행하십시오.
AS 프리펜딩 정책 확인
목적
디바이스에 정책이 구성되어 있고, AS 번호 앞에 적절한 경로가 지정되어 있는지 확인합니다.
작업
운영 모드에서 명령을 입력합니다 show policy prependpolicy1 .
user@R1> show policy prependpolicy1
Policy prependpolicy1: [CHANGED/RESOLVED/]
Term prependterm1:
from proto Direct
route filter:
172.16.0.0/16 orlonger
192.168.0.0/24 orlonger
10.255.1.0/24 orlonger
then aspathprepend 65001 65001 65001 accept
Term else:
from proto Direct
route filter:
10.200.0.0/16 orlonger
then accept
정책은 올바른 일치 조건 및 작업을 표시합니다.
라우팅 정책 애플리케이션 및 BGP 피어링 확인
목적
라우팅 정책이 EBGP 피어 그룹에 내보내기 정책으로 적용되는지 확인합니다. 또한 이 단계는 R2에 대한 BGP 세션이 올바르게 설정되었음을 확인합니다.
작업
운영 모드에서 show bgp neighbor 10.1.23.2 명령을 입력합니다.
user@R1> show bgp neighbor 10.1.23.2 Peer: 10.1.23.2+49642 AS 65000 Local: 10.1.23.1+179 AS 65001 Group: ebgp Routing-Instance: master Forwarding routing-instance: master Type: External State: Established Flags: <Sync> Last State: OpenConfirm Last Event: RecvKeepAlive Last Error: None Export: [ prependpolicy1 ] Options: <PeerAS Refresh> Options: <GracefulShutdownRcv> Holdtime: 90 Preference: 170 Graceful Shutdown Receiver local-preference: 0 Number of flaps: 1 Last flap event: RecvNotify Error: 'Cease' Sent: 0 Recv: 1 Peer ID: 192.168.0.2 Local ID: 192.168.0.1 Active Holdtime: 90 . . . Input messages: Total 2498 Updates 1 Refreshes 0 Octets 47510 Output messages: Total 2500 Updates 3 Refreshes 0 Octets 47620 Output Queue[1]: 0 (inet.0, inet-unicast)
명령 출력은 BGP 세션이 설정되었고 R1이 정책을 내보내기로 적용 prependpolicy1 했음을 확인합니다.
AS 경로 접두부 확인
목적
내보내기 정책이 일치하는 경로에 AS 번호를 추가하는 설계로 작동하는지 확인합니다.
작업
운영 모드의 R2에 show route protocol bgp 명령을 입력합니다. 또는 R1에서 show route advertising-protocol bgp 10.1.23.2 를 사용하여 R2에 보급하는 경로에 대한 세부 정보를 표시합니다.
user@R2> show route protocol bgp
inet.0: 14 destinations, 14 routes (14 active, 0 holddown, 0 hidden)
+ = Active Route, - = Last Active, * = Both
10.200.1.0/24 *[BGP/170] 00:04:46, localpref 100
AS path: 65001 I, validation-state: unverified
> to 10.1.23.1 via xe-0/0/0:0.0
10.255.1.0/30 *[BGP/170] 00:04:46, localpref 100
AS path: 65001 65001 65001 65001 I, validation-state: unverified
> to 10.1.23.1 via xe-0/0/0:0.0
172.16.0.0/24 *[BGP/170] 00:04:46, localpref 100
AS path: 65001 65001 65001 65001 I, validation-state: unverified
> to 10.1.23.1 via xe-0/0/0:0.0
192.168.0.1/32 *[BGP/170] 00:04:46, localpref 100
AS path: 65001 65001 65001 65001 I, validation-state: unverified
> to 10.1.23.1 via xe-0/0/0:0.0
경로는 예상되는 AS 경로 앞에 표시됩니다. 10.200.1.0/24 경로에는 AS 번호 65001의 인스턴스가 하나만 있습니다. 이 경로는 정책의 prependpolicy1 경로 필터 문 prependterm1 과 일치하지 않으므로 앞에 추가되지 않습니다.
R2에 보급하는 BGP 경로에 대한 R1의 보기는 완전성을 위해 제공됩니다.
user@R1> show route advertising-protocol bgp 10.1.23.2
inet.0: 16 destinations, 16 routes (16 active, 0 holddown, 0 hidden)
Prefix Nexthop MED Lclpref AS path
* 10.200.1.0/24 Self I
* 10.255.1.0/30 Self 65001 65001 65001 [65001] I
* 172.16.0.0/24 Self 65001 65001 65001 [65001] I
* 192.168.0.1/32 Self 65001 65001 65001 [65001] I
부록 전체 구성
R1의 전체 구성입니다.
set system host-name R1 set interfaces xe-0/0/0:0 unit 0 family inet address 10.255.1.1/30 set interfaces xe-0/0/0:0 unit 0 family inet address 172.16.0.1/24 set interfaces xe-0/0/0:0 unit 0 family inet address 10.200.1.1/24 set interfaces xe-0/0/0:1 unit 0 family inet address 10.1.23.1/24 set interfaces lo0 unit 0 family inet address 192.168.0.1/32 set policy-options policy-statement prependpolicy1 term prependterm1 from protocol direct set policy-options policy-statement prependpolicy1 term prependterm1 from route-filter 172.16.0.0/16 orlonger set policy-options policy-statement prependpolicy1 term prependterm1 from route-filter 192.168.0.0/24 orlonger set policy-options policy-statement prependpolicy1 term prependterm1 from route-filter 10.255.1.0/24 orlonger set policy-options policy-statement prependpolicy1 term prependterm1 then as-path-prepend "65001 65001 65001" set policy-options policy-statement prependpolicy1 term prependterm1 then accept set policy-options policy-statement prependpolicy1 term else from protocol direct set policy-options policy-statement prependpolicy1 term else from route-filter 10.200.0.0/16 orlonger set policy-options policy-statement prependpolicy1 term else then accept set routing-options router-id 192.168.0.1 set routing-options autonomous-system 65001 set protocols bgp group ebgp type external set protocols bgp group ebgp export prependpolicy1 set protocols bgp group ebgp peer-as 65000 set protocols bgp group ebgp neighbor 10.1.23.2
R2의 전체 구성입니다.
set system host-name R2 set interfaces xe-0/0/0:0 unit 0 family inet address 10.1.23.2/24 set interfaces lo0 unit 0 family inet address 192.168.0.2/32 set routing-options router-id 192.168.0.2 set routing-options autonomous-system 65000 set protocols bgp group ebgp type external set protocols bgp group ebgp peer-as 65001 set protocols bgp group ebgp neighbor 10.1.23.1