이 페이지에서
예: 커밋 스크립트를 사용하여 분류자 할당
IPv4 프로토콜 체계로 구성된 각 인터페이스에 대해 이 커밋 스크립트는 지정된 분류기를 자동으로 할당합니다. 이 분류기는 수신 패킷을 포워딩 클래스 및 손실 우선순위와 연결하고 출력 대기열에 패킷을 할당합니다.
요구 사항
이 예는 Junos OS 실행하는 디바이스를 사용합니다.
개요 및 커밋 스크립트
Junos OS CoS(classifier)에서는 수신 패킷을 포워딩 클래스 및 손실 우선순위와 연결하고, 관련 포워딩 클래스에 따라 패킷을 출력 대기열에 할당할 수 있습니다. 분류기를 구성한 후 입력 인터페이스에 할당해야 합니다.
IPv4 프로토콜 체계로 구성된 각 인터페이스에 대해 이 스크립트는 라는 지정된 분류기를 fc-q3
자동으로 할당합니다. fc-q3
분류자는 계층 수준에서 구성 [edit class-of-service]
되어야 합니다.
예제 스크립트는 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="cos-all" select="class-of-service"/> <xsl:for-each select="interfaces/interface[contains(name, '/')]/unit[family/inet]"> <xsl:variable name="ifname" select="../name"/> <xsl:variable name="unit" select="name"/> <xsl:variable name="cos" select="$cos-all/interfaces[name = $ifname]"/> <xsl:if test="not($cos/unit[name = $unit])"> <xsl:call-template name="jcs:emit-change"> <xsl:with-param name="message"> <xsl:text>Adding CoS forwarding class for </xsl:text> <xsl:value-of select="concat($ifname, '.', $unit)"/> </xsl:with-param> <xsl:with-param name="dot" select="$cos-all"/> <xsl:with-param name="content"> <interfaces> <name><xsl:value-of select="$ifname"/></name> <unit> <name><xsl:value-of select="$unit"/></name> <forwarding-class>fc-q3</forwarding-class> </unit> </interfaces> </xsl:with-param> </xsl:call-template> </xsl:if> </xsl:for-each> </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 $cos-all = class-of-service; for-each (interfaces/interface[contains(name, '/')]/unit[family/inet]) { var $ifname = ../name; var $unit = name; var $cos = $cos-all/interfaces[name = $ifname]; if (not($cos/unit[name = $unit])) { call jcs:emit-change($dot = $cos-all) { with $message = { expr "Adding CoS forwarding class for "; expr $ifname _ '.' _ $unit; } with $content = { <interfaces> { <name> $ifname; <unit> { <name> $unit; <forwarding-class> "fc-q3"; } } } } } } }
구성
절차
단계별 절차
스크립트를 다운로드, 활성화 및 테스트하려면,
스크립트를 텍스트 파일로 복사하여 파일 classifier.xsl 또는 classifier.slax 의 이름을 적절히 지정하고 디바이스의 /var/db/scripts/commit/ directory로 복사합니다.
다음 테스트 구성 stanzas를 선택하고 Ctrl+c를 눌러 클립보드로 복사합니다.
스크립트의 SLAX 버전을 사용하는 경우, 계층 수준에서 파일 이름을
[edit system scripts commit file]
classifier.slax로 변경합니다.system { scripts { commit { file classifier.xsl; } } } interfaces { fe-0/0/0 { unit 0 { family inet { address 10.168.16.2/24; } } } } class-of-service { forwarding-classes { queue 3 fc-q3; } classifiers { inet-precedence fc-q3 { forwarding-class fc-q3 { loss-priority low code-points 010; } } } }
구성 모드에서 명령을 실행
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
확인
구성 확인
목적
스크립트가 예상대로 작동하는지 확인합니다.
작업
명령의 출력을 검토합니다commit
. 테스트 구성 stanzas에서 fe-0/0/0.0 인터페이스는 문으로 family inet
구성됩니다. 인터페이스가 IPv4 프로토콜 체계로 구성되므로 스크립트는 명령 출력에 표시된 인터페이스에 commit
분류기를 자동으로 할당 fc-q3
합니다.
[edit] user@host# commit [edit interfaces interface fe-0/0/0 unit 0] warning: Adding CoS forwarding class for fe-0/0/0.0 commit complete
구성을 확인하여 스크립트에서 생성된 변경 사항이 존재하는지 확인합니다. 구성 모드 명령을 실행합니다 show class-of-service
. 출력은 fe-0/0/0.0 인터페이스에 fc-q3
분류기가 할당되었음을 보여줍니다.
[edit] user@host# show class-of-service classifiers { inet-precedence fc-q3 { forwarding-class fc-q3 { loss-priority low code-points 010; } } } forwarding-classes { queue 3 fc-q3; } interfaces { fe-0/0/0 { unit 0 { forwarding-class fc-q3; # Added by commit script } } }