LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 07-25-2005, 01:41 AM   #1
roopunix
Member
 
Registered: Feb 2004
Location: Kathmandu
Distribution: Redhat/fedora/Suse [Wanna Drive With Debian]
Posts: 208

Rep: Reputation: 30
htb interface


hello everyone


i want to some basics of htb.

i have redhat9 box

eth0 is my lan part and eth 1 is my wan part

so if i just want to control bandwidth in which interface should i apply htb.?

and if i want to control upload and download then how do i apply the htb?

any answers will be helpful for me to learn htb so only 1 answers also be appreciated from the above 2 questions. it will more help full if there is a sample simple configuration of htb.I have tried browsing LARTC but nothin is going on my head.
 
Old 07-25-2005, 07:42 PM   #2
mpeg4codec
Member
 
Registered: Jul 2005
Distribution: Debian, Gentoo, self-built [not LFS]
Posts: 109

Rep: Reputation: 15
If you want to limit your upload, you would have HTB running on your WAN port, so eth1. If you're finding the advanced routing HOWTO a bit over your head, I would recommend cbq.init. It uses the more complex CBQ qdisc, but it should be able to accomplish what you're looking to do very easily. Give it a look and let me know how it goes.

Note: It's a bad idea to try to control your download [ingress] bandwidth. It can work, but it usually just causes more problems than it solves.

As for HTB, if you're *really* dying for a good setup, I can give you an example. However, cbq.init should be more than good enough.
 
Old 07-25-2005, 08:31 PM   #3
roopunix
Member
 
Registered: Feb 2004
Location: Kathmandu
Distribution: Redhat/fedora/Suse [Wanna Drive With Debian]
Posts: 208

Original Poster
Rep: Reputation: 30
thank's for the reply but if one of my friend will try to download a song or a linux distro then it will effect other's too right?? This is why i want to limit download and upload
for example i have a 512 kbps wireless broadband link.

eth0 lan side
eth1 my isp side [wan]

now i wanna give 128 kbps download and 64 kbps upload to the ip 192.168.0.20.But if the link is not busy he can get 256 download and 128 upload.So i want to accomplish this via HTB. So can you give me a sample example for so that i can understand.

Thanking You
 
Old 07-25-2005, 11:46 PM   #4
mpeg4codec
Member
 
Registered: Jul 2005
Distribution: Debian, Gentoo, self-built [not LFS]
Posts: 109

Rep: Reputation: 15
Ah I see what you're trying to do. In that case, you'd want to do your bandwidth limiting on the internal [eth0] interface. I'll have to look into this one.. but I'll post an HTB setup I can come up with probably tomorrow.
 
Old 07-26-2005, 12:11 AM   #5
roopunix
Member
 
Registered: Feb 2004
Location: Kathmandu
Distribution: Redhat/fedora/Suse [Wanna Drive With Debian]
Posts: 208

Original Poster
Rep: Reputation: 30
thanks for the quick reply

i will wait for your answer.I will be sticking on this site..

thank you for your knee interest on this question.
 
Old 07-26-2005, 11:15 PM   #6
mpeg4codec
Member
 
Registered: Jul 2005
Distribution: Debian, Gentoo, self-built [not LFS]
Posts: 109

Rep: Reputation: 15
The egress filter on eth0 limits the rate that you send packets to machines on the internal network. In other words, it limits the rate at which machines on your network can download. This is not considered a good idea, but it's worth trying.

tc qdisc del dev eth0 root
tc qdisc del dev eth0 ingress

tc qdisc add dev eth0 root handle 1: htb default 20
tc class add dev eth0 parent 1: classid 1:1 htb rate 100mbit
tc class add dev eth0 parent 1:1 classid 1:10 htb rate 256kbit ceil 256kbit burst 5kbit
tc class add dev eth0 parent 1:1 classid 1:20 htb rate 128kbit ceil 256kbit burst 5kbit

The egress filter on eth1 limits the rate at which you upload packets. This is a commonly-used setup, so no worries about how well it should work.

tc qdisc del dev eth1 root
tc qdisc del dev eth1 ingress

tc qdisc add dev eth1 root handle 1: htb default 10
tc class add dev eth0 parent 1: classid 1:1 htb rate 128kbit
tc class add dev eth0 parent 1:1 classid 1:10 htb rate 64kbit ceil 128kbit burst 5kbit

The following iptables rules should help classify traffic into the proper classes of the htb queues:

iptables -t mangle -F POSTROUTING
iptables -t mangle -A POSTROUTING -o eth0 -s 192.168.0.0/24 -j CLASSIFY --set-class 1:1
iptables -t mangle -A POSTROUTING -o eth1 -s ! 192.168.0.20 -j CLASSIFY --set-class 1:10

The middle rule makes sure that the machines trying talk to each other over ethernet aren't limited to 256 kbit. The last rule makes sure that everyone trying to access the internet, except for 192.168.0.20, gets 128 kbit. 192.168.0.20 gets only 64 kbit.

Let me know if this is what you were looking for.
 
Old 07-26-2005, 11:54 PM   #7
roopunix
Member
 
Registered: Feb 2004
Location: Kathmandu
Distribution: Redhat/fedora/Suse [Wanna Drive With Debian]
Posts: 208

Original Poster
Rep: Reputation: 30
that was a confusing to me.
But i got a script in the web which was more easy for me to understand.But it is also done on 1 side.So i need your help on this too.

my wan intf eth1 which is connected to the isp. 512kbps of wireless internet.
my lan intf eth0 which is my lan side.

tc qdisc add dev eth1 root handle 1: htb default 1:2

tc class add dev eth1 parent 1: classid 1:1 htb rate 512kbps

tc class add dev eth1 parent 1:1 classid 1:2 htb rate 128kbps ceil 256kbps

tc filter add dev eth1 parent 1:1 protocol ip prio16 u32 match ip src 192.168.0.20 flowid 1:2

now this is the script. 192.168.0.20 is getting 128 kbps [for upload or download??] But as i had said i want
128 download and 64 upload and of course if the link is free i want to give 256 download and 128 upload to
that ip. and to the rest of the network i want to let them go through the rest of the available bandwidth.

It would be easier to me if the script will as above for the eth0 side also. i hope you understand my situation.

anyway thank you for your time.
 
Old 07-29-2005, 08:32 AM   #8
mpeg4codec
Member
 
Registered: Jul 2005
Distribution: Debian, Gentoo, self-built [not LFS]
Posts: 109

Rep: Reputation: 15
Did you try the script I posted above. Unless I've made a mistake, it should be doing exactly what you want. You may need a small change to this section:

tc qdisc add dev eth0 root handle 1: htb default 20
tc class add dev eth0 parent 1: classid 1:1 htb rate 100mbit
tc class add dev eth0 parent 1:1 classid 1:10 htb rate 256kbit ceil 256kbit burst 5kbit
tc class add dev eth0 parent 1:1 classid 1:20 htb rate 128kbit ceil 256kbit burst 5kbit

Change that to this:
tc qdisc add dev eth0 root handle 1: htb default 20
tc class add dev eth0 parent 1: classid 1:1 htb rate 100mbit
tc class add dev eth0 parent 1:1 classid 1:10 htb rate 512kbit ceil 512kbit burst 5kbit
tc class add dev eth0 parent 1:1 classid 1:20 htb rate 128kbit ceil 256kbit burst 5kbit

That part does handle the eth0 side of things.. Did you miss it?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
QoS with HTB diaskimo Linux - Networking 3 08-08-2005 12:57 AM
HTB as a child of another HTB - doesn't work ddaas Linux - Networking 5 07-25-2005 03:21 AM
How To HTB linuxcolor Fedora 1 02-15-2005 07:46 AM
htb.init Ipolit Slackware 2 05-02-2004 01:23 PM
HTB.. qos or what? bcc1981 Mandriva 0 04-16-2004 02:19 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 05:31 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration