OpenWRT is an operating system used for embedded devices such as commodity home routers to route network traffic. It provides rich feature sets for network management, including firewall, QoS policy, port forwarding, monitoring, etc. One of the useful features of OpenWRT is to configure QoS policy such as bandwidth limiting for connected devices. If you would like to configure upload and download rate limiting on OpenWRT, you can follow the instructions below. This setup has been tested on OpenWRT Kamikaze 8.09 with Linksys WRT54GL router.
In this example, I am going to cap the upload and download bandwidth of my Linksys router at 2Mbits/sec and 4Mbits/sec respectively.
My WRT54GL router has two interfaces: (1) eth0 for WAN interface connecting to external networks, and (2) br-lan for LAN interface connected to the internal network.
First, ssh to WRT54GL router as root. Follow the rest of the steps below.
Optionally, set up proxy if the router is behind a proxy.
Using OpenWRT's package manager called opkg, install necessary software and kernel modules.
$ opkg install tc iptables-mod-ipopt
$ opkg kmod-sched
Then, verify that all necessary kernel modules are installed. The names of kernel modules start with "sch_".
$(uname -r) | grep sch
Next, insert a kernel module needed for rate limiting. In this case, I choose token bucket filter.
For upload bandwidth limiting, I set up the outgoing rate limit on WAN interface as follows.
For download bandwidth limiting, I set up the outgoing rate limit on LAN interface as follows.
To verify that eth0 and br-lan have been configured properly:
$ tc -s qdisc ls dev br-lan
This completes the QoS rate limit setting on OpenWRT. If you would like to disable rate limit later, you can do the following.
$ tc qdisc del dev br-lan root
Subscribe to Xmodulo
Do you want to receive Linux FAQs, detailed tutorials and tips published at Xmodulo? Enter your email address below, and we will deliver our Linux posts straight to your email box, for free. Delivery powered by Google Feedburner.
Did you find this tutorial helpful? Then please be generous and support Xmodulo!
Latest posts by Dan Nanni (see all)
- How to switch from NetworkManager to systemd-networkd on Linux - August 31, 2015
- How to set up a system status page of your infrastructure - August 25, 2015
- How to configure virtual hosts in Apache HTTP server - August 24, 2015