예: 경로 필터를 사용하여 MED 구성
이 예에서는 경로 필터를 사용하여 BGP 업데이트 메시지에 광고하기 위해 MED(Multiple Exit Discriminator) 메트릭을 수정하는 정책을 구성하는 방법을 보여줍니다.
요구 사항
이 예제를 구성하기 전에 디바이스 초기화 이외의 특별한 구성은 필요하지 않습니다.
개요
BGP 업데이트 메시지에서 광고된 MED 메트릭을 수정하는 route-filter 정책을 구성하려면 정책 작업에 문을 포함합니다 metric
.
그림 1 에는 내부 피어 세션과 인접 AS(Autonomous System)에 대한 여러 출구점이 있는 일반적인 네트워크가 나와 있습니다.

디바이스 R4에는 보급된 접두사를 시뮬레이션하도록 구성된 여러 루프백 인터페이스가 있습니다. 추가 루프백 인터페이스 주소는 172.16.44.0/32 및 172.16.144.0/32입니다. 이 예는 172.16.144.0을 제외한 모든 경로에 대해 디바이스 R3에 MED 값 30을 알리도록 디바이스 R4를 구성하는 방법을 보여줍니다. 172.16.144.0의 경우 MED 값 10이 디바이스 3에 보급됩니다. MED 값 20은 경로 접두사에 관계없이 디바이스 R2에 보급됩니다.
구성
CLI 빠른 구성
이 예를 빠르게 구성하려면, 아래 명령을 복사하여 텍스트 파일로 붙여 넣은 다음 모든 라인브레이크를 제거하고, 네트워크 구성을 일치하는 데 필요한 세부 사항을 바꾸고 [edit]
계층 수준에서 명령을 CLI로 복사해 붙여 넣습니다.
디바이스 R1
set interfaces fe-1/2/0 unit 1 family inet address 172.16.12.1/24 set interfaces fe-1/2/1 unit 2 family inet address 172.16.13.1/24 set interfaces lo0 unit 1 family inet address 192.168.1.1/32 set protocols bgp group internal type internal set protocols bgp group internal local-address 192.168.1.1 set protocols bgp group internal export send-direct set protocols bgp group internal neighbor 192.168.2.1 set protocols bgp group internal neighbor 192.168.3.1 set protocols ospf area 0.0.0.0 interface lo0.1 passive 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.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 123 set routing-options router-id 192.168.1.1
디바이스 R2
set interfaces fe-1/2/0 unit 3 family inet address 172.16.12.2/24 set interfaces fe-1/2/1 unit 4 family inet address 172.16.24.2/24 set interfaces lo0 unit 2 family inet address 192.168.2.1/32 set protocols bgp group internal type internal set protocols bgp group internal local-address 192.168.2.1 set protocols bgp group internal export send-direct set protocols bgp group internal neighbor 192.168.1.1 set protocols bgp group internal neighbor 192.168.3.1 set protocols bgp group external type external set protocols bgp group external export send-direct set protocols bgp group external peer-as 4 set protocols bgp group external neighbor 172.16.24.4 set protocols ospf area 0.0.0.0 interface lo0.2 passive set protocols ospf area 0.0.0.0 interface fe-1/2/0.3 set protocols ospf area 0.0.0.0 interface fe-1/2/1.4 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 123 set routing-options router-id 192.168.2.1
디바이스 R3
set interfaces fe-1/2/0 unit 5 family inet address 172.16.13.3/24 set interfaces fe-1/2/1 unit 6 family inet address 172.16.34.3/24 set interfaces lo0 unit 3 family inet address 192.168.3.1/32 set protocols bgp group internal type internal set protocols bgp group internal local-address 192.168.3.1 set protocols bgp group internal export send-direct set protocols bgp group internal neighbor 192.168.1.1 set protocols bgp group internal neighbor 192.168.2.1 set protocols bgp group external type external set protocols bgp group external export send-direct set protocols bgp group external peer-as 4 set protocols bgp group external neighbor 172.16.34.4 set protocols ospf area 0.0.0.0 interface lo0.3 passive set protocols ospf area 0.0.0.0 interface fe-1/2/0.5 set protocols ospf area 0.0.0.0 interface fe-1/2/1.6 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 123 set routing-options router-id 192.168.3.1
디바이스 R4
set interfaces fe-1/2/0 unit 7 family inet address 172.16.24.4/24 set interfaces fe-1/2/1 unit 8 family inet address 172.16.34.4/24 set interfaces lo0 unit 4 family inet address 192.168.4.1/32 set interfaces lo0 unit 4 family inet address 172.16.44.0/32 set interfaces lo0 unit 4 family inet address 172.16.144.0/32 set protocols bgp group external type external set protocols bgp group external export send-direct set protocols bgp group external peer-as 123 set protocols bgp group external neighbor 172.16.34.3 export med-10 set protocols bgp group external neighbor 172.16.34.3 export med-30 set protocols bgp group external neighbor 172.16.24.2 metric-out 20 set policy-options policy-statement med-10 from route-filter 172.16.144.0/32 exact set policy-options policy-statement med-10 then metric 10 set policy-options policy-statement med-10 then accept set policy-options policy-statement med-30 from route-filter 0.0.0.0/0 longer set policy-options policy-statement med-30 then metric 30 set policy-options policy-statement med-30 then accept 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 4 set routing-options router-id 192.168.4.1
디바이스 R1 구성
단계별 절차
다음 예는 구성 계층에서 다양한 수준의 탐색이 필요합니다. CLI 탐색 관련 정보는 Junos OS CLI 사용자 가이드의 구성 모드에서의 CLI 편집기 사용을 참조하십시오.
디바이스 R1 구성
디바이스 인터페이스를 구성합니다.
[edit interfaces fe-1/2/0 unit 1] user@R1# set family inet address 172.16.12.1/24 [edit interfaces fe-1/2/1 unit 2] user@R1# set family inet address 172.16.13.1/24 [edit interfaces lo0 unit 1] user@R1# set family inet address 192.168.1.1/32
BGP를 구성합니다.
[edit protocols bgp group internal] user@R1# set type internal user@R1# set local-address 192.168.1.1 user@R1# set export send-direct user@R1# set neighbor 192.168.2.1 user@R1# set neighbor 192.168.3.1
OSPF를 구성합니다.
[edit protocols ospf area 0.0.0.0] user@R1# set interface lo0.1 passive user@R1# set interface fe-1/2/0.1 user@R1# set interface fe-1/2/1.2
직접 경로를 수용하는 정책을 구성합니다.
이 시나리오의 다른 유용한 옵션은 OSPF 또는 로컬 경로를 통해 학습된 경로를 수용하는 것일 수 있습니다.
[edit policy-options policy-statement send-direct term 1] user@R1# set from protocol direct user@R1# set then accept
라우터 ID 및 AS(Autonomous System) 번호를 구성합니다.
[edit routing-options] user@R1# set autonomous-system 123 user@R1# set router-id 192.168.1.1
결과
구성 모드에서 show interfaces
, show protocols
, show policy-options
및 show routing-options
명령을 입력하여 구성을 확인합니다. 출력 결과가 의도한 구성대로 표시되지 않으면 이 예의 지침을 반복하여 구성을 수정하십시오.
user@R1# show interfaces fe-1/2/0 { unit 1 { family inet { address 172.16.12.1/24; } } } fe-1/2/1 { unit 2 { family inet { address 172.16.13.1/24; } } } lo0 { unit 1 { family inet { address 192.168.1.1/32; } } }
user@R1# show protocols bgp { group internal { type internal; local-address 192.168.1.1; export send-direct; neighbor 192.168.2.1; neighbor 192.168.3.1; } } ospf { area 0.0.0.0 { interface lo0.1 { passive; } interface fe-1/2/0.1; interface fe-1/2/1.2; } }
user@R1# show policy-options policy-statement send-direct { term 1 { from protocol direct; then accept; } }
user@R1# show routing-options autonomous-system 123; router-id 192.168.1.1;
디바이스 구성을 마쳤으면 구성 모드에서 commit
을(를) 입력합니다.
디바이스 R2 구성
단계별 절차
다음 예는 구성 계층에서 다양한 수준의 탐색이 필요합니다. CLI 탐색 관련 정보는 Junos OS CLI 사용자 가이드의 구성 모드에서의 CLI 편집기 사용을 참조하십시오.
디바이스 R2 구성:
디바이스 인터페이스를 구성합니다.
[edit interfaces fe-1/2/0 unit 3] user@R2# set family inet address 172.16.12.21/24 [edit interfaces fe-1/2/1 unit 4] user@R2# set family inet address 172.16.24.2/24 [edit interfaces lo0 unit 2] user@R2# set family inet address 192.168.2.1/32
BGP를 구성합니다.
[edit protocols bgp group internal] user@R2# set type internal user@R2# set local-address 192.168.2.1 user@R2# set export send-direct user@R2# set neighbor 192.168.1.1 user@R2# set neighbor 192.168.3.1 [edit protocols bgp group external] user@R2# set type external user@R2# set export send-direct user@R2# set peer-as 4 user@R2# set neighbor 172.16.24.4
OSPF를 구성합니다.
[edit protocols ospf area 0.0.0.0] user@R2# set interface lo0.2 passive user@R2# set interface fe-1/2/0.3 user@R2# set interface fe-1/2/1.4
직접 경로를 수용하는 정책을 구성합니다.
이 시나리오의 다른 유용한 옵션은 OSPF 또는 로컬 경로를 통해 학습된 경로를 수용하는 것일 수 있습니다.
[edit policy-options policy-statement send-direct term 1] user@R2# set from protocol direct user@R2# set then accept
라우터 ID 및 AS(Autonomous System) 번호를 구성합니다.
[edit routing-options] user@R2# set autonomous-system 123 user@R2# set router-id 192.168.2.1
결과
구성 모드에서 show interfaces
, show protocols
, show policy-options
및 show routing-options
명령을 입력하여 구성을 확인합니다. 출력 결과가 의도한 구성대로 표시되지 않으면 이 예의 지침을 반복하여 구성을 수정하십시오.
user@R2# show interfaces fe-1/2/0 { unit 3 { family inet { address 172.16.12.2/24; } } } fe-1/2/1 { unit 4 { family inet { address 172.16.24.2/24; } } } lo0 { unit 2 { family inet { address 192.168.2.1/32; } } }
user@R2# show protocols bgp { group internal { type internal; local-address 192.168.2.1; export send-direct; neighbor 192.168.1.1; neighbor 192.168.3.1; } group external { type external; export send-direct; peer-as 4; neighbor 172.16.24.4; } } ospf { area 0.0.0.0 { interface lo0.2 { passive; } interface fe-1/2/0.3; interface fe-1/2/1.4; } }
user@R2# show policy-options policy-statement send-direct { term 1 { from protocol direct; then accept; } }
user@R2# show routing-options autonomous-system 123; router-id 192.168.2.1;
디바이스 구성을 마쳤으면 구성 모드에서 commit
을(를) 입력합니다.
디바이스 R3 구성
단계별 절차
다음 예는 구성 계층에서 다양한 수준의 탐색이 필요합니다. CLI 탐색 관련 정보는 Junos OS CLI 사용자 가이드의 구성 모드에서의 CLI 편집기 사용을 참조하십시오.
디바이스 R3 구성:
디바이스 인터페이스를 구성합니다.
[edit interfaces fe-1/2/0 unit 5] user@R3# set family inet address 172.16.13.3/24 [edit interfaces fe-1/2/1 unit 6] user@R3# set family inet address 172.16.34.3/24 [edit interfaces lo0 unit 3] user@R3# set family inet address 192.168.3.1/32
BGP를 구성합니다.
[edit protocols bgp group internal] user@R3# set type internal user@R3# set local-address 192.168.3.1 user@R3# set export send-direct user@R3# set neighbor 192.168.1.1 user@R3# set neighbor 192.168.2.1 [edit protocols bgp group external] user@R3# set type external user@R3# set export send-direct user@R3# set peer-as 4 user@R3# set neighbor 172.16.34.4
OSPF를 구성합니다.
[edit protocols ospf area 0.0.0.0] user@R3# set interface lo0.3 passive user@R3# set interface fe-1/2/0.5 user@R3# set interface fe-1/2/1.6
직접 경로를 수용하는 정책을 구성합니다.
이 시나리오의 다른 유용한 옵션은 OSPF 또는 로컬 경로를 통해 학습된 경로를 수용하는 것일 수 있습니다.
[edit policy-options policy-statement send-direct term 1] user@R3# set from protocol direct user@R3# set then accept
라우터 ID 및 AS(Autonomous System) 번호를 구성합니다.
[edit routing-options] user@R3# set autonomous-system 123 user@R3# set router-id 192.168.3.1
결과
구성 모드에서 show interfaces
, show protocols
, show policy-options
및 show routing-options
명령을 입력하여 구성을 확인합니다. 출력 결과가 의도한 구성대로 표시되지 않으면 이 예의 지침을 반복하여 구성을 수정하십시오.
user@R3# show interfaces fe-1/2/0 { unit 5 { family inet { address 172.16.13.3/24; } } } fe-1/2/1 { unit 6 { family inet { address 172.16.34.3/24; } } } lo0 { unit 3 { family inet { address 192.168.3.1/32; } } }
user@R3# show protocols bgp { group internal { type internal; local-address 192.168.3.1; export send-direct; neighbor 192.168.1.1; neighbor 192.168.2.1; } group external { type external; export send-direct; peer-as 4; neighbor 172.16.34.4; } } ospf { area 0.0.0.0 { interface lo0.3 { passive; } interface fe-1/2/0.5; interface fe-1/2/1.6; } }
user@R3# show policy-options policy-statement send-direct { term 1 { from protocol direct; then accept; } }
user@R3# show routing-options autonomous-system 123; router-id 192.168.3.1;
디바이스 구성을 마쳤으면 구성 모드에서 commit
을(를) 입력합니다.
디바이스 R4 구성
단계별 절차
다음 예는 구성 계층에서 다양한 수준의 탐색이 필요합니다. CLI 탐색 관련 정보는 Junos OS CLI 사용자 가이드의 구성 모드에서의 CLI 편집기 사용을 참조하십시오.
디바이스 R4 구성:
디바이스 인터페이스를 구성합니다.
[edit interfaces fe-1/2/0 unit 7] user@R4# set family inet address 172.16.24.4/24 [edit interfaces fe-1/2/1 unit 8] user@R4# set family inet address 172.16.34.4/24 [edit interfaces lo0 unit 4] user@R4# set family inet address 192.168.4.1/32 user@R4# set family inet address 172.16.44.0/32 user@R4# set family inet address 172.16.144.0/32
디바이스 R4에는 보급된 접두사를 시뮬레이션하기 위한 여러 루프백 인터페이스 주소가 있습니다.
직접 경로를 수용하는 정책을 구성합니다.
이 시나리오의 다른 유용한 옵션은 OSPF 또는 로컬 경로를 통해 학습된 경로를 수용하는 것일 수 있습니다.
[edit policy-options policy-statement send-direct term 1] user@R4# set from protocol direct user@R4# set then accept
BGP를 구성합니다.
[edit protocols bgp group external] user@R4# set type external user@R4# set export send-direct user@R4# set peer-as 123
두 개의 MED 정책을 구성합니다.
[edit policy-options] set policy-statement med-10 from route-filter 172.16.144.0/32 exact set policy-statement med-10 then metric 10 set policy-statement med-10 then accept set policy-statement med-30 from route-filter 0.0.0.0/0 longer set policy-statement med-30 then metric 30 set policy-statement med-30 then accept
두 개의 EBGP 인접 라우터를 구성하고, 두 개의 MED 정책을 디바이스 R3에 적용하고, MED 값 20을 디바이스 R2에 적용합니다.
[edit protocols bgp group external] user@R4# set neighbor 172.16.34.3 export med-10 user@R4# set neighbor 172.16.34.3 export med-30 user@R4# set neighbor 172.16.24.2 metric-out 20
라우터 ID 및 AS(Autonomous System) 번호를 구성합니다.
[edit routing-options] user@R4# set autonomous-system 4 user@R4# set router-id 192.168.4.1
결과
구성 모드에서 show interfaces
, show protocols
, show policy-options
및 show routing-options
명령을 입력하여 구성을 확인합니다. 출력 결과가 의도한 구성대로 표시되지 않으면 이 예의 지침을 반복하여 구성을 수정하십시오.
user@R4# show interfaces fe-1/2/0 { unit 7 { family inet { address 172.16.24.4/24; } } } fe-1/2/1 { unit 8 { family inet { address 172.16.34.4/24; } } } lo0 { unit 4 { family inet { address 192.168.4.1/32; address 172.16.44.0/32; address 172.16.144.0/32; } } }
user@R4# show protocols bgp { group external { type external; export send-direct; peer-as 123; neighbor 172.16.24.2 { metric-out 20; } neighbor 172.16.34.3 { export [ med-10 med-30 ]; } } }
user@R4# show policy-options policy-statement med-10 { from { route-filter 172.16.144.0/32 exact; } then { metric 10; accept; } } policy-statement med-30 { from { route-filter 0.0.0.0/0 longer; } then { metric 30; accept; } } policy-statement send-direct { term 1 { from protocol direct; then accept; } }
user@R4# show routing-options autonomous-system 4; router-id 192.168.4.1;
디바이스 구성을 마쳤으면 구성 모드에서 commit
을(를) 입력합니다.
검증
구성이 올바르게 작동하고 있는지 확인합니다.
디바이스 R1에서 디바이스 R4로의 활성 경로 확인
목적
활성 경로가 디바이스 R2를 통과하는지 확인합니다.
작업
운영 모드에서 show route protocol bgp
명령을 입력합니다.
user@R1> show route protocol bgp inet.0: 13 destinations, 19 routes (13 active, 0 holddown, 0 hidden) + = Active Route, - = Last Active, * = Both 172.16.12.0/24 [BGP/170] 4d 01:13:32, localpref 100, from 192.168.2.1 AS path: I > to 172.16.12.2 via fe-1/2/0.1 172.16.13.0/24 [BGP/170] 3d 05:36:10, localpref 100, from 192.168.3.1 AS path: I > to 172.16.13.3 via fe-1/2/1.2 172.16.24.0/24 [BGP/170] 4d 01:13:32, localpref 100, from 192.168.2.1 AS path: I > to 172.16.12.2 via fe-1/2/0.1 172.16.34.0/24 [BGP/170] 3d 05:36:10, localpref 100, from 192.168.3.1 AS path: I > to 172.16.13.3 via fe-1/2/1.2 172.16.44.0/32 *[BGP/170] 00:06:03, MED 20, localpref 100, from 192.168.2.1 AS path: 4 I > to 172.16.12.2 via fe-1/2/0.1 172.16.144.0/32 *[BGP/170] 00:06:03, MED 10, localpref 100, from 192.168.3.1 AS path: 4 I > to 172.16.13.3 via fe-1/2/1.2 192.168.2.1/32 [BGP/170] 4d 01:13:32, localpref 100, from 192.168.2.1 AS path: I > to 172.16.12.2 via fe-1/2/0.1 192.168.3.1/32 [BGP/170] 3d 05:36:10, localpref 100, from 192.168.3.1 AS path: I > to 172.16.13.3 via fe-1/2/1.2 192.168.4.1/32 *[BGP/170] 00:06:03, MED 20, localpref 100, from 192.168.2.1 AS path: 4 I > to 172.16.12.2 via fe-1/2/0.1
의미
출력 결과, 디바이스 R4가 보급하는 경로의 기본 경로는 172.16.144.0/32를 제외한 모든 경로에 대해 디바이스 R2를 통과하는 것입니다. 172.16.144.0/32의 경우 기본 경로는 디바이스 R3을 통과하는 것입니다.
디바이스 R4가 경로를 올바르게 전송하고 있는지 확인
목적
디바이스 R4가 디바이스 R2에 20 값, 디바이스 R3에 30 값을 가진 업데이트 메시지를 전송하고 있는지 확인합니다.
작업
운영 모드에서 show route advertising-protocol bgp
명령을 입력합니다.
user@R4> show route advertising-protocol bgp 172.16.24.2 inet.0: 11 destinations, 13 routes (11 active, 0 holddown, 0 hidden) Prefix Nexthop MED Lclpref AS path * 172.16.24.0/24 Self 20 I * 172.16.34.0/24 Self 20 I * 172.16.44.0/32 Self 20 I * 172.16.144.0/32 Self 20 I * 192.168.4.1/32 Self 20 I
user@R4> show route advertising-protocol bgp 172.16.34.3 inet.0: 11 destinations, 13 routes (11 active, 0 holddown, 0 hidden) Prefix Nexthop MED Lclpref AS path * 172.16.24.0/24 Self 30 I * 172.16.34.0/24 Self 30 I * 172.16.44.0/32 Self 30 I * 172.16.144.0/32 Self 10 I * 192.168.4.1/32 Self 30 I
의미
MED 열은 디바이스 R4가 두 개의 EBGP 인접 라우터에 올바른 MED 값을 전송하고 있음을 보여줍니다.