[Samba] speed limit

Michele Petrazzo - Unipex srl michele.petrazzo at unipex.it
Thu Aug 21 09:23:48 GMT 2008

Michael Heydon wrote:
>> could you please tell me at least one tool to do this? I need to 
>> limit speed not for all tcp trafik, only samba.
> Under linux, a mixture of tc and iptables should do the trick, but 
> it's not for the faint of heart ;)

Not so much, if you know the thing ;)
We are now OT, but a simple example, I think, don't irritate nobody!

Assuming our network are 192.168.1.X, the client that we want to limit
are .100 at 5mbit and our lan ethernet are eth0. All the clients that we
don't know have to go to 1mbit (all together).

# default root handle
tc qdisc add dev eth0 root handle 1: htb default 1000
# the parent for all the classes, has the max ethernet speed
tc class add dev eth0 parent 1: classid 1:1 htb rate 100mbit ceil 100mbit
# our know client
tc class add dev eth0 parent 1:1 classid 1:100 htb rate 1mbit ceil 5mbit
# all the others
tc class add dev eth0 parent 1:1 classid 1:1000 htb rate 1mbit ceil 1mbit

iptables -t mangle -F OUTPUT
iptables -t mangle -A OUTPUT -o eth0 -d -j CLASSIFY
--set-class 1:100
# this it's not need, but clarifies for understand better (since all the
# packets that aren't marked goes to the default into tc
iptables -t mangle -A OUTPUT -o eth0 -j CLASSIFY --set-class 1:1000

P.s. Pay attention that this limit all the traffic to the destination,
not only the samba one! The trickle can be done with something like -p
tcp --sport 445, but I'm not so sure :)


More information about the samba mailing list