Traffic Shaping/Control

Beginning with version 1.2.0, Shorewall has limited support for traffic shaping/control. In order to use traffic shaping under Shorewall, it is essential that you get a copy of the Linux Advanced Routing and Shaping HOWTO, version 0.3.0 or later. You must also install the iproute (iproute2) package to provide the "ip" and "tc" utilities.

Shorewall traffic shaping support consists of the following:

Kernel Configuration

This screen shot show how I've configured QoS in my Kernel:

/etc/shorewall/tcrules

The fwmark classifier provides a convenient way to classify packets for traffic shaping. The /etc/shorewall/tcrules file provides a means for specifying these marks in a tabular fashion.

Columns in the file are as follows:

Example 1 - All packets arriving on eth1 should be marked with 1. All packets arriving on eth2 should be marked with 2. All packets originating on the firewall itself should be marked with 3.

MARK SOURCE DEST PROTO PORT(S) CLIENT PORT(S)
1 eth1 0.0.0.0/0 all    
2 eth2 0.0.0.0/0 all    
3 fw 0.0.0.0/0 all    

Example 2 - All GRE (protocol 47) packets not originating on the firewall and destined for 155.186.235.151 should be marked with 12.

MARK SOURCE DEST PROTO PORT(S) CLIENT PORT(S)
12 0.0.0.0/0 155.186.235.151 47    

Example 3 - All SSH packets originating in 192.168.1.0/24 and destined for 155.186.235.151 should be marked with 22.

MARK SOURCE DEST PROTO PORT(S) CLIENT PORT(S)
22 192.168.1.0/24 155.186.235.151 tcp 22  

Hierarchical Token Bucket

I personally use HTB. I have found a couple of things that may be of use to others.

run_tc qdisc add dev eth0 root handle 1: htb default 30
run_tc class add dev eth0 parent 1: classid 1:1 htb rate 384kbit burst 15k

echo "   Added Top Level Class -- rate 384kbit"
run_tc class add dev eth0 parent 1:1 classid 1:10 htb rate 140kbit ceil 384kbit burst 15k
run_tc class add dev eth0 parent 1:1 classid 1:20 htb rate 224kbit ceil 384kbit burst 15k
run_tc class add dev eth0 parent 1:1 classid 1:30 htb rate 20kbit  ceil 384kbit burst 15k quantum 1500
echo "   Added Second Level Classes -- rates 140kbit, 224kbit, 20kbit"
run_tc qdisc add dev eth0 parent 1:10 sfq perturb 10
run_tc qdisc add dev eth0 parent 1:20 sfq perturb 10
run_tc qdisc add dev eth0 parent 1:30 sfq perturb 10
echo "   Enabled SFQ on Second Level Classes"
run_tc filter add dev eth0 protocol ip parent 1:0 prio 1 handle 1 fw classid 1:10
run_tc filter add dev eth0 protocol ip parent 1:0 prio 1 handle 2 fw classid 1:20
run_tc filter add dev eth0 protocol ip parent 1:0 prio 1 handle 3 fw classid 1:30
echo "   Defined fwmark filters"

My tcrules file is shown in Example 1 above. You can look at my network configuration to get an idea of why I want these particular rules.

Last Updated 10/25/2002 - Tom Eastep

Copyright © 2001, 2002 Thomas M. Eastep.