Linux - NetworkingThis forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Distribution: Redhat/fedora/Suse [Wanna Drive With Debian]
Posts: 208
Rep:
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.
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.
Distribution: Redhat/fedora/Suse [Wanna Drive With Debian]
Posts: 208
Original Poster
Rep:
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.
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.
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:
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.
Distribution: Redhat/fedora/Suse [Wanna Drive With Debian]
Posts: 208
Original Poster
Rep:
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 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.
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?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.