예를 들면 다음과 같습니다. 조건부 기본 경로 정책 구성
이 예는 하나의 라우팅 디바이스에서 조건부 기본 경로를 구성하고 기본 경로를 OSPF에 재배포하는 방법을 보여줍니다.
요구 사항
이 예를 구성하기 전에 디바이스 초기화를 제외한 특별한 구성은 필요하지 않습니다.
개요
이 예에서 OSPF 영역 0은 3개의 라우팅 디바이스를 포함합니다. 디바이스 R3에는 외부 피어와 BGP 세션이 있습니다(예: 인터넷 서비스 프로바이더(ISP)).
정적 경로를 BGP로 전파하기 위해 이 예는 경로를 정의할 때 문을 포함합니다 discard
. ISP는 기본 정적 경로를 BGP에 삽입하여 고객 네트워크에 외부 네트워크에 도달할 수 있는 기본 정적 경로를 제공합니다. 정적 경로에는 폐기 다음 홉이 있습니다. 즉, 패킷이 더 구체적인 경로와 일치하지 않으면 패킷이 거부되고 이 대상에 대한 거부 경로가 라우팅 테이블 설치되지만 ICMP(Internet Control Message Protocol) 도달 불가능한 메시지는 전송되지 않습니다. 삭제 다음 홉을 사용하면 요약 경로를 생성할 수 있으며, 이는 동적 라우팅 프로토콜을 통해 보급될 수 있습니다.
디바이스 R3은 기본 경로를 OSPF로 내보냅니다. 디바이스 R3의 경로 정책은 조건부이므로 ISP에 대한 연결이 중단되면 더 이상 라우팅 테이블 활성화되지 않아 기본 경로가 OSPF로 내보내기되지 않습니다. 이 정책은 알림 없이 패킷이 자동으로 삭제되는 것을 방지합니다(null-route 필터링이라고도 함).
이 예는 모든 디바이스의 구성과 디바이스 R3의 단계별 구성을 보여줍니다.
구성
CLI 빠른 구성
이 예를 빠르게 구성하려면, 아래 명령을 복사하여 텍스트 파일로 붙여 넣은 다음 모든 라인브러브를 제거하고, 네트워크 구성을 일치하는 데 필요한 세부 사항을 변경한 다음 계층 수준에서 명령을 CLI [edit]
로 복사해 붙여 넣습니다.
디바이스 R1
set interfaces fe-1/2/0 unit 0 description R1->R3 set interfaces fe-1/2/0 unit 0 family inet address 10.0.1.2/30 set interfaces fe-1/2/1 unit 2 description R1->R2 set interfaces fe-1/2/1 unit 2 family inet address 10.0.0.1/30 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.2
디바이스 R2
set interfaces fe-1/2/0 unit 1 description R2->R1 set interfaces fe-1/2/0 unit 1 family inet address 10.0.0.2/30 set interfaces fe-1/2/1 unit 4 description R2->R3 set interfaces fe-1/2/1 unit 4 family inet address 10.0.2.2/30 set protocols ospf area 0.0.0.0 interface fe-1/2/0.1 set protocols ospf area 0.0.0.0 interface fe-1/2/1.4
디바이스 R3
set interfaces fe-1/2/0 unit 3 description R3->R2 set interfaces fe-1/2/0 unit 3 family inet address 10.0.2.1/30 set interfaces fe-1/2/1 unit 5 description R3->R1 set interfaces fe-1/2/1 unit 5 family inet address 10.0.1.1/30 set interfaces ge-0/0/2 unit 0 description R3->ISP set interfaces ge-0/0/2 unit 0 family inet address 10.0.45.2/30 set protocols bgp group ext type external set protocols bgp group ext peer-as 64500 set protocols bgp group ext neighbor 10.0.45.1 set protocols ospf export gendefault set protocols ospf area 0.0.0.0 interface fe-1/2/1.4 set protocols ospf area 0.0.0.0 interface fe-1/2/0.3 set policy-options policy-statement gendefault term upstreamroutes from protocol bgp set policy-options policy-statement gendefault term upstreamroutes from as-path upstream set policy-options policy-statement gendefault term upstreamroutes from route-filter 0.0.0.0/0 upto /16 set policy-options policy-statement gendefault term upstreamroutes then next-hop 10.0.45.1 set policy-options policy-statement gendefault term upstreamroutes then accept set policy-options policy-statement gendefault term end then reject set policy-options as-path upstream "^64500 " set routing-options autonomous-system 64501
디바이스 ISP
set interfaces ge-0/0/2 unit 0 family inet address 10.0.45.1/30 set protocols bgp group ext type external set protocols bgp group ext export advertise-default set protocols bgp group ext peer-as 64501 set protocols bgp group ext neighbor 10.0.45.2 set policy-options policy-statement advertise-default term 1 from route-filter 0.0.0.0/0 exact set policy-options policy-statement advertise-default term 1 then accept set routing-options static route 0.0.0.0/0 discard set routing-options autonomous-system 64500
절차
단계별 절차
다음 예제에서는 구성 계층에서 다양한 수준의 탐색이 필요합니다. CLI 탐색에 대한 정보는 Junos OS CLI 사용자 가이드의 구성 모드에서 CLI 편집기 사용을 참조하십시오.
디바이스 R3 구성:
인터페이스를 구성합니다.
[edit interfaces] user@R3# set fe-1/2/0 unit 3 description R3->R2 user@R3# set fe-1/2/0 unit 3 family inet address 10.0.2.1/30 user@R3# set fe-1/2/1 unit 5 description R3->R1 user@R3# set fe-1/2/1 unit 5 family inet address 10.0.1.1/30 user@R3# set ge-0/0/2 unit 0 description R3->ISP user@R3# set ge-0/0/2 unit 0 family inet address 10.0.45.2/30
AS(Autonomous System) 번호를 구성합니다.
[edit routing-options] user@R3# set autonomous-system 64501
ISP 디바이스로 BGP 세션을 구성합니다.
[edit protocols bgp group ext] user@R3# set type external user@R3# set peer-as 64500 user@R3# set neighbor 10.0.45.1
OSPF를 구성합니다.
[edit protocols ospf area 0.0.0.0] user@R3# set interface fe-1/2/1.4 user@R3# set interface fe-1/2/0.3
라우팅 정책 구성합니다.
[edit policy-options policy-statement gendefault] user@R3# set term upstreamroutes from protocol bgp user@R3# set term upstreamroutes from as-path upstream user@R3# set term upstreamroutes from route-filter 0.0.0.0/0 upto /16 user@R3# set term upstreamroutes then next-hop 10.0.45.1 user@R3# set term upstreamroutes then accept user@R3# set term end then reject [edit policy-options] user@R3# set as-path upstream "^64500 "
내보내기 정책을 OSPF에 적용합니다.
[edit protocols ospf] user@R3# set export gendefault
디바이스 구성이 완료되면 구성을 커밋합니다.
[edit] user@R3# commit
결과
명령을 실행하여 구성을 확인합니다 show
. 출력에 의도한 구성이 표시되지 않으면 이 예의 지침을 반복하여 구성을 수정합니다.
user@R3# show interfaces { fe-1/2/0 { unit 3 { description R3->R2; family inet { address 10.0.2.1/30; } } } fe-1/2/1 { unit 5 { description R3->R1; family inet { address 10.0.1.1/30; } } } ge-1/2/0 { unit 0 { description R3->ISP; family inet { address 10.0.45.2/30; } } } } protocols { bgp { group ext { type external; peer-as 64500; neighbor 10.0.45.1; } } ospf { export gendefault; area 0.0.0.0 { interface fe-1/2/1.4; interface fe-1/2/0.3; } } } policy-options { policy-statement gendefault { term upstreamroutes { from { protocol bgp; as-path upstream; route-filter 0.0.0.0/0 upto /16; } then { next-hop 10.0.45.1; accept; } } term end { then reject; } } as-path upstream "^64500 "; } routing-options { autonomous-system 64501; }
확인
구성이 제대로 작동하는지 확인합니다.
ISP에 대한 경로가 작동하는지 확인
목적
디바이스 R3과 ISP의 라우터 간에 연결이 설정되었는지 확인합니다.
실행
user@R3> ping 10.0.45.1 PING 10.0.45.1 (10.0.45.1): 56 data bytes 64 bytes from 10.0.45.1: icmp_seq=0 ttl=64 time=1.185 ms 64 bytes from 10.0.45.1: icmp_seq=1 ttl=64 time=1.199 ms 64 bytes from 10.0.45.1: icmp_seq=2 ttl=64 time=1.186 ms
의미
ping
명령은 도달 가능성을 확인합니다.
정적 경로가 재배포되는지 확인
목적
BGP 정책이 정적 경로를 디바이스 R3의 라우팅 테이블 재배포하는지 확인합니다. 또한 OSPF 정책이 정적 경로를 디바이스 R1 및 디바이스 R2의 라우팅 테이블에 재배포하는지 확인합니다.
실행
user@R3> show route protocol bgp inet.0: 9 destinations, 10 routes (9 active, 0 holddown, 1 hidden) + = Active Route, - = Last Active, * = Both 0.0.0.0/0 *[BGP/170] 00:00:25, localpref 100 AS path: 64500 I > to 10.0.45.1 via ge-0/0/2.6
user@R1> show route protocol ospf inet.0: 7 destinations, 7 routes (7 active, 0 holddown, 0 hidden) + = Active Route, - = Last Active, * = Both 0.0.0.0/0 *[OSPF/150] 00:03:58, metric 0, tag 0 > to 10.0.1.1 via fe-1/2/0.0 10.0.2.0/30 *[OSPF/10] 03:37:45, metric 2 to 10.0.1.1 via fe-1/2/0.0 > to 10.0.0.2 via fe-1/2/1.2 172.16.233.5/32 *[OSPF/10] 03:38:41, metric 1 MultiRecv
user@R2> show route protocol ospf inet.0: 7 destinations, 7 routes (7 active, 0 holddown, 0 hidden) + = Active Route, - = Last Active, * = Both 0.0.0.0/0 *[OSPF/150] 00:04:04, metric 0, tag 0 > to 10.0.2.1 via fe-1/2/1.4 10.0.1.0/30 *[OSPF/10] 03:37:46, metric 2 to 10.0.0.1 via fe-1/2/0.1 > to 10.0.2.1 via fe-1/2/1.4 172.16.233.5/32 *[OSPF/10] 03:38:47, metric 1 MultiRecv
의미
라우팅 테이블에는 기본 0.0.0.0/0 경로가 포함되어 있습니다. 디바이스 R1 및 디바이스 R2가 라우팅 테이블에 지정되지 않은 네트워크로 향하는 패킷을 수신하면 해당 패킷은 추가 처리를 위해 디바이스 R3으로 전송됩니다. 디바이스 R3이 라우팅 테이블 지정되지 않은 네트워크로 향하는 패킷을 수신하면 해당 패킷은 추가 처리를 위해 ISP로 전송됩니다.
정책 조건 테스트
목적
외부 네트워크에 연결할 수 없게 되면 인터페이스를 비활성화하여 라우팅 테이블에서 경로가 제거되는지 확인합니다.
실행
user@R3> deactivate interfaces ge-0/0/2 unit 0 family inet address 10.0.45.2/30 user@R3> commit
user@R1> show route protocol ospf inet.0: 6 destinations, 6 routes (6 active, 0 holddown, 0 hidden) + = Active Route, - = Last Active, * = Both 10.0.2.0/30 *[OSPF/10] 03:41:48, metric 2 to 10.0.1.1 via fe-1/2/0.0 > to 10.0.0.2 via fe-1/2/1.2 172.16.233.5/32 *[OSPF/10] 03:42:44, metric 1 MultiRecv user@R2> show route protocol ospf inet.0: 6 destinations, 6 routes (6 active, 0 holddown, 0 hidden) + = Active Route, - = Last Active, * = Both 10.0.1.0/30 *[OSPF/10] 03:42:10, metric 2 to 10.0.0.1 via fe-1/2/0.1 > to 10.0.2.1 via fe-1/2/1.4 172.16.233.5/32 *[OSPF/10] 03:43:11, metric 1 MultiRecv
의미
디바이스 R1 및 디바이스 R2의 라우팅 테이블에는 기본 0.0.0.0/0 경로가 포함되어 있지 않습니다. 이렇게 하면 기본 경로가 더 이상 OSPF 도메인에 없음을 확인합니다. ge-0/0/2.6 인터페이스를 다시 활성화하려면 구성 모드 명령을 실행합니다 activate interfaces ge-0/0/2 unit 0 family inet address 10.0.45.2/30
.