Skip to contentSkip to conversation

newbie question - how to downgrade ftp-data traffic

LARTC Troy Rockwood 3 participants 4 messages Jan 18, 2002 – Jan 19, 2002

lore
Share & tools
lore
#0 lore raw

I'm new to the list and to traffic shaping, however I understand the
idea behind it I believe. My home computer is connected via DSL. I run an ftp server and I have a home network behind the machine so that it acts as the router/gateway for that network.
I get a lot of ftp traffic, sometimes so much that traffic from the
home network is too slow to be useful. What is the easiest way to give all other traffic priority over ftp-data traffic so that it doesn't eat up all my bandwidth and starve my wife's web browsing? Here is what I have tried:

I have tried to use iptables to change the TOS bits such that traffic other than that to port 20 is given priority:

$IPTABLES -A PREROUTING -t mangle -p tcp --sport ! 20 \
          -j TOS --set-tos Minimize-Delay

or

$IPTABLES -A OUTPUT -t mangle -p tcp --sport ! 20 \
          -j TOS --set-tos Minimize-Delay

However, this does not seem to have the desired effect (I have looked at the packets with ethereal (tcpdump with a GUI) but the TOS bits do not seem to be affected in either case.

I also tried using queuing:

tc qdisc add dev eth0 root handle 1: prio
tc qdisc add dev eth0 parent 1:1 handle 10: sfq
tc qdisc add dev eth0 parent 1:2 handle 20: sfq
tc qdisc add dev eth0 parent 1:3 handle 30: sfq
tc filter add dev eth0 protocol ip parent 1: prio 0 u32 match ip dport 119 0xffff flowid 1:1

I get limited success with this approach, in this test I gave nntp (internet news) traffic (port 119) priority but if I try something like:

tc filter add dev eth0 protocol ip parent 1: prio 2 u32 match ip sport 20 0xffff flowid 1:2

This does not seem to move ftp-data packets into the lowest priority bin. I'm not sure what syntax to use to move all BUT ftp-data packets to the high priority bin or how to move only ftp-data packets into the lower priority bin.

This is probably something stupid and easy but it's not clear to me right now. Any help would be greatly appreciated. What I'm looking for is the simplest way to give other traffic higher priority than the traffic to/from the ftp-data port (20). Thanks in advance and thanks for your patience.

==Troy Rockwood - [email protected]

I have made this letter longer than usual because I lack the time to make it shorter. -- Blaise Pascal

__________________________________________________
Do You Yahoo!?
Send FREE video emails in Yahoo! Mail!
http://promo.yahoo.com/videomail/
_______________________________________________
LARTC mailing list / [email protected]
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://ds9a.nl/lartc/

#1 lore raw
Quoted 19 lines · Troy Rockwood

I'm new to the list and to traffic shaping, however I understand the
idea behind it I believe. My home computer is connected via DSL. I run an ftp server and I have a home network behind the machine so that it acts as the router/gateway for that network.
I get a lot of ftp traffic, sometimes so much that traffic from the
home network is too slow to be useful. What is the easiest way to give all other traffic priority over ftp-data traffic so that it doesn't eat up all my bandwidth and starve my wife's web browsing? Here is what I have tried:

I have tried to use iptables to change the TOS bits such that traffic other than that to port 20 is given priority:

[some commands deleted]
This does not seem to move ftp-data packets into the lowest priority bin. I'm not sure what syntax to use to move all BUT ftp-data packets to the high priority bin or how to move only ftp-data packets into the lower priority bin.

Quoted 6 lines

This is probably something stupid and easy but it's not clear to me right now. Any help would be greatly appreciated. What I'm looking for is the simplest way to give other traffic higher priority than the traffic to/from the ftp-data port (20). Thanks in advance and thanks for your patience.

Depending on the ftp mode clients use, data-port may not be the port 20. In passive mode, the client choose himself the data port. Maybe it is your case.

Quoted 2 lines

==> Troy Rockwood - [email protected]

--
Michael Strauss

_______________________________________________
LARTC mailing list / [email protected]
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://ds9a.nl/lartc/

#2 lore raw
In reply to Troy Rockwood
Quoted 17 lines · --- DLG
Quoted 1 line · Troy Rockwood

My home computer is connected via DSL.

I

Quoted 1 line

run an ftp server and I have a home network behind the machine so

that

Quoted 2 lines

it acts as the router/gateway for that network.
I get a lot of ftp traffic, sometimes so much that traffic from

the

Quoted 1 line

home network is too slow to be useful. What is the easiest way to

give

Quoted 1 line

all other traffic priority over ftp-data traffic so that it doesn't

eat

Quoted 2 lines

up all my bandwidth and starve my wife's web browsing? Any help would be greatly appreciated. What I'm

looking for is the simplest way to give other traffic higher

Quoted 2 lines

priority than the
traffic to/from the ftp-data port (20). Thanks in advance and

Quoted 8 lines

thanks

Quoted 2 lines

for your patience.

Depending on the ftp mode clients use, data-port may not be the port 20.
In passive mode, the client choose himself the data port. Maybe it is your case.

Actually, I checked it with tcpdump (ethereal) and nobody was using passive mode. I'm fine if some people that use ftp accidentally get higher priority (by using passive), it's just when the ftp traffic drowns out everything else that the problem is. At present that means ftp-data (port 20) traffic. Thanks for the reply though I may have to be more clever in the future if passive is used predominantly.

Quoted 3 lines

--
Michael Strauss

==Troy Rockwood - [email protected]

I have made this letter longer than usual because I lack the time to make it shorter. -- Blaise Pascal

__________________________________________________
Do You Yahoo!?
Send FREE video emails in Yahoo! Mail!
http://promo.yahoo.com/videomail/
_______________________________________________
LARTC mailing list / [email protected]
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://ds9a.nl/lartc/

#3 lore raw
In reply to Troy Rockwood

On Fri, 18 Jan 2002, Troy Rockwood wrote:

[snip]

Quoted 6 lines

Actually, I checked it with tcpdump (ethereal) and nobody was using passive mode. I'm fine if some people that use ftp accidentally get higher priority (by using passive), it's just when the ftp traffic drowns out everything else that the problem is. At present that means ftp-data (port 20) traffic. Thanks for the reply though I may have to be more clever in the future if passive is used predominantly.

There is a new match in iptables that you could use. It is a match that's capable of mathing which conntrack helper a related connection belongs to.

so if you load ip_conntrack_ftp then you can do something like this:

iptables -A FORWARD -m helper --helper ftp -j MARK --set-mark 2

then all packet belonging to ftp connection (both the packets in the ftp-command connection and all packets in the related data connections) will have a fwmark of 2. this works for both passive and active ftp.

You'll find this helper match in the iptables patch-o-matic (either from cvs or download iptables 1.2.5)

/Martin

Never argue with an idiot. They drag you down to their level, then beat you with experience.

_______________________________________________
LARTC mailing list / [email protected]
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://ds9a.nl/lartc/