Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Bandwidth Limiting with HTBinit
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
Se7enLC
Tux's lil' helper
Tux's lil' helper


Joined: 22 Aug 2003
Posts: 88

PostPosted: Fri Feb 08, 2008 12:33 am    Post subject: Bandwidth Limiting with HTBinit Reply with quote

Do you run a web server on a machine with limited upload bandwidth? Sick of having really high latency in ssh sessions when your page is being accessed? HTB is the answer!

I followed the basic howto from this site:
http://edseek.com/~jasonb/articles/linux_tc_minihowto.shtml
It basically said to
  • Configure kernel for traffic shaping.
  • emerge iproute2
  • emerge htbinit


And that was the easy part. Now that we have htbinit installed, it's time to set it up. The howto above will handle a simple case, but I had something a little more complex in mind.

In the /etc/htb directory, you need to make a series of configuration files. These files define the hierarchy of rules and rates that htbinit will use to generate startup commands.

For my setup, I've defined a single node on eth0 at a really huge bandwidth [2]. That node has two children: local [3] and remote [4]. Local has the same large pipe and a rule that specifies data must have a source and destination on the local subnet. Remote has a pipe that is defined as 45KB/s (slightly slower than the upload speed of my cablemodem). The Remote node has two children: www [10] and def [30]. www has a rate of 240kb/s (about 30KB/s) and a rule that specifies that the data must be originating from my webserver port. The default case has the full 30KB/s and no rules.

Here are the files:

Code:
# HTB.init eth0
#
# http://edseek.com/~jasonb/articles/linux_tc_minihowto.shtml
#

# Default traffic is ID:30
DEFAULT=30


Code:
# HTB.init eth0-2.root
#

# Default rate is Really Big (local network)
RATE=10000000Kbit


Code:
# HTB.init eth0-2:3.local

# Rate for local access is full-speed
RATE=10000000Kbit

# Local is anything that is being sent to/from a 192.168 address
RULE=192.168.1.*,192.168.1.*


Code:
# HTB.init eth0-2:4.remote

# Limit remote connections to 360kb/s (45 KB/s)
RATE=360Kbit


Code:
# HTB.init eth0-2:4:10.www

# RATE=<speed>|prate|pceil                      mandatory
# CEIL=<speed>|prate|pceil                      optional, default $RATE
# BURST=<bytes>                                 optional, default computed
# RULE=[[saddr[/prefix]][:port[/mask]],][daddr[/prefix]][:port[/mask]]

# Limit to 240kb/s (30KB/s)
RATE=240Kbit
CEIL=240Kbit
BURST=2K

# Anything leaving on port 8000 (web)
RULE=*:8000,


Code:
# HTB.init eth0-2:4:30.def

# By default, allow the full 360kb/s (45KB/s)
RATE=360Kbit
CEIL=360Kbit
BURST=2K
Back to top
View user's profile Send private message
desultory
Bodhisattva
Bodhisattva


Joined: 04 Nov 2005
Posts: 9410

PostPosted: Fri Feb 08, 2008 3:50 am    Post subject: Reply with quote

Moved from Networking & Security to Documentation, Tips & Tricks.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum