Remember to maintain security and privacy. Do not share sensitive information. Procedimento.com.br may make mistakes. Verify important information. Termo de Responsabilidade

How to Implement Traffic Prioritization in Linux Using Traffic Control (tc)

Traffic prioritization is a crucial aspect of network management, ensuring that critical applications receive the necessary bandwidth and low latency, while less important traffic is appropriately managed. In Linux, this can be effectively achieved using the tc (Traffic Control) command, part of the iproute2 package. This article will guide you through the process of implementing traffic prioritization using tc, highlighting its importance and providing practical examples.

Examples:

  1. Installing the iproute2 package: Before using tc, ensure that the iproute2 package is installed on your Linux system. Most modern Linux distributions come with iproute2 pre-installed. If it's not installed, you can install it using the package manager.

    sudo apt-get update
    sudo apt-get install iproute2
  2. Creating a Root qdisc: The first step in traffic prioritization is to create a root qdisc (queueing discipline) on the network interface. For example, to add a root qdisc on the eth0 interface:

    sudo tc qdisc add dev eth0 root handle 1: htb default 30
  3. Adding Classes: Next, you need to create classes under the root qdisc to define different traffic priorities. For example, to create a high-priority class (1:10) and a default class (1:30):

    sudo tc class add dev eth0 parent 1: classid 1:10 htb rate 1mbit ceil 1mbit
    sudo tc class add dev eth0 parent 1: classid 1:30 htb rate 512kbit ceil 1mbit
  4. Adding Filters: Filters are used to direct traffic to the appropriate class. For example, to prioritize traffic from a specific IP address (192.168.1.100):

    sudo tc filter add dev eth0 protocol ip parent 1:0 prio 1 u32 match ip src 192.168.1.100 flowid 1:10
  5. Verifying the Configuration: To verify the traffic control configuration, you can use the following command:

    sudo tc qdisc show dev eth0
    sudo tc class show dev eth0
    sudo tc filter show dev eth0
  6. Removing Traffic Control Rules: If you need to remove the traffic control rules, you can delete the root qdisc:

    sudo tc qdisc del dev eth0 root

By following these steps, you can effectively manage and prioritize network traffic on your Linux system, ensuring that critical applications receive the necessary bandwidth and low latency.

To share Download PDF

Gostou do artigo? Deixe sua avaliação!
Sua opinião é muito importante para nós. Clique em um dos botões abaixo para nos dizer o que achou deste conteúdo.