이 페이지의 내용
예: RIP 그룹에 T1 인터페이스 추가
이 예에서는 커밋 스크립트를 사용하여 수동 구성의 양을 줄이는 방법, 특히 계층 수준에서 [edit protocols rip group test]
구성된 [edit interfaces]
모든 T1 인터페이스를 계층 수준에 추가하는 방법을 보여줍니다.
요구 사항
이 예에서는 T1 인터페이스로 Junos OS를 실행하는 디바이스를 사용합니다.
개요 및 커밋 스크립트
인터페이스에서 RIP를 활성화하려면 및 [edit protocols rip]
계층 수준 모두에서 [edit interfaces]
변경해야 합니다. 이 예에서는 커밋 스크립트를 사용하여 계층 수준에서 [edit protocols rip group test]
구성된 [edit interfaces]
모든 T1 인터페이스를 계층 수준에 추가하는 방법을 보여줍니다. 이 예제에는 오류, 경고 또는 시스템 로그 메시지가 포함되어 있지 않습니다. 구성에 대한 변경은 자동으로 이루어집니다.
예제 스크립트는 XSLT 및 SLAX 구문으로 표시됩니다.
XSLT 구문
<?xml version="1.0" standalone="yes"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:junos="http://xml.juniper.net/junos/*/junos" xmlns:xnm="http://xml.juniper.net/xnm/1.1/xnm" xmlns:jcs="http://xml.juniper.net/junos/commit-scripts/1.0"> <xsl:import href="../import/junos.xsl"/> <xsl:template match="configuration"> <xsl:variable name="all-t1" select="interfaces/interface[starts-with(name, 't1-')]"/> <xsl:if test="$all-t1"> <change> <protocols> <rip> <group> <name>test</name> <xsl:for-each select="$all-t1"> <xsl:variable name="ifname" select="concat(name, '.0')"/> <neighbor> <name><xsl:value-of select="$ifname"/></name> </neighbor> </xsl:for-each> </group> </rip> </protocols> </change> </xsl:if> </xsl:template> </xsl:stylesheet>
SLAX 구문
version 1.0; ns junos = "http://xml.juniper.net/junos/*/junos"; ns xnm = "http://xml.juniper.net/xnm/1.1/xnm"; ns jcs = "http://xml.juniper.net/junos/commit-scripts/1.0"; import "../import/junos.xsl"; match configuration { var $all-t1 = interfaces/interface[starts-with(name, 't1-')]; if ($all-t1) { <change> { <protocols> { <rip> { <group> { <name> "test"; for-each ($all-t1) { var $ifname = name _ '.0'; <neighbor> { <name> $ifname; } } } } } } } }
구성
절차
단계별 절차
스크립트를 다운로드, 사용 및 테스트하려면:To download, enable, and test the script:
스크립트를 텍스트 파일에 복사하고 파일 이름을 rip-t1.xsl 또는 rip-t1.slax로 적절하게 지정한 다음 디바이스의 /var/db/scripts/commit/ 디렉터리에 복사합니다.
다음 테스트 구성 스탠자를 선택하고 Ctrl+c를 눌러 클립보드에 복사하십시오.
SLAX 버전의 스크립트를 사용하는 경우 계층 수준에서 파일 이름을
[edit system scripts commit file]
rip-t1.slax로 변경합니다.system { scripts { commit { file rip-t1.xsl; } } } interfaces { t1-0/0/0 { unit 0 { family iso; } } t1-0/0/1 { unit 0 { family iso; } } t1-0/0/2 { unit 0 { family iso; } } t1-0/0/3 { unit 0 { family iso; } } t1-0/1/0 { unit 0 { family iso; } } t1-0/1/1 { unit 0 { family iso; } } t1-0/1/2 { unit 0 { family iso; } } t1-0/1/3 { unit 0 { family iso; } } }
구성 모드에서 명령을 실행하여
load merge terminal
스탠자를 디바이스 구성에 병합합니다.[edit] user@host# load merge terminal [Type ^D at a new line to end input] ... Paste the contents of the clipboard here ...
프롬프트에서 마우스와 붙여넣기 아이콘을 사용하여 클립보드의 내용을 붙여넣습니다.
Enter.
Ctrl+d를 누릅니다.
구성을 커밋합니다.
user@host# commit
확인
구성 확인
목적
스크립트가 예상대로 작동하는지 확인합니다.
작업
show protocols rip group test
명령을 실행합니다. 이제 모든 T1 인터페이스가 계층 수준 아래에 [edit protocols rip group test]
나타납니다.
[edit] user@host# show protocols rip group test neighbor t1-0/0/0.0; neighbor t1-0/0/1.0; neighbor t1-0/0/2.0; neighbor t1-0/0/3.0; neighbor t1-0/1/0.0; neighbor t1-0/1/1.0; neighbor t1-0/1/2.0; neighbor t1-0/1/3.0;