Traffic Control With Wondershaper While Still Letting Your LAN Speeds Stay Super Fast

Wondershaper is pretty nice and easy traffic shaping tool for linux.  It’s been around for a while (and has its critics), but I find it to be a great tool.

It’s so useful for a pretty straightforward reason:  I can use a lot of bandwidth if I’m not careful, particularly upstream.  And while I’ve got pretty good speeds at my place now, I don’t want to totally annoy friends when I’m over at their house.  My amour still checks to see if I’m on the internet whenever her Roku starts buffering…

So that’s where we get to Wondershaper.  It helps limit and prioritize the bandwidth traffic coming to and from your computer so that the “tubes” don’t get congested.

Yes, it takes a little time to set up, but there are some excellent guides to walk you through it.  (If you can’t see the link, it’s  Most of the legwork needed will also help you set up properly Quality of Service settings on your router;  the cool thing here is that Wondershaper will help make those QoS settings work even better since your computer isn’t trying to shove more through the router.1

Except for one small thing.  For most people in the US, the bandwidth on your local network far exceeds the speeds you have to the internet.  Here’s the wireless network standard speeds (most wired networks are 100Mbps)

802.11b – 11 Mbps (2.4GHz)
802.11a – 54 Mbps (5 GHz)
802.11g – 54 Mbps (2.4GHz)
802.11n – 150Mbps – 600 Mbps (2.4GHz and 5 GHz)
802.11ac – 1300 Mbps (5 GHz)

I just tested my internet speeds, and it’s 7.88Mbps down (and 0.89Mbps up)… so there’s no way that I could download from the internet faster than even an old wireless standard could handle.

Wondershaper doesn’t know that.

As Wondershaper is currently written (at least in Debian and Ubuntu) it doesn’t differentiate between traffic out to the internet and between two computers on the same network.  So it made things really slow when I was trying to copy my music to another computer.

I managed to find where roobinatube had figured this out back in 2011.  By just adding a few lines of code, Wondershaper completely ignore LAN traffic and while still doing its job with internet-bound traffic. Let me walk you through what to do:

1.  Find out what your LAN’s private IP address space is.  (You can find out with the ip route command from iproute2.)  Most people’s are 192.168.. or 10...*, where the asterisks can be any number from 0 to 255.

Here’s an example output:

default via dev eth0 dev eth0  proto kernel  scope link  src would be the router in this example, which the computer is connected to by the eth0 (or ethernet) connection. The /24 on the second line tells us that only the last number changes in our LAN.

2.  Find where the Wondershaper script is on your system.

which wondershaper
  1. Open Wondershaper in your favorite text editor. (I’m using where Wondershaper is installed on my system here.) You’ll probably need superuser permissions, so
sudo nano /usr/sbin/wondershaper
gksudo gedit /usr/sbin/wondershaper
kdesudo geany /usr/sbin/wondershaper

Here’s the fun part:

  1. Modification One.

Find these lines in the program.

# Set the following values to somewhat less than your actual download
# and uplink speed. In kilobits. Also set the device that is to be shaped.

Add these lines below making sure that you change the subnet. (Example: If your subnet from above is, then the value for LAN_SUBNET is…) And yes, I recommend leaving the comment so when you’ve forgotten what you did and find it again it saves you time.

# added to exclude LAN
  1. Modification Two. Now find these lines:
/sbin/tc class add dev $DEV parent 1:1 classid 1:30 cbq rate $((8*$UPLINK/10))kbit
allot 1600 prio 2 avpkt 1000

And add a blank line and then add this:

# added to exclude LAN
#put lan traffic into lan class
/sbin/tc filter add dev $DEV parent 1:0 protocol ip prio 1 u32
match ip src $LAN_SUBNET/24
match ip dst $LAN_SUBNET/24
flowid 1:3
  1. Modification Three. And finally, find this line (it should be just under a part that says “downlink”):
/sbin/tc qdisc add dev $DEV handle ffff: ingress

And then add this immediately below it

# added to exclude LAN
tc filter add dev $DEV parent ffff: prio 1 u32
match ip src $LAN_SUBNET/24
match ip dst $LAN_SUBNET/24
flowid :1

Your bandwidth will flow more smoothly – both within your LAN and out to the world at large.

1 If you have a laptop, you might have realized that the settings for Wondershaper won’t be the same at every location. We’ll hit that with my network control script later this week.

Popular posts:

  • HOWTO Make Your Hamburger Helper Better
  • The Songs That Chronicle Our Lives
  • Word Porn Quotes
  • I am not a number; I am a free man, OR, why you should never rely on social media
  • It's not being "Awkward", and the difference between Excuses and Explanations
  • I really like you, but I have to break up with you before I don't.
  • If You Have A Teenager, I Think You Should Watch This Show With Them.  Now.