LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 08-01-2011, 03:41 PM   #1
sci3ntist
Member
 
Registered: Dec 2006
Distribution: Debian,Slackware,FreeBSD,CentOS,Red Hat,Windows Server 2008
Posts: 133

Rep: Reputation: 16
Traffic shaping with htb


Hi,

I'm implementing a script to do traffic shaping and here are my rules:

tc qdisc add dev eth0 root handle 1:0 htb
tc class add dev eth0 parent 1:0 classid 1:1 htb rate 2kbit ceil 2kbit
tc class add dev eth0 parent 1:0 classid 1:2 htb rate 500kbit ceil 500kbit

tc qdisc add dev eth0 parent 1:1 sfq perturb 10
tc qdisc add dev eth0 parent 1:2 sfq perturb 10

tc filter add dev eth0 parent 1:0 protocol ip prio 1 handle 256 fw flowid 1:1
tc filter add dev eth0 parent 1:0 protocol ip prio 1 handle 1536 fw flowid 1:2

and for the purpose of testing, I did some testing rules on iptables as follows:

iptables -t mangle -N internet_256
iptables -A PREROUTING -t mangle -m mac --mac-source XX-XX-XX-XX-XX-XX -j internet_256
iptables -t mangle -A internet_256 -j MARK --set-mark 256
iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE

Like when a client has the above mac address it'll be redirected to the internet_256 rules and then will be marked with 256. I'm not sure why its not working properly. Any advise?

Thanks in advance.
 
Old 08-02-2011, 04:03 AM   #2
guiclaw
LQ Newbie
 
Registered: Mar 2009
Posts: 1

Rep: Reputation: 0
On the iptables MARK, try using hexadecimal - so --set-mark 0x100 (for 256 in tc) and give that a try. I seem to remember having is problem in the past and just checking my scripts source, this is how I resolved the issue.
 
Old 08-02-2011, 04:12 AM   #3
iori988
LQ Newbie
 
Registered: Jul 2011
Posts: 2

Rep: Reputation: Disabled
Quote:
Originally Posted by guiclaw View Post
On the iptables MARK, try using hexadecimal - so --set-mark 0x100 (for 256 in tc) and give that a try. I seem to remember having is problem in the past and just checking my scripts source, this is how I resolved the issue.
Thanks in a word
 
Old 08-05-2011, 04:31 AM   #4
sci3ntist
Member
 
Registered: Dec 2006
Distribution: Debian,Slackware,FreeBSD,CentOS,Red Hat,Windows Server 2008
Posts: 133

Original Poster
Rep: Reputation: 16
Thank you, but it didn't work.
This should work in case I add the following line:
iptables -t mangle -A PREROUTING -j MARK --set-mark 0x100

Which is not what I want, I only want certian mac address to be included into this, if I do the following:
iptables -t mangle -A PREROUTING -m mac --mac-source XX:XX:XX:XX -j MARK --set-mark 0x100

Also I doesn't work.
From searching around I found that you have something like the following:
tc filter add dev eth0 parent 1:0 protocol ip prio 1 u32 match u16 0x0800 0xffff at -2 match u16 0x4E83 0xffff at -4 match u32 0x0800271C 0xffffffff at -8 flowid 1:1

but also didn't work. I'm not sure what I'm missing,
Any ideas? any suggestions?

Regards,
 
  


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
traffic shaping with htb.init rogerdv Linux - Networking 0 03-20-2009 07:03 AM
Problems, Traffic shaping with HTB scuba0 Linux - Networking 4 07-31-2008 11:21 AM
Traffic shaping with HTB, several questions exscape Linux - Networking 1 05-28-2008 12:10 PM
traffic shaping with htb zsoltrenyi Linux - Software 2 11-12-2004 09:17 AM
traffic shaping htb SchwipSchwap Linux - Networking 1 08-28-2003 03:17 PM

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

All times are GMT -5. The time now is 06:45 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