예: AS 경로 정규 표현식 사용
AS(Autonomous System) 경로는 BGP에서 사용하는 경로 속성입니다. AS 경로는 경로 선택과 잠재적 라우팅 루프를 방지하는 데 모두 사용됩니다. 이 예는 경로 세트를 찾기 위해 AS 경로 번호와 함께 정규 표현식을 사용하는 방법을 보여줍니다.
요구 사항
이 예를 구성하기 전에 디바이스 초기화를 제외한 특별한 구성은 필요하지 않습니다.
개요
그림 1 은 외부 BGP(EBGP) 피어링 세션을 통해 연결된 여러 AS를 보여줍니다. 각 디바이스는 할당된 주소 공간 내에서 고객 경로를 생성합니다.
토폴로지
그림 1은 샘플 네트워크를 표시합니다.
AS 64516의 관리자는 AS 64513 및 AS 64514에서 시작되는 모든 경로를 거부하려고 합니다. 및 orig-in-64514
라는 orig-in-64513
정책reject-some-routes
에서 생성 및 참조되는 두 개의 AS 경로 정규 표현식이 생성됩니다. 그런 다음 라우팅 정책이 디바이스 R6에 가져오기 정책으로 적용됩니다.
CLI 빠른 구성은(는) 그림 1 내 모든 디바이스의 구성을 보여줍니다.
이 섹션에서는 #configuration488__policy-as-path-regex-st 디바이스 R2 및 디바이스 R6의 단계를 설명합니다. 검증 에서는 정규식을 사용하여 경로를 찾기 위해 디바이스 R2에서 명령과 show route
함께 옵션을 사용하는 aspath-regex
방법을 보여줍니다.
구성
CLI 빠른 구성
이 예를 빠르게 구성하려면, 아래 명령을 복사하여 텍스트 파일로 붙여 넣은 다음 모든 라인브레이크를 제거하고, 네트워크 구성을 일치하는 데 필요한 세부 사항을 바꾸고 [edit]
계층 수준에서 명령을 CLI로 복사해 붙여 넣습니다.
디바이스 R1
set interfaces fe-1/2/2 unit 0 description to-R2 set interfaces fe-1/2/2 unit 0 family inet address 10.2.0.2/30 set interfaces fe-1/2/3 unit 0 description to-R3 set interfaces fe-1/2/3 unit 0 family inet address 10.2.0.6/30 set interfaces fe-1/2/0 unit 0 description to-R5 set interfaces fe-1/2/0 unit 0 family inet address 10.0.0.2/30 set interfaces lo0 unit 0 family inet address 192.168.0.1/32 set protocols bgp export send-static set protocols bgp group 64512 type external set protocols bgp group 64512 peer-as 64512 set protocols bgp group 64512 neighbor 10.2.0.1 set protocols bgp group 64513 type external set protocols bgp group 64513 peer-as 64513 set protocols bgp group 64513 neighbor 10.2.0.5 set protocols bgp group 64515 type external set protocols bgp group 64515 peer-as 64515 set protocols bgp group 64515 neighbor 10.0.0.1 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 10.10.1.0/24 reject set routing-options static route 10.10.2.0/24 reject set routing-options static route 10.10.3.0/24 reject set routing-options autonomous-system 64511
디바이스 R2
set interfaces fe-1/2/2 unit 0 description to-R1 set interfaces fe-1/2/2 unit 0 family inet address 10.2.0.1/30 set interfaces lo0 unit 0 family inet address 192.168.0.2/32 set protocols bgp export send-static set protocols bgp group 64511 type external set protocols bgp group 64511 peer-as 64511 set protocols bgp group 64511 neighbor 10.2.0.2 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 10.20.1.0/24 reject set routing-options static route 10.20.2.0/24 reject set routing-options static route 10.20.3.0/24 reject set routing-options autonomous-system 64512
디바이스 R3
set interfaces fe-1/2/3 unit 0 description to-R1 set interfaces fe-1/2/3 unit 0 family inet address 10.2.0.5/30 set interfaces fe-1/2/2 unit 0 description to-R4 set interfaces fe-1/2/2 unit 0 family inet address 10.3.0.42/30 set interfaces lo0 unit 0 family inet address 192.168.0.3/32 set protocols bgp export send-static set protocols bgp group 64511 type external set protocols bgp group 64511 peer-as 64511 set protocols bgp group 64511 neighbor 10.2.0.6 set protocols bgp group 64514 type external set protocols bgp group 64514 peer-as 64514 set protocols bgp group 64514 neighbor 10.3.0.41 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 10.30.1.0/24 reject set routing-options static route 10.30.2.0/24 reject set routing-options static route 10.30.3.0/24 reject set routing-options autonomous-system 64513
디바이스 R4
set interfaces fe-1/2/2 unit 0 description to-R3 set interfaces fe-1/2/2 unit 0 family inet address 10.3.0.41/30 set interfaces lo0 unit 0 family inet address 192.168.0.4/32 set protocols bgp export send-static set protocols bgp group 64513 type external set protocols bgp group 64513 peer-as 64513 set protocols bgp group 64513 neighbor 10.3.0.42 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 10.40.1.0/24 reject set routing-options static route 10.40.2.0/24 reject set routing-options static route 10.40.3.0/24 reject set routing-options autonomous-system 64514
디바이스 R5
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.1/30 set interfaces fe-1/2/1 unit 0 description to-R6 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 export send-static set protocols bgp group 64511 type external set protocols bgp group 64511 peer-as 64511 set protocols bgp group 64511 neighbor 10.0.0.2 set protocols bgp group 64516 type external set protocols bgp group 64516 peer-as 64516 set protocols bgp group 64516 neighbor 10.0.0.10 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 10.50.1.0/24 reject set routing-options static route 10.50.2.0/24 reject set routing-options static route 10.50.3.0/24 reject set routing-options autonomous-system 64515
디바이스 R6
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.6/32 set protocols bgp export send-static set protocols bgp group 64515 type external set protocols bgp group 64515 import reject-some-routes set protocols bgp group 64515 peer-as 64515 set protocols bgp group 64515 neighbor 10.0.0.9 set policy-options policy-statement send-static term 1 from protocol static set policy-options policy-statement send-static term 1 then accept set policy-options policy-statement reject-some-routes term find-routes from as-path orig-in-64513 set policy-options policy-statement reject-some-routes term find-routes from as-path orig-in-64514 set policy-options policy-statement reject-some-routes term find-routes then reject set policy-options as-path orig-in-64513 ".* 64513" set policy-options as-path orig-in-64514 ".* 64514" set routing-options static route 10.60.1.0/24 reject set routing-options static route 10.60.2.0/24 reject set routing-options static route 10.60.3.0/24 reject set routing-options autonomous-system 64516
절차
단계별 절차
다음 예는 구성 계층에서 다양한 수준의 탐색이 필요합니다. CLI 탐색에 대한 내용은 Junos OS CLI 사용자 가이드의 구성 모드에서 CLI 편집기 사용을(를) 참조하십시오.
디바이스 R2 구성:
디바이스 인터페이스를 구성합니다.
[edit interfaces] user@R2# set fe-1/2/2 unit 0 description to-R1 user@R2# set fe-1/2/2 unit 0 family inet address 10.2.0.1/30 user@R2# set lo0 unit 0 family inet address 192.168.0.2/32
디바이스 R1에 EBGP 연결을 구성합니다.
[edit protocols bgp] user@R2# set export send-static user@R2# set group 64511 type external user@R2# set group 64511 peer-as 64511 user@R2# set group 64511 neighbor 10.2.0.2
라우팅 정책 구성
[edit policy-options policy-statement send-static term 1] user@R2# set from protocol static user@R2# set then accept
고정 경로를 구성합니다.
[edit routing-options static] user@R2# set route 10.20.1.0/24 reject user@R2# set route 10.20.2.0/24 reject user@R2# set route 10.20.3.0/24 reject
AS 번호를 구성합니다.
[edit routing-options] user@R2# set autonomous-system 64512
단계별 절차
다음 예는 구성 계층에서 다양한 수준의 탐색이 필요합니다. CLI 탐색에 대한 내용은 Junos OS CLI 사용자 가이드의 구성 모드에서 CLI 편집기 사용을(를) 참조하십시오.
디바이스 R6 구성:
디바이스 인터페이스를 구성합니다.
[edit interfaces] user@R6# set fe-1/2/1 unit 0 description to-R5 user@R6# set fe-1/2/1 unit 0 family inet address 10.0.0.10/30 user@R6# set lo0 unit 0 family inet address 192.168.0.6/32
디바이스 R5에 EBGP 연결을 구성합니다.
[edit protocols bgp] user@R6# set export send-static user@R6# set group 64515 type external user@R6# set group 64515 import reject-some-routes user@R6# set group 64515 peer-as 64515 user@R6# set group 64515 neighbor 10.0.0.9
정적 경로를 전송하는 라우팅 정책을 구성합니다.
[edit policy-options policy-statement send-static term 1] user@R6# set from protocol static user@R6# set then accept
특정 경로를 거부하는 라우팅 정책을 구성합니다.
[edit policy-options policy-statement reject-some-routes term find-routes] user@R6# set from as-path orig-in-64513 user@R6# set from as-path orig-in-64514 user@R6# set then reject [edit policy-options] user@R6# set as-path orig-in-64513 ".* 64513" user@R6# set as-path orig-in-64514 ".* 64514"
고정 경로를 구성합니다.
[edit routing-options static] user@R6# set route 10.60.1.0/24 reject user@R6# set route 10.60.2.0/24 reject user@R6# set route 10.60.3.0/24 reject
AS 번호를 구성합니다.
[edit routing-options] user@R6# set autonomous-system 64516
결과
구성 모드에서 show interfaces
, show protocols
, show policy-options
및 show routing-options
명령을 입력하여 구성을 확인합니다. 출력 결과가 의도한 구성대로 표시되지 않으면 이 예의 지침을 반복하여 구성을 수정하십시오.
디바이스 R2
user@R2# show interfaces fe-1/2/0 { unit 0 { description to-R1; family inet { address 10.2.0.1/30; } } } lo0 { unit 0 { family inet { address 192.168.0.2/32; } } }
user@R2# show protocols bgp { export send-static; group 64511 { type external; peer-as 64511; neighbor 10.2.0.2; } }
user@R2# show policy-options policy-statement send-static { term 1 { from protocol static; then accept; } }
user@R2# show routing-options static { route 10.20.1.0/24 reject; route 10.20.2.0/24 reject; route 10.20.3.0/24 reject; } autonomous-system 64512;
디바이스 R6
user@R6# show interfaces fe-1/2/0 { unit 0 { description to-R5; family inet { address 10.0.0.10/30; } } } lo0 { unit 0 { family inet { address 192.168.0.6/32; } } }
user@R6# show protocols bgp { export send-static; group 64515 { type external; import reject-some-routes; peer-as 64515; neighbor 10.0.0.9; } }
user@R6# show policy-options policy-statement reject-some-routes { term find-routes { from as-path [ orig-in-64513 orig-in-64514 ]; then reject; } } policy-statement send-static { term 1 { from protocol static; then accept; } } as-path orig-in-64513 ".* 64513"; as-path orig-in-64514 ".* 64514";
user@R6# show routing-options static { route 10.60.1.0/24 reject; route 10.60.2.0/24 reject; route 10.60.3.0/24 reject; } autonomous-system 64516;
디바이스 구성이 완료되면 구성모드에서 commit
을(를) 입력합니다.
검증
구성이 올바르게 작동하고 있는지 확인합니다.
디바이스 R2에서 경로 찾기
목적
디바이스 R2에서 명령을 사용하여 show route aspath-regex
정규식을 사용하는 경로를 찾습니다.
작업
AS 64516의 디바이스 R6에서 시작된 경로를 찾습니다.
user@R2> show route terse aspath-regex ".* 64516" inet.0: 21 destinations, 21 routes (21 active, 0 holddown, 0 hidden) + = Active Route, - = Last Active, * = Both A V Destination P Prf Metric 1 Metric 2 Next hop AS path * ? 10.60.1.0/24 B 170 100 64511 64515 64516 I unverified >10.2.0.2 * ? 10.60.2.0/24 B 170 100 64511 64515 64516 I unverified >10.2.0.2 * ? 10.60.3.0/24 B 170 100 64511 64515 64516 I unverified >10.2.0.2
AS 64514 또는 AS 64516에서 시작된 경로를 찾습니다.
user@R2> show route terse aspath-regex ".* (64514|64516)" inet.0: 21 destinations, 21 routes (21 active, 0 holddown, 0 hidden) + = Active Route, - = Last Active, * = Both A V Destination P Prf Metric 1 Metric 2 Next hop AS path * ? 10.40.1.0/24 B 170 100 64511 64513 64514 I unverified >10.2.0.2 * ? 10.40.2.0/24 B 170 100 64511 64513 64514 I unverified >10.2.0.2 * ? 10.40.3.0/24 B 170 100 64511 64513 64514 I unverified >10.2.0.2 * ? 10.60.1.0/24 B 170 100 64511 64515 64516 I unverified >10.2.0.2 * ? 10.60.2.0/24 B 170 100 64511 64515 64516 I unverified >10.2.0.2 * ? 10.60.3.0/24 B 170 100 64511 64515 64516 I unverified >10.2.0.2
AS 64513을 전송 네트워크로 사용하는 경로를 찾습니다.
user@R2> show route terse aspath-regex ".* 64513 .+" inet.0: 21 destinations, 21 routes (21 active, 0 holddown, 0 hidden) + = Active Route, - = Last Active, * = Both A V Destination P Prf Metric 1 Metric 2 Next hop AS path * ? 10.40.1.0/24 B 170 100 64511 64513 64514 I unverified >10.2.0.2 * ? 10.40.2.0/24 B 170 100 64511 64513 64514 I unverified >10.2.0.2 * ? 10.40.3.0/24 B 170 100 64511 64513 64514 I unverified
의미
출력에는 지정된 AS 경로 정규 표현식과 일치하는 라우팅 테이블 항목이 표시됩니다.
디바이스 R6에서 경로가 제외되었는지 확인
목적
디바이스 R6에서 명령을 사용하여 show route and show route hidden
AS 64513 및 AS 64514에서 시작되는 경로가 디바이스 R6의 라우팅 테이블에서 제외되는지 확인합니다.
작업
user@R6> show route 10.30.0/22 inet.0: 21 destinations, 21 routes (15 active, 0 holddown, 6 hidden)
user@R6> show route 10.40.0/22 inet.0: 21 destinations, 21 routes (15 active, 0 holddown, 6 hidden)
user@R6> show route hidden inet.0: 21 destinations, 21 routes (15 active, 0 holddown, 6 hidden) + = Active Route, - = Last Active, * = Both 10.30.1.0/24 [BGP ] 02:24:47, localpref 100 AS path: 64515 64511 64513 I, validation-state: unverified > to 10.0.0.9 via fe-1/2/1.0 10.30.2.0/24 [BGP ] 02:24:47, localpref 100 AS path: 64515 64511 64513 I, validation-state: unverified > to 10.0.0.9 via fe-1/2/1.0 10.30.3.0/24 [BGP ] 02:24:47, localpref 100 AS path: 64515 64511 64513 I, validation-state: unverified > to 10.0.0.9 via fe-1/2/1.0 10.40.1.0/24 [BGP ] 02:24:47, localpref 100 AS path: 64515 64511 64513 64514 I, validation-state: unverified > to 10.0.0.9 via fe-1/2/1.0 10.40.2.0/24 [BGP ] 02:24:47, localpref 100 AS path: 64515 64511 64513 64514 I, validation-state: unverified > to 10.0.0.9 via fe-1/2/1.0 10.40.3.0/24 [BGP ] 02:24:47, localpref 100 AS path: 64515 64511 64513 64514 I, validation-state: unverified > to 10.0.0.9 via fe-1/2/1.0
의미
출력은 디바이스 R6에서 10.30.0/22 및 10.40.0/22 경로가 거부됨을 보여줍니다.