Junos CoS Configuration: Classifiers, Schedulers, Rewrite Rules - 夜莺博客

Junos CoS Configuration: Classifiers, Schedulers, Rewrite Rules

Juniper Junos Class of Service (CoS) can look intimidating because traffic treatment is split across several mapping components: a classifier marks packets at ingress, a scheduler-map picks which queue each forwarding class uses, and a rewrite rule re-marks packets at egress. This guide explains the data flow between those components and gives you a complete, copy-paste Junos CoS configuration for prioritising voice traffic, from class-of-service hierarchy to verification commands on MX and QFX platforms.

How the Junos CoS Components Map Together

Junos CoS is built from four mapping tables. Classifiers map incoming code-points (DSCP, 802.1p, MPLS EXP) to a forwarding class + loss priority. Scheduler-maps assign each forwarding class to a scheduler (transmit rate, buffer, priority). Drop-profile maps tie loss priority to a drop profile, and rewrite-rules map forwarding class + loss priority back to egress code-points so the marking survives to the next hop. Getting these four tables consistent is the whole game.

Defining Forwarding Classes and a Classifier

Start by mapping DSCP EF (voice) to an expedited-forwarding queue and copying the default classifier as a base:

set class-of-service forwarding-classes class expedited-forwarding queue 5
set class-of-service classifiers dscp voice-classifier import default
set class-of-service classifiers dscp voice-classifier forwarding-class expedited-forwarding loss-priority low code-points ef

Creating a Scheduler and Scheduler-Map

Give the voice queue strict-high priority plus a guaranteed transmit rate, and the best-effort queue the remainder:

set class-of-service schedulers ef-scheduler transmit-rate percent 30
set class-of-service schedulers ef-scheduler buffer-size percent 20
set class-of-service schedulers ef-scheduler priority strict-high
set class-of-service scheduler-maps smap1 forwarding-class expedited-forwarding scheduler ef-scheduler

Configuring Rewrite Rules and Applying CoS to an Interface

Rewrite the DSCP value on egress so downstream devices still see the marking, then attach classifier, scheduler-map and rewrite rule to the logical interface:

set class-of-service rewrite-rules dscp dscp-rewrite forwarding-class expedited-forwarding loss-priority low code-point ef
set class-of-service interfaces ge-0/0/0 unit 0 classifiers dscp voice-classifier
set class-of-service interfaces ge-0/0/0 unit 0 scheduler-map smap1
set class-of-service interfaces ge-0/0/0 unit 0 rewrite-rules dscp dscp-rewrite
commit

Verification Commands

Check the applied CoS state on the interface and the configured tables:

show class-of-service interface ge-0/0/0
show class-of-service classifier dscp
show class-of-service scheduler-map
show class-of-service forwarding-class

Juniper documentation stresses that on QFX and MX switches you should verify the forwarding-class-to-queue mapping matches the platform default queues to avoid accidentally renumbering queues that control traffic uses.

Related Guides on This Site

Combine CoS with a working underlay: see our Junos OSPF configuration guide, the Junos static route and qualified next-hop guide, and the Arista EOS QoS configuration guide for a cross-vendor comparison of marking and queueing.

原文链接:https://www.juniper.net/documentation/us/en/software/junos/cos/topics/task/cos-inputs-outputs-sample-configs.html