예: 이벤트 정책을 사용하여 구성 변경
특정 이벤트에 대응하여 구성을 수정해야 할 수도 있습니다. Junos OS 릴리스 12.1부터 이벤트 정책을 구성하여 하나 이상의 특정 이벤트에 의해 이벤트 정책이 트리거될 때 구성 변경을 적용하고 커밋할 수 있습니다.
이 예에서는 특정 인터페이스에 대한 SNMP_TRAP_LINK_DOWN 이벤트를 시뮬레이션합니다. 이벤트가 수신되면 이벤트 정책은 조치를 사용하여 change-configuration 정적 경로의 구성을 수정하여 다른 출구 인터페이스를 통해 새로운 넥트 홉 IP 주소를 사용합니다.
요구 사항
Junos OS 릴리스 12.1 이상에서 실행되는 라우팅, 스위칭 또는 보안 디바이스
개요
단일 이벤트 또는 상관 이벤트에 의해 정책이 트리거될 때 이벤트 정책 작업을 구성하여 구성을 수정할 수 있습니다. exit 인터페이스 ge-0/3/1을 통해 10.1.2.1의 넥스트 홉 IP 주소가 있는 10.1.10.0/24 네트워크로 정적 경로가 있다고 가정해 보십시오. 이 인터페이스가 다운되면 SNMP_TRAP_LINK_DOWN 이벤트가 시작됩니다.
이 예에서는 업데이트-온-snmp-trap-link-down이라는 이벤트 정책을 만듭니다. 이벤트 정책은 이벤트 프로세스가 인터페이스 ge-0/3/1.0과 관련된 SNMP_TRAP_LINK_DOWN 이벤트를 수신 대기하도록 구성됩니다. 인터페이스가 다운되면 이벤트 정책이 변경 구성 작업을 실행합니다. 이벤트 정책 구성 명령은 ge-0/3/1 출구 인터페이스를 통해 정적 경로를 제거하고 exit 인터페이스 ge-0/2/1을 통해 10.1.3.1의 넥스트 홉 IP 주소로 동일한 대상 네트워크에 새로운 정적 경로를 생성합니다. 명령어들은 이벤트 정책에 나타나는 순서대로 실행됩니다.
이벤트 정책 변경 구성 커밋 작업은 관련 이벤트 정책을 통해 변경이 이루어졌는지 명시한 커밋 주석과 함께 사용자 이름 bsmith에서 실행됩니다. 재시도 수는 5로 설정되고 재시도 간격은 4초로 설정됩니다. 최초 구성 변경 시도에 실패하면 시스템은 구성 변경을 5번 더 시도하며 각 시도 사이에 4초가 기다려야 합니다.
여기에서는 제공되지 않지만 인터페이스가 다시 가동될 때 정적 경로를 업데이트하기 위해 변경 구성 작업을 실행하는 유사한 두 번째 이벤트 정책이 있을 수 있습니다. 이 경우 정책은 동일한 인터페이스에 대해 SNMP_TRAP_LINK_UP 이벤트에서 트리거됩니다.
구성
CLI 빠른 구성
이 예제를 신속하게 구성하려면 다음 명령을 복사하여 텍스트 파일에 붙여넣고, 줄 바꿈을 제거하고, 네트워크 구성에 필요한 모든 세부 정보를 변경한 다음, 계층 수준에서 CLI [edit] 에 명령을 복사하여 붙여넣습니다.
set event-options policy update-on-snmp-trap-link-down events snmp_trap_link_down set event-options policy update-on-snmp-trap-link-down attributes-match snmp_trap_link_down.interface-name matches ge-0/3/1.0 set event-options policy update-on-snmp-trap-link-down then change-configuration retry count 5 set event-options policy update-on-snmp-trap-link-down then change-configuration retry interval 4 set event-options policy update-on-snmp-trap-link-down then change-configuration commands "delete routing-options static route 10.1.10.0/24 next-hop" set event-options policy update-on-snmp-trap-link-down then change-configuration commands "set routing-options static route 10.1.10.0/24 next-hop 10.1.3.1" set event-options policy update-on-snmp-trap-link-down then change-configuration user-name bsmith set event-options policy update-on-snmp-trap-link-down then change-configuration commit-options log "updating configuration from event policy update-on-snmp-trap-link-down" set routing-options static route 10.1.10.0/24 next-hop 10.1.2.1 set system syslog file syslog-event-daemon-warning daemon warning
이벤트 정책 구성
단계별 절차
이벤트 정책을 생성하고 이름을 지정합니다.
[edit] bsmith@R1# edit event-options policy update-on-snmp-trap-link-down
이벤트 정책이 SNMP_TRAP_LINK_DOWN
events이벤트에 트리거되도록 명령문을 구성합니다.attributes-matchge-0/3/1.0 인터페이스에 대해 SNMP_TRAP_LINK_DOWN 이벤트가 발생하는 경우에만 정책이 실행되도록 명령문을 설정합니다.[edit event-options policy update-on-snmp-trap-link-down] bsmith@R1# set events snmp_trap_link_down bsmith@R1# set attributes-match snmp_trap_link_down.interface-name matches ge-0/3/1.0
ge-0/3/1 인터페이스가 다운되면 실행되는 구성 모드 명령을 지정합니다.
단일 라인에서 각 명령을 구성하고, 명령 문자열을 따옴표로 동봉하고, 전체 명령문 경로를 지정합니다.
[edit event-options policy update-on-snmp-trap-link-down then change-configuration] bsmith@R1# set commands "delete routing-options static route 10.1.10.0/24 next-hop" bsmith@R1# set commands "set routing-options static route 10.1.10.0/24 next-hop 10.1.3.1"
커밋 옵션을 구성합니다.
log구성 변경 사항을 설명하는 주석으로 옵션을 구성합니다. 관련 이벤트 정책을 통해 성공적인 커밋 작업이 수행된 후 주석이 커밋 로그에 추가됩니다.[edit event-options policy update-on-snmp-trap-link-down then change-configuration] bsmith@R1# set commit-options log "updating configuration from event policy update-on-snmp-trap-link-down"
듀얼 라우팅 엔진이 있는 경우, 두 라우팅 엔진 모두에서 구성을 커밋하는 옵션을 구성
synchronize하십시오.force경고를 무시하고 다른 라우팅 엔진에 대한 커밋을 강제하는 옵션을 포함합니다. 이 예에서는 해당 옵션과force옵션을 구성synchronize하지 않습니다.(선택사항) 재시도 횟수 및 재시도 간격을 구성합니다.
이 예
count에서는 5로 설정되고interval4초입니다.[edit event-options policy update-on-snmp-trap-link-down then change-configuration] bsmith@R1# set retry count 5 interval 4
(선택사항) 구성 변경 및 커밋의 권한에 따라 사용자 이름을 구성합니다.
사용자 이름을 지정하지 않으면 작업이 사용자 루트로 실행됩니다.
[edit event-options policy update-on-snmp-trap-link-down then change-configuration] bsmith@R1# set user-name bsmith
계층 수준에서 새 로그 파일을
[edit system syslog]구성하여 시설daemon및 심각도의 syslog 이벤트를 기록합니다warning.이는 SNMP_TRAP_LINK_DOWN 이벤트를 캡처합니다.
[edit system syslog] bsmith@R1# set file syslog-event-daemon-warning daemon warning
이 예제를 테스트하려면 다음 홉 IP 주소가 10.1.2.1인 10.1.10.0/24 네트워크로 정적 경로를 구성합니다.
[edit] bsmith@R1# set routing-options static route 10.1.10.0/24 next-hop 10.1.2.1
구성을 커밋합니다.
bsmith@R1# commit
[edit routing-options static]ge-0/3/1 인터페이스를 비활성화하기 전에 구성의 계층 수준을 검토하고 다음 홉 IP 주소를 확인합니다.bsmith@R1> show configuration routing-options static ... route 10.1.10.0/24 next-hop 10.1.2.1; ...
이벤트 정책을 수동으로 테스트하려면 ge-0/3/1 인터페이스를 일시적으로 오프라인으로 전환하여 SNMP_TRAP_LINK_DOWN 이벤트를 생성합니다.
[edit] bsmith@R1# set interfaces ge-0/3/1 disable bsmith@R1# commit
결과
[edit]
event-options {
policy update-on-snmp-trap-link-down {
events snmp_trap_link_down;
attributes-match {
snmp_trap_link_down.interface-name matches ge-0/3/1.0;
}
then {
change-configuration {
retry count 5 interval 4;
commands {
"delete routing-options static route 10.1.10.0/24 next-hop";
"set routing-options static route 10.1.10.0/24 next-hop 10.1.3.1";
}
user-name bsmith;
commit-options {
log "updating configuration from event policy update-on-snmp-trap-link-down";
}
}
}
}
}
routing-options {
static {
route 10.1.10.0/24 next-hop 10.1.2.1;
}
}
system {
syslog {
file syslog-event-daemon-warning {
daemon warning;
}
}
}
확인
구성이 올바르게 작동하는지 확인합니다.
인터페이스 상태 검증
목적
ge-0/3/1 인터페이스가 다운되고 SNMP_TRAP_LINK_DOWN 이벤트가 트리거되었는지 확인합니다.
작업
show interfaces ge-0/3/1 운영 모드 명령을 실행합니다. 명령 출력은 인터페이스가 관리적으로 오프라인 상태임을 보여줍니다.
bsmith@R1> show interfaces ge-0/3/1 Physical interface: ge-0/3/1, Administratively down, Physical link is Down <output omitted>
7단계에서 구성된 시스템 로그 파일의 내용을 검토 합니다. 출력은 ge-0/3/1.0 인터페이스가 다운되어 SNMP_TRAP_LINK_DOWN 이벤트를 생성한 것을 보여줍니다.
bsmith@R1> show log syslog-event-daemon-warning Oct 10 18:00:57 R1 mib2d[1371]: SNMP_TRAP_LINK_DOWN: ifIndex 531, ifAdminStatus down(2), ifOperStatus down(2), ifName ge-0/3/1.0
커밋 확인
목적
커밋 로그와 메시지 로그 파일을 검토함으로써 이벤트 정책 커밋 작업이 성공적이었는지 확인합니다.
작업
커밋 로그를 show system commit 보려면 운영 모드 명령을 실행합니다. 이 예제에서 로그는 지정된 날짜와 시간에 사용자 장인의 권한에 따라 이벤트 정책을 통해 구성이 커밋된 것을 확인합니다.
bsmith@R1> show system commit
0 2011-10-10 18:01:03 PDT by bsmith via junoscript
updating configuration from event policy update-on-snmp-trap-link-down
1 2011-09-02 14:16:44 PDT by admin via netconf
2 2011-07-08 14:33:46 PDT by root via other
메시지 로그 파일을 검토 합니다 . SNMP_TRAP_LINK_DOWN 이벤트를 수신한 후 Junos OS는 구성을 수정하고 커밋하기 위해 구성된 이벤트 정책 작업을 실행했습니다. 커밋 작업은 사용자 장인의 권한 하에서 발생했습니다.
bsmith@R1> show log messages | last 20 ... Oct 10 18:00:57 R1 mib2d[1371]: SNMP_TRAP_LINK_DOWN: ifIndex 531, ifAdminStatus down(2), ifOperStatus down(2), ifName ge-0/3/1.0 Oct 10 18:00:59 R1 file[17575]: UI_COMMIT: User 'bsmith' requested 'commit' operation (comment: updating configuration from event policy update-on-snmp-trap-link-down) Oct 10 18:01:03 R1 eventd: EVENTD_CONFIG_CHANGE_SUCCESS: Configuration change successful: while executing policy update-on-snmp-trap-link-down with user bsmith privileges
다른 로그 파일을 구성하는 경우 구성에 맞는 파일을 검토합니다.
의미
운영 모드 명령과 메시지 로그 파일의 show system commit 출력은 사용자 장인의 권한 하에 이벤트 정책을 통해 수행된 커밋 작업이 성공적이었는지 확인합니다. 출력 및 메시지 로그 파일은 show system commit 계층 수준의 명령문에 log 지정된 커밋 주석을 [edit event-options policy update-on-snmp-trap-link-down then change-configuration commit-options] 참조합니다.
구성 변경 확인
목적
ge-0/3/1 인터페이스를 비활성화한 후 구성의 계층 수준을 검토 [edit routing-options static] 하여 구성 변경 사항을 확인합니다.
작업
다음 운영 모드 명령을 실행합니다.
bsmith@R1> show configuration routing-options static ... route 10.1.10.0/24 next-hop 10.1.3.1; ...
의미
구성된 다음 홉은 이벤트 정책에 따라 exit 인터페이스 ge-0/2/1을 통과하는 경로가 있는 새로운 IP 주소 10.1.3.1로 수정되었습니다.
문제 해결
커밋 오류 문제 해결
문제
트리거된 이벤트 정책은 지정된 구성 변경을 수행하지 않으며, 로그는 커밋이 성공하지 못했는지 확인합니다.
bsmith@R1> show log messages | last 20 ... Oct 10 17:48:59 R1 mib2d[1371]: SNMP_TRAP_LINK_DOWN: ifIndex 531, ifAdminStatus down(2), ifOperStatus down(2), ifName ge-0/3/1.0 Oct 10 17:49:01 R1 file[17142]: UI_LOAD_EVENT: User 'bsmith' is performing a 'rollback' Oct 10 17:49:01 R1 eventd: EVENTD_CONFIG_CHANGE_FAILED: Configuration change failed: rpc to management daemon failed while executing policy update-on-snmp-trap-link-down with user bsmith privileges
구성이 잠겨 있거나 구성 모드 명령이 잘못된 구문 또는 순서가 있는 경우 장애가 발생할 수 있습니다.
솔루션
계층 수준에서 구성 모드 명령을 [edit event-options policy update-on-snmp-trap-link-down then change-configuration commands] 확인하고 구문과 실행 순서가 올바른지 확인합니다.
또한 재시도 횟수와 간격 옵션을 증가시 하여 구성이 잠기면 이벤트 정책이 첫 번째 인스턴스에 실패한 후 지정된 횟수로 구성 변경을 시도합니다.