How to check if a network QoS policy is active in Linux

LinuxLinuxBeginner
Practice Now

Introduction

In this lab, you will learn how to check if a network Quality of Service (QoS) policy is active in Linux. You will use the powerful tc command to list and inspect QoS disciplines and classes configured on your network interfaces.

Specifically, you will first use tc qdisc show to list the active queueing disciplines, understanding their role in managing network traffic. Then, you will explore how to check QoS classes with tc class, which are used to categorize and prioritize different types of traffic. Finally, you will learn how to inspect the network configuration files in /etc/network to understand how QoS policies might be persistently configured.


Skills Graph

%%%%{init: {'theme':'neutral'}}%%%% flowchart RL linux(("Linux")) -.-> linux/BasicSystemCommandsGroup(["Basic System Commands"]) linux(("Linux")) -.-> linux/BasicFileOperationsGroup(["Basic File Operations"]) linux(("Linux")) -.-> linux/RemoteAccessandNetworkingGroup(["Remote Access and Networking"]) linux/BasicSystemCommandsGroup -.-> linux/help("Command Assistance") linux/BasicSystemCommandsGroup -.-> linux/man("Manual Access") linux/BasicFileOperationsGroup -.-> linux/ls("Content Listing") linux/BasicFileOperationsGroup -.-> linux/cat("File Concatenating") linux/RemoteAccessandNetworkingGroup -.-> linux/ifconfig("Network Configuring") linux/RemoteAccessandNetworkingGroup -.-> linux/netstat("Network Monitoring") linux/RemoteAccessandNetworkingGroup -.-> linux/ip("IP Managing") subgraph Lab Skills linux/help -.-> lab-558741{{"How to check if a network QoS policy is active in Linux"}} linux/man -.-> lab-558741{{"How to check if a network QoS policy is active in Linux"}} linux/ls -.-> lab-558741{{"How to check if a network QoS policy is active in Linux"}} linux/cat -.-> lab-558741{{"How to check if a network QoS policy is active in Linux"}} linux/ifconfig -.-> lab-558741{{"How to check if a network QoS policy is active in Linux"}} linux/netstat -.-> lab-558741{{"How to check if a network QoS policy is active in Linux"}} linux/ip -.-> lab-558741{{"How to check if a network QoS policy is active in Linux"}} end

List QoS disciplines with tc qdisc

In this step, you will learn how to list Quality of Service (QoS) disciplines using the tc command. QoS is a set of technologies that manage network traffic to reduce packet loss, latency, and jitter. The tc command is a powerful tool in Linux for configuring traffic control.

The tc qdisc command is used to manage queueing disciplines. A queueing discipline (qdisc) is the part of the Linux kernel that determines the scheduling of packets.

To list the currently configured QoS disciplines on your network interfaces, open the terminal and type the following command:

tc qdisc show

Press Enter.

You should see output similar to this:

qdisc noqueue 0: dev lo root refcnt 2
qdisc fq_codel 0: dev eth0 root refcnt 2 limit 10240p flows 1024 quantum 1514 target 5ms interval 100ms memory_limit 32Mb ecn

Let's break down the output:

  • qdisc: Indicates that this line describes a queueing discipline.
  • noqueue 0: dev lo: Shows the qdisc for the loopback interface (lo). noqueue means no queueing is happening, as traffic on the loopback interface is typically not subject to shaping.
  • fq_codel 0: dev eth0: Shows the qdisc for the eth0 network interface. fq_codel is a specific type of qdisc that combines Fair Queueing (FQ) with Controlled Delay (CoDel).
  • root: Indicates that this is the root qdisc for the device.
  • The remaining parameters (refcnt, limit, flows, etc.) are specific to the fq_codel qdisc and control its behavior.

The output you see might vary depending on the default configuration of the network interfaces in the LabEx environment. The important part is understanding that tc qdisc show lists the active queueing disciplines.

Now, try listing the qdiscs for a specific interface, like eth0:

tc qdisc show dev eth0

Press Enter.

This command will only show the qdisc configured on the eth0 interface.

Understanding the output of tc qdisc show is the first step in managing network traffic with tc.

Click Continue to proceed to the next step.

Check QoS classes with tc class

In the previous step, you learned about queueing disciplines (qdisc). Now, let's explore QoS classes using the tc class command.

While qdiscs define the overall scheduling behavior on an interface, classes are used within certain qdiscs (like HTB or CBQ) to create hierarchical structures and apply different rules to different types of traffic. Think of classes as categories or subdivisions within a qdisc.

To list the currently configured QoS classes, you need to specify the network interface and the parent qdisc or class. Since the default fq_codel qdisc on eth0 doesn't use a class hierarchy in the same way as some other qdiscs, running tc class show dev eth0 directly might not show any classes initially.

Let's try the command anyway to see the output:

tc class show dev eth0

Press Enter.

You will likely see no output, or output indicating no classes are defined, similar to this:

This is expected because fq_codel is a classless qdisc. Classless qdiscs perform their work without needing to classify traffic into different groups.

However, if a qdisc like HTB (Hierarchical Token Bucket) or CBQ (Class Based Queueing) were configured, you would see a list of classes defined under that qdisc, showing their parameters like bandwidth limits, priorities, etc.

For example, if HTB was configured on eth0, the output might look something like this (this is just an example, you won't see this output in the current environment):

class htb 1:1 root prio 0 rate 100Mbit ceil 100Mbit burst 1600b cburst 1600b
class htb 1:10 parent 1:1 prio 1 rate 50Mbit ceil 80Mbit burst 1600b cburst 1600b
class htb 1:20 parent 1:1 prio 2 rate 20Mbit ceil 30Mbit burst 1600b cburst 1600b

In this hypothetical example:

  • class htb: Indicates an HTB class.
  • 1:1: The handle for the root class.
  • 1:10, 1:20: Handles for child classes under the root class 1:1.
  • rate, ceil: Define the guaranteed and maximum bandwidth for the class.
  • prio: Defines the priority of the class.

While you don't see classes with the default configuration, understanding the tc class show command is crucial for working with classful qdiscs when they are configured.

Click Continue to move to the next step.

Inspect QoS config in /etc/network

In the previous steps, you used the tc command to view the currently active QoS configurations. While tc shows the runtime state, the configuration files often determine how these settings are applied when the system starts or network interfaces are brought up.

On Debian-based systems like Ubuntu, network interface configurations are often managed in the /etc/network/interfaces file and files within the /etc/network/interfaces.d/ directory. These files can include commands to be executed when an interface is configured, including tc commands to set up QoS.

Let's inspect the main network configuration file. Open the terminal and use the cat command to view the contents of /etc/network/interfaces:

cat /etc/network/interfaces

Press Enter.

You will see the basic network interface configuration. In this LabEx environment, the output might look something like this:

## interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp

This file defines the loopback interface (lo) and the primary network interface (eth0), which is configured to use DHCP to obtain an IP address.

QoS configurations are not typically placed directly in /etc/network/interfaces for complex setups. Instead, they are often included in separate scripts or configuration snippets that are executed when the interface is brought up. These snippets might be located in the /etc/network/if-up.d/ directory. Scripts in this directory are executed after a network interface has been brought up.

Let's list the files in the /etc/network/if-up.d/ directory to see if there are any scripts related to QoS or traffic control:

ls /etc/network/if-up.d/

Press Enter.

The output will show the files present in that directory. You might see various scripts related to network configuration, but likely none specifically for complex QoS setups in this basic environment.

## Example output (may vary)
avahi-autoipd  ethtool  mountnfs  ntp  openssh-server  resolvconf  upstart

If there were scripts designed to apply tc rules at boot time, they would typically reside here. For example, a script named qos-setup in this directory could contain tc commands to configure qdiscs and classes.

While you didn't find explicit QoS configurations in these standard locations in this basic environment, knowing where to look (/etc/network/interfaces, /etc/network/interfaces.d/, and /etc/network/if-up.d/) is essential for understanding how QoS is persistently configured on a Linux system.

Click Continue to complete this lab.

Summary

In this lab, you learned how to check if a network QoS policy is active in Linux. You started by using the tc qdisc show command to list the active queueing disciplines on your network interfaces, understanding that qdiscs determine packet scheduling and are a key part of QoS configuration. You examined the output to identify the qdisc type and the associated network interface, and also learned how to list qdiscs for a specific interface using tc qdisc show dev <interface>.