Openwrt Qos Configuration and Management

Author

Reads 1.3K

A silver network router with multiple USB ports, perfect for small offices.
Credit: pexels.com, A silver network router with multiple USB ports, perfect for small offices.

OpenWRT QoS configuration is a powerful tool for managing network traffic. It allows you to prioritize certain types of traffic over others, ensuring that critical applications receive the bandwidth they need.

You can configure QoS rules based on various criteria, including source and destination IP addresses, ports, and protocols. For example, you can set up a rule to prioritize traffic from a specific server or device.

To set up QoS rules, you'll need to use the OpenWRT configuration file, which is typically stored in the /etc/config/qos directory. This file contains a list of QoS rules, each defined by a unique name and a set of criteria.

By configuring QoS rules effectively, you can improve the performance and reliability of your network, making it more suitable for demanding applications like video streaming and online gaming.

Curious to learn more? Check out: QoS Class Identifier

Network Configuration

Network Configuration is a crucial step in setting up OpenWRT QoS.

You'll want to configure your network settings to prioritize certain devices or applications, which can be done through the LuCI web interface.

Credit: youtube.com, OpenWRT - SQM QoS Setup on LuCI

To start, ensure you've enabled the QoS feature in the OpenWRT settings.

Next, you'll need to configure the network interfaces, such as the LAN and WAN ports.

The article mentions that you can use the `uci` command to configure the network interfaces.

In the example, the `uci` command is used to set the WAN port to a specific configuration.

You can also configure Quality of Service (QoS) rules to prioritize certain traffic.

The QoS rules can be set up to prioritize traffic based on various criteria, such as IP address, MAC address, or protocol.

In the example, a QoS rule is set up to prioritize traffic from a specific IP address.

By configuring your network settings and QoS rules, you can ensure that your network is running smoothly and efficiently.

For another approach, see: Openwrt Uci

Scripting

QoS scripting can be complex, but it's a crucial part of achieving Quality of Service in OpenWRT. The QoS script in this example uses the Hierarchical fair-service curve scheduler (HFSC) to split bandwidth fairly between two networks.

Credit: youtube.com, OpenWrt - Bufferbloat | SQM Scripts | Test

The script is designed to be flexible and complex, but it has a caveat: it cannot handle IPv6's variable header lengths. This is a significant limitation that should be addressed by rewriting the script to use iptables MARK's for proper classification.

The script's traffic shaping schema can be rendered with ditaa, and documentation links are provided for the HFSC scheduler and the u32 classifier.

Test the Capability

To test the capability of a script, you can simulate a heavy network stress test. Connect a PC or laptop through the router's LAN port and run a heavy downloading app like a torrent client. This will put a lot of strain on the network.

Next, turn on the router's Wi-Fi and connect one or two smartphones to start browsing a few web pages. Give the Wi-Fi password to friends and have them chat on Skype. This will add more traffic to the network.

For more insights, see: Openwrt Travel Router

Man Doing A Sample Test In The Laboratory
Credit: pexels.com, Man Doing A Sample Test In The Laboratory

Now, connect another PC or laptop to the LAN port using a good quality Ethernet cable. This will help you test the network's performance from a different angle.

You can then test the network's performance by pinging remote servers like Google or browsing a few web pages. This will give you an idea of how the script handles heavy network traffic.

Here's a summary of the steps:

  1. Run a heavy downloading app on a PC or laptop connected to the router's LAN port.
  2. Turn on the router's Wi-Fi and connect one or two smartphones to start browsing and chatting.
  3. Connect another PC or laptop to the LAN port using a good quality Ethernet cable.
  4. Ping remote servers or browse web pages to test the network's performance.

Curfew Script

The Curfew Script is a clever way to implement time-based restrictions on network traffic using Firewall Traffic Rules and Cron. It's a great example of how scripting can be used to automate tasks and improve network management.

You can pass the rule name prefix through an environment variable, making it easy to create different sets of rules. This is a useful feature, especially when you need to apply the same rules to multiple networks or devices.

The script header has more details on how to use the Curfew Script, including information on how to configure it for your specific needs. If you're interested in learning more, be sure to check it out.

Smart home wireless network router device
Credit: pexels.com, Smart home wireless network router device

One of the benefits of the Curfew Script is its ease of use. You can simply pass the rule name prefix as an environment variable, and the script will take care of the rest. This makes it a great option for network administrators who need to implement time-based restrictions on a large scale.

The Curfew Script uses Firewall Traffic Rules and Cron to implement time-based restrictions. This means that you can specify specific times of day or week when certain rules should be applied.

Here's a quick rundown of the key features of the Curfew Script:

  • Uses Firewall Traffic Rules to implement time-based restrictions
  • Can be configured using an environment variable
  • Easy to use and automate
  • Great for network administrators who need to implement time-based restrictions on a large scale

Install Luci-App-Sqm

Installing Luci-App-Sqm is a breeze, and it's a great way to get started with scripting on your OpenWrt router.

First, make sure you have enough storage space - you'll need at least 550KB, so if your router is running low, you may need to set up extroot.

To install through the command line, login to your OpenWrt router via SSH and ensure it can reach the internet.

Credit: youtube.com, Installing SQM on OpenWrt to combat Bufferbloat

You'll also need to update the opkg package repository and install luci-app-sqm, which will install SQM with all dependencies.

To start the SQM service and enable automatic startup after each reboot, use the commands /etc/init.d/sqm start and /etc/init.d/sqm enable.

Alternatively, you can install through the LuCI web interface, which is even easier.

To do this, login to your router's web interface and go to the System>Software section from the dropdown menu.

Update the package list and put luci-app-sqm in the Download and install package: field, which will install SQM QoS service with all dependencies.

Finally, don't forget to start the SQM service and add it to auto startup list by going to System > Startup section from the dropdown menu.

Suggestion: Update Openwrt

Installation

Installing SQM on OpenWrt is a relatively straightforward process. You can install it from the command line or the LuCI web interface.

To install SQM from the command line, you'll need to log in to your router through SSH and make sure it can reach the internet properly. This is done by pinging a website like google.com.

Credit: youtube.com, OpenWrt Qos over Nftables-NFT QoS Setup On Luci

First, update the opkg package repository with the command `opkg update`. Then, install luci-app-sqm with the command `opkg install luci-app-sqm`. This will install SQM with all its dependencies.

After installation, start the SQM service with the command `/etc/init.d/sqm start` and enable automatic startup after each reboot with the command `/etc/init.d/sqm enable`.

Alternatively, you can install SQM through the LuCI web interface. To do this, log in to your router's web interface and go to the System > Software section. Update the package list and put `luci-app-sqm` in the Download and install package: field.

Don't forget to start the SQM service and add it to the auto startup list. Go to System > Startup section, hit the Disabled button to enable auto startup, and hit the Start button to start the QoS service.

Here's a step-by-step guide to installing SQM from the command line:

1. Log in to your router through SSH and make sure it can reach the internet properly.

2. Update the opkg package repository with `opkg update`.

3. Install luci-app-sqm with `opkg install luci-app-sqm`.

4. Start the SQM service with `/etc/init.d/sqm start`.

5. Enable automatic startup after each reboot with `/etc/init.d/sqm enable`.

If this caught your attention, see: Openwrt Install Tailscale

Settings

Credit: youtube.com, OpenWRT - Bandwidth Limiting for LAN & WiFi - SQM QoS

To set up OpenWrt QoS, you'll need to determine your internet download and upload speed, as well as network latency. This can be done using speed testing websites like http://speedtest.net or https://www.speedcheck.org/.

You can also use the ping command to measure network latency, taking note of the time required to ping different domains and calculating the average time.

For example, I measured a download speed of about 2.62 Mbps and an upload speed of 2.98 Mbps with a USB 3G mobile broadband connection. Average network latency was 140mS to a maximum of ~450mS.

To configure SQM, go to Network > SQM QoS setting from the LuCI web interface dropdown menu.

Here are the steps to follow:

  1. Enable QoS by checking the enable box in the Basic Settings tab.
  2. Select the Network interface, which is usually eth1 or eth0 for WAN networks, or ppp0 for mobile broadband connections.
  3. Set the Download and Upload speed to about 90-95% of your maximum speed, in kbps, not kB/s.
  4. Leave the Queue Discipline tab options at their default settings.
  5. Choose your connection type in the Link layer adaptation tab, as it's self-explanatory.
  6. Finally, hit the Save & Apply button to enable OpenWrt QoS on the router.

Cloud

Cloud computing is a vast and complex topic, but in the context of OpenWrt QoS, we can focus on a specific aspect: the impact of cloud services on our network traffic. The proposed script divides outgoing network traffic into 5 priority classes.

Credit: youtube.com, OpenWRT - Enable SQM QoS Chart on Netdata - Netdata Cloud Auto Start Fix

One of the classes is for "gaming, SSH" which is given high priority and reliability. This is crucial for cloud gaming services that require fast and stable connections.

We can also consider the bitrate requirements for cloud services. According to the script, we can set average and maximum bitrate for our network connection and each priority class. This allows us to tailor our QoS settings to the specific needs of our cloud services.

In terms of practical implementation, the script uses HTB (Hierarchical Token Bucket) queues to manage traffic, which is well-suited for network bitrate changes. This is particularly important for cloud services that often involve dynamic traffic patterns.

Here's a summary of the priority classes:

  • 1 - ping, DNS, ack : very fast
  • 2 - gaming, SSH : high priority, reliable
  • 3 - local services : good bitrate, average response time
  • 4 - users: web and email(default class)
  • 5 - peer 2 peer

By understanding how cloud services fit into our QoS strategy, we can optimize our network traffic and ensure a better user experience.

Frequently Asked Questions

Is sqm better than QoS?

SQM offers more advanced features than QoS, including network scheduling, traffic shaping, and active queue length management, making it a more comprehensive solution for network optimization. If you're looking for a more robust way to manage network traffic, SQM is worth exploring further.

Cory Hayashi

Writer

Cory Hayashi is a writer with a passion for technology and innovation. He started his career as a software developer and quickly became interested in the intersection of tech and society. His writing explores how emerging technologies impact our lives, from the way we work to the way we communicate.

Love What You Read? Stay Updated!

Join our community for insights, tips, and more.