Fedora Linux Support Community & Resources Center
  #1  
Old 4th January 2007, 05:12 PM
ajoian Offline
Registered User
 
Join Date: Dec 2006
Location: Romania
Posts: 59
Limit Download per port

Hello,
I have this problem: at home I have an internet link with 1024 kb/s downstream si 256 kb/s upstream on my personal computer, to this link I like to apply some traffic shaping per ports, for the upload part I do something like this and it works fine:
Code:
tc qdisc add dev $IF root handle 1: htb default 12 
tc class add dev $IF parent 1: classid 1:1 htb rate ${CEIL}kbit ceil ${CEIL}kbit 
tc class add dev $IF parent 1:1 classid 1:10 htb rate 80kbit ceil ${CEIL}kbit prio 1 
tc class add dev $IF parent 1:1 classid 1:11 htb rate 108kbit ceil ${CEIL}kbit prio 2 
tc class add dev $IF parent 1:1 classid 1:12 htb rate 8kbit ceil ${CEIL}kbit prio 3
$iptables -A OUTPUT -t mangle -o $IF -p tcp --sport 22 -j MARK --set-mark 1
$iptables -A OUTPUT -t mangle -o $IF -p tcp --dport 22 -j MARK --set-mark 1
$iptables -A OUTPUT -t mangle -o $IF -p tcp --sport 65125 -j MARK --set-mark 1
$iptables -A OUTPUT -t mangle -o $IF -p tcp --dport 65125 -j MARK --set-mark 1
$iptables -A OUTPUT -t mangle -o $IF -p tcp --tcp-flags SYN,RST,ACK SYN,FIN -j MARK --set-mark 1
$iptables -A OUTPUT -t mangle -o $IF -p udp --dport 53 -j MARK --set-mark 1
$iptables -A OUTPUT -t mangle -o $IF -p tcp --dport 80 -j MARK --set-mark 1
tc filter add dev $IF parent 1: protocol ip handle 1 fw classid 1:10
$iptables -A OUTPUT -t mangle -o $IF -p udp --dport 25 -j MARK --set-mark 2
$iptables -A OUTPUT -t mangle -o $IF -p udp --dport 110 -j MARK --set-mark 2
$iptables -A OUTPUT -t mangle -o $IF -p udp --dport 143 -j MARK --set-mark 2
tc filter add dev $IF parent 1: protocol ip handle 2 fw classid 1:11
The problem is for the download part because I cant sperate the traffic per ports, this without using (i have my reasons)IMQ or htb-init found on sourceforge, for download at the moment I user what tc offers me for ingress (read in man tc):

Code:
tc qdisc del dev $IF ingress
tc qdisc add dev $IF handle ffff: ingress
tc filter add dev $IF parent ffff: protocol ip prio 10 u32 match \
ip src 0.0.0.0/0 police rate 948kbit burst 80kbit drop flowid :1
Reply With Quote
  #2  
Old 7th January 2007, 07:42 AM
ajoian Offline
Registered User
 
Join Date: Dec 2006
Location: Romania
Posts: 59
So no guruz here, I've managed to mark the ports for INPUT like this:
Code:
#Marcare trafic inbound
iptables -t mangle -N MYSHAPER-IN
iptables -t mangle -I PREROUTING -i $IF -j MYSHAPER-IN

iptables -t mangle -A MYSHAPER-IN -p ! tcp -j MARK --set-mark 20           
iptables -t mangle -A MYSHAPER-IN -p tcp -m length --length :64 -j MARK --set-mark 20
iptables -t mangle -A MYSHAPER-IN -p tcp --dport ssh -j MARK --set-mark 20   
iptables -t mangle -A MYSHAPER-IN -p tcp --sport ssh -j MARK --set-mark 20   
iptables -t mangle -A MYSHAPER-IN -m mark --mark 0 -j MARK --set-mark 21
and if want to I use imq :
Code:
iptables -t mangle -A MYSHAPER-IN -j IMQ
but i dont so i'll use red.
Reply With Quote
Reply

Tags
download, limit, port

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[REQ] an app that can limit download speed/daily bandwith usage per local port/ip Frantis Using Fedora 0 28th July 2009 01:42 PM
download fedora 9 using rsync (to fix corrupted download) bingoUV Using Fedora 11 1st June 2008 10:00 AM
Help on Limit Transfer Speed on a IP/Port fluidhosts Using Fedora 3 9th August 2004 07:02 PM


Current GMT-time: 00:15 (Wednesday, 22-05-2013)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat