Set and Verify DCB Traffic-Class Maximum Rates with dcb maxrate
Confuse Gbit with GB in a dcb maxrate command and you can cap a traffic class at an eighth of the speed you meant. This guide inspects, and if the device supports it, sets the maximum egress rate for each DCB traffic class, using a map from traffic-class numbers 0 through 7 to rates such as 25Gbit. Allow about 15 minutes for a read-only check, longer if you need to coordinate a live network change.
The route
Jump straight to the step you need, or tick off Done means at the end.
You need the iproute2 package, a DCB-capable network device, and its interface name. The examples use eth0 as a placeholder: replace it with the actual device before you press enter. Reading settings is normally unprivileged on a suitable system; changing them normally needs root or the relevant network administration capability.
1. Confirm the installed command
This guide follows the installed dcb from iproute2 6.1.0. Check the local binary and its supported syntax:
$ dcb -V
dcb utility, iproute2-6.1.0
$ dcb maxrate help
Usage: dcb maxrate help
Usage: dcb [ -i ] maxrate show dev STRING
[ tc-maxrate ]
Usage: dcb maxrate set dev STRING
[ tc-maxrate RATE-MAP ]
The exact package revision may differ on another distribution. The part that matters locally is the maxrate object, with its show and set commands.
2. Inspect the current map
Start with a read-only query. With no parameter name, show asks for the complete maxrate configuration:
$ dcb maxrate show dev eth0
tc-maxrate 0:25Gbit 1:25Gbit 2:25Gbit 3:25Gbit 4:25Gbit 5:25Gbit 6:100Gbit 7:25Gbit
Your output reflects the device, driver and firmware in front of you. The shape that matters is tc-maxrate followed by mappings such as 6:100Gbit: the class number sits on the left, the maximum rate on the right.
Checkpoint
Record the current output before you change anything. It is the simplest recovery reference if you need to put the previous values back.
3. Read rates with ISO prefixes when needed
The top-level -i option toggles between decimal prefixes and ISO/IEC prefixes when rates are displayed. Run both forms if a unit boundary actually matters to your capacity calculation:
$ dcb -i maxrate show dev eth0
$ dcb maxrate show dev eth0
Do not read Gbit as bytes. In this command's notation, bit means bits per second and b means bytes per second, and mixing the two up is the fastest way to under- or over-provision a class by a factor of eight. The manual also accepts units such as Kbit and Mib. Use the spelling that matches what you actually mean, then verify the displayed map.
4. Set a complete, explicit map
Changing a device's egress limits can affect live traffic. Schedule the change with whoever owns the link, note down the old map, and reach for elevated privileges only for the write itself:
$ sudo dcb maxrate set dev eth0 tc-maxrate all:25Gbit 6:100Gbit
The all:25Gbit mapping gives every traffic class the same rate, then 6:100Gbit overrides class 6 on top of that. Traffic classes 0 through 7 are the only accepted class indices. The command writes straight to the device; it is not preparing a file for a later service restart.
Verify the result immediately:
$ sudo dcb maxrate show dev eth0
tc-maxrate 0:25Gbit 1:25Gbit 2:25Gbit 3:25Gbit 4:25Gbit 5:25Gbit 6:100Gbit 7:25Gbit
If the command prints an error, treat the whole change as unconfirmed. Run the read command again rather than assuming part of the map made it through.
5. Change selected classes carefully
A rate map can hold individual class mappings too. For a targeted change, name only the class you actually intend to alter:
$ sudo dcb maxrate set dev eth0 tc-maxrate 6:100Gbit
$ sudo dcb maxrate show dev eth0
Use this form only once you understand how the device treats the entries you left out. A complete map is usually the safer, more repeatable choice, because it states the value you want for every class instead of leaning on whatever was already there. Do not mix up a class number with a queue number: the documented key here is a traffic-class index, nothing else.
6. Restore the previous values
There is no separate undo command in dcb maxrate. Recovery means setting the old map again. To restore the map captured earlier:
$ sudo dcb maxrate set dev eth0 tc-maxrate all:25Gbit 6:100Gbit
$ sudo dcb maxrate show dev eth0
If your recorded map differs, swap in its exact class and rate pairs. Keep the old output around until the restored map has been checked. Warning: do not use a guessed zero rate as an undo: that is a new traffic policy in its own right, and the manpage does not define it as any kind of reset.
7. Diagnose an unsupported device
Success here depends on support from the network driver and device. On a device without the required DCB attribute, a query can fail like this:
$ dcb maxrate show dev lo
Attribute read: Operation not supported
That is not evidence of a hidden default maxrate map. Check the interface name, confirm the adapter and driver actually provide DCB maxrate support, and inspect the kernel and driver logs through your normal process. Do not keep retrying a write against an interface that already told you the attribute is unsupported.
A failure can also come from a misspelled device, insufficient privilege, an invalid rate, or a malformed map. Check the exit status in a script rather than guessing from the output alone:
if sudo dcb maxrate show dev eth0; then
printf '%s\n' 'maxrate query succeeded'
else
status=$?
printf 'maxrate query failed with status %s\n' "$status" >&2
exit "$status"
fi
The documented exit status is zero for success and a positive value for failure. Preserve the actual status in automation; do not let every failure quietly turn into a claim that the rate is zero.
Done means
- Know the installed iproute2 version and the target interface.
- Read and recorded the existing tc-maxrate map before any write.
- Checked the traffic impact and used the required privilege before writing rates.
- Confirmed the post-change query shows the intended class-to-rate mappings.
- Kept a tested restoration command and the previous map, ready if you need to reverse it.