Ssh flow does not go into correct class. Help!
I'm a new comer. I have problems using tc+htb. I run the following commands, and expect outgoing ssh flow goes into 1:11. But actually it goes into default 12. What's wrong?
tc qdisc add dev eth0 root handle 1: htb default 12
tc class add dev eth0 parent 1: classid 1:1 htb rate 1000kbit ceil 2000kbit prio 1
tc class add dev eth0 parent 1:1 classid 1:11 htb rate 100kbit ceil 100kbit prio 1 tc class add dev eth0 parent 1:1 classid 1:12 htb rate 800kbit ceil 1600kbit prio 1 tc class add dev eth0 parent 1:1 classid 1:13 htb rate 100kbit ceil 100kbit prio 1 tc qdisc add dev eth0 parent 1:11 handle 111: sfq perturb 5
tc qdisc add dev eth0 parent 1:12 handle 112: sfq perturb 5
tc qdisc add dev eth0 parent 1:13 handle 113: sfq perturb 5
iptables -t mangle -A PREROUTING -p tcp -m tcp --sport 22 -j MARK --set-mark 20 iptables -t mangle -A PREROUTING -p tcp -m tcp --sport 22 -j RETURN
tc filter add dev eth0 parent 1:0 prio 1 protocol ip handle 20 fw flowid 1:11
Thanks a lot!
CcM
---------------------------------
Do You Yahoo!?
注册世界一流品质的雅虎免费电邮
I'm a new comer. I have problems using tc+htb. I run the following commands, and expect outgoing ssh flow goes into 1:11. But actually it goes into default 12. What's wrong?
tc qdisc add dev eth0 root handle 1: htb default 12
tc class add dev eth0 parent 1: classid 1:1 htb rate 1000kbit ceil 2000kbit prio 1
tc class add dev eth0 parent 1:1 classid 1:11 htb rate 100kbit ceil 100kbit prio 1 tc class add dev eth0 parent 1:1 classid 1:12 htb rate 800kbit ceil 1600kbit prio 1 tc class add dev eth0 parent 1:1 classid 1:13 htb rate 100kbit ceil 100kbit prio 1 tc qdisc add dev eth0 parent 1:11 handle 111: sfq perturb 5
tc qdisc add dev eth0 parent 1:12 handle 112: sfq perturb 5
tc qdisc add dev eth0 parent 1:13 handle 113: sfq perturb 5
iptables -t mangle -A PREROUTING -p tcp -m tcp --sport 22 -j MARK --set-mark 20 iptables -t mangle -A PREROUTING -p tcp -m tcp --sport 22 -j RETURN
tc filter add dev eth0 parent 1:0 prio 1 protocol ip handle 20 fw flowid 1:11
Thanks a lot!
CcM
---------------------------------
Do You Yahoo!?
注册世界一流品质的雅虎免费电邮
Sorry, I did not make it clear. The machine I want to do traffic control is a server which run sshd. I think it should be --sport. I also tried to use :
iptables -t mangle -A PREROUTING -m tos --tos Minimize-Delay -j MARK --set-mark 20
the ssh traffice still goes into default 12.
following is the evidence:
bash#tc -s -d class show dev eth0
class htb 1:11 parent 1:1 leaf 111: prio 1 quantum 1000 rate 10Kbit ceil 10Kbit burst 1611b/8 mpu 0b cburst 1611b/8 mpu 0b level 0
Sent 0 bytes 0 pkts (dropped 0, overlimits 0)
lended: 0 borrowed: 0 giants: 0
tokens: 1031680 ctokens: 1031680
class htb 1:1 root rate 1000Kbit ceil 2000Kbit burst 2879b/8 mpu 0b cburst 4159b/8 mpu 0b level 7
Sent 21163 bytes 149 pkts (dropped 0, overlimits 0)
rate 5bps
lended: 0 borrowed: 0 giants: 0
tokens: 17818 ctokens: 13004
class htb 1:13 parent 1:1 leaf 113: prio 1 quantum 1280 rate 100Kbit ceil 100Kbit burst 1727b/8 mpu 0b cburst 1727b/8 mpu 0b level 0
Sent 0 bytes 0 pkts (dropped 0, overlimits 0)
lended: 0 borrowed: 0 giants: 0
tokens: 110592 ctokens: 110592
class htb 1:12 parent 1:1 leaf 112: prio 1 quantum 10240 rate 800Kbit ceil 1600Kbit burst 2623b/8 mpu 0b cburst 3647b/8 mpu 0b level 0
Sent 21163 bytes 149 pkts (dropped 0, overlimits 0)
rate 5bps
lended: 149 borrowed: 0 giants: 0
tokens: 20225 ctokens: 14208
Mika Hirvonen <[email protected]> wrote:
Quoted 7 lines · CcM
I'm a new comer. I have problems using tc+htb. I run the following commands, and expect outgoing ssh flow goes into 1:11. But actually it goes into default 12. What's wrong?
iptables -t mangle -A PREROUTING -p tcp -m tcp --sport 22 -j MARK --set-mark 20
iptables -t mangle -A PREROUTING -p tcp -m tcp --sport 22 -j RETURN
These two lines should use --dport instead of --sport. The source port is random.
AFAIR OpenSSH (and probably others) automatically mark their packets with proper ToS flags, so you should considering using those instead of port numbers. If you classify ssh traffic by port number only, SSH file transfers (scp and sftp) end up in the same class as interactive traffic.
Signature · 8 lines
Mika Hirvonen --------------------------------- Do You Yahoo!? 注册世界一流品质的雅虎免费电邮
Use:
iptables -t mangle -A POSTROUTING -p tcp -m tcp --sport 22 -j MARK \
--set-mark 20
---
Catalin(ux aka Dino) BOIE
catab at deuroconsult.ro
http://kernel.umbrella.ro/
_______________________________________________
LARTC mailing list / [email protected]
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/
It does work! Thanks!
But many articles write like what I did, what's the difference between POSTROUTING and PREROUTING. I mean I know these are two hook point in ip stack, but why should be POSTROUTING here when do mangle?
"Catalin(ux aka Dino) BOIE" <[email protected]> wrote:
Use:
iptables -t mangle -A POSTROUTING -p tcp -m tcp --sport 22 -j MARK \
--set-mark 20
---
Catalin(ux aka Dino) BOIE
catab at deuroconsult.ro
http://kernel.umbrella.ro/
_______________________________________________
LARTC mailing list / [email protected]
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/
---------------------------------
Do You Yahoo!?
注册世界一流品质的雅虎免费电邮
Quoted 7 lines · CcM
It does work! Thanks!
But many articles write like what I did, what's the difference between POSTROUTING and PREROUTING. I mean I know these are two hook point in ip stack, but why should be POSTROUTING here when do mangle?"Catalin(ux aka Dino) BOIE" <[email protected]> wrote:
Use:
iptables -t mangle -A POSTROUTING -p tcp -m tcp --sport 22 -j MARK \
--set-mark 20
Because local generated packets doesn't go through PREROUTING. But, best is to use OUTPUT.
Quoted 11 lines
---
Catalin(ux aka Dino) BOIE
catab at deuroconsult.ro
http://kernel.umbrella.ro/
_______________________________________________
LARTC mailing list / [email protected]
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/
Quoted 3 lines
---------------------------------
Do You Yahoo!?
×¢²áÊÀ½çÒ»Á÷Æ·ÖʵÄÑÅ»¢Ãâ·ÑµçÓÊ
---
Catalin(ux aka Dino) BOIE
catab at deuroconsult.ro
http://kernel.umbrella.ro/
Now I want to control ports with ips specified, like following, it seems not work, only --sport effect. Ftp-data goes to ips beside 10.190.6.16 also goes into 1:12 while default is 1:13. Why?
tc qdisc add dev eth0 root handle 1: htb default 13
tc class add dev eth0 parent 1: classid 1:1 htb rate 80000kbit ceil 80000kbit prio 1 tc class add dev eth0 parent 1:1 classid 1:11 htb rate 40kbit ceil 40kbit prio 1 tc class add dev eth0 parent 1:1 classid 1:12 htb rate 800kbit ceil 1600kbit prio 1 tc class add dev eth0 parent 1:1 classid 1:13 htb rate 70000kbit ceil 80000kbit prio 1 tc qdisc add dev eth0 parent 1:11 handle 111: sfq perturb 5
tc qdisc add dev eth0 parent 1:12 handle 112: sfq perturb 5
tc qdisc add dev eth0 parent 1:13 handle 113: sfq perturb 5
iptables -t mangle -A OUTPUT -p tcp -m tcp --sport 22 -j MARK --set-mark 20 iptables -t mangle -A OUTPUT -p tcp -m tcp --sport 22 -j RETURN
iptables -t mangle -A POSTROUTING -d 10.190.6.16 -p tcp --sport ftp-data -j MARK --set-mark 21 iptables -t mangle -A POSTROUTING -d 10.190.6.16 -p tcp --sport ftp-data -j RETURN
tc filter add dev eth0 parent 1:0 prio 1 protocol ip handle 20 fw flowid 1:11 tc filter add dev eth0 parent 1:0 prio 1 protocol ip handle 21 fw flowid 1:12
"Catalin(ux aka Dino) BOIE" <[email protected]> wrote:
Quoted 7 lines · CcM
It does work! Thanks!
But many articles write like what I did, what's the difference between POSTROUTING and PREROUTING. I mean I know these are two hook point in ip stack, but why should be POSTROUTING here when do mangle?"Catalin(ux aka Dino) BOIE" wrote:
Use:
iptables -t mangle -A POSTROUTING -p tcp -m tcp --sport 22 -j MARK \
--set-mark 20
Because local generated packets doesn't go through PREROUTING. But, best is to use OUTPUT.
Quoted 11 lines
---
Catalin(ux aka Dino) BOIE
catab at deuroconsult.ro
http://kernel.umbrella.ro/
_______________________________________________
LARTC mailing list / [email protected]
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/
Quoted 3 lines
---------------------------------
Do You Yahoo!?
注册世界一流品质的雅虎免费电邮
---
Catalin(ux aka Dino) BOIE
catab at deuroconsult.ro
http://kernel.umbrella.ro/
---------------------------------
Do You Yahoo!?
注册世界一流品质的雅虎免费电邮
Quoted 11 lines · CcM
Now I want to control ports with ips specified, like following, it seems not work, only --sport effect. Ftp-data goes to ips beside 10.190.6.16 also goes into 1:12 while default is 1:13. Why?
tc qdisc add dev eth0 root handle 1: htb default 13
tc class add dev eth0 parent 1: classid 1:1 htb rate 80000kbit ceil 80000kbit prio 1 tc class add dev eth0 parent 1:1 classid 1:11 htb rate 40kbit ceil 40kbit prio 1 tc class add dev eth0 parent 1:1 classid 1:12 htb rate 800kbit ceil 1600kbit prio 1 tc class add dev eth0 parent 1:1 classid 1:13 htb rate 70000kbit ceil 80000kbit prio 1 tc qdisc add dev eth0 parent 1:11 handle 111: sfq perturb 5
tc qdisc add dev eth0 parent 1:12 handle 112: sfq perturb 5
tc qdisc add dev eth0 parent 1:13 handle 113: sfq perturb 5
Quoted 5 lines
iptables -t mangle -A OUTPUT -p tcp -m tcp --sport 22 -j MARK --set-mark 20 iptables -t mangle -A OUTPUT -p tcp -m tcp --sport 22 -j RETURN
iptables -t mangle -A POSTROUTING -d 10.190.6.16 -p tcp --sport ftp-data -j MARK --set-mark 21 iptables -t mangle -A POSTROUTING -d 10.190.6.16 -p tcp --sport ftp-data -j RETURN
I bet you use passive mode in ftp so you get a weird port, not ftp-data (20). ftp is tricky to match. You can use this:
iptables -t mangle -A POSTROUTING -d x.x.x.x -m helper --helper ftp \ -j MARK --set-mark 21
This will mark with 21 all ftp control+data connections.
Quoted 40 lines
tc filter add dev eth0 parent 1:0 prio 1 protocol ip handle 20 fw flowid 1:11 tc filter add dev eth0 parent 1:0 prio 1 protocol ip handle 21 fw flowid 1:12
"Catalin(ux aka Dino) BOIE" <[email protected]> wrote:
Quoted 7 lines · CcM
It does work! Thanks!
But many articles write like what I did, what's the difference between POSTROUTING and PREROUTING. I mean I know these are two hook point in ip stack, but why should be POSTROUTING here when do mangle?"Catalin(ux aka Dino) BOIE" wrote:
Use:
iptables -t mangle -A POSTROUTING -p tcp -m tcp --sport 22 -j MARK \
--set-mark 20Because local generated packets doesn't go through PREROUTING. But, best is to use OUTPUT.
Quoted 11 lines
---
Catalin(ux aka Dino) BOIE
catab at deuroconsult.ro
http://kernel.umbrella.ro/
_______________________________________________
LARTC mailing list / [email protected]
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/Quoted 3 lines
---------------------------------
Do You Yahoo!?
×¢²áÊÀ½çÒ»Á÷Æ·ÖʵÄÑÅ»¢Ãâ·ÑµçÓÊ---
Catalin(ux aka Dino) BOIE
catab at deuroconsult.ro
http://kernel.umbrella.ro/
Quoted 3 lines
---------------------------------
Do You Yahoo!?
×¢²áÊÀ½çÒ»Á÷Æ·ÖʵÄÑÅ»¢Ãâ·ÑµçÓÊ
---
Catalin(ux aka Dino) BOIE
catab at deuroconsult.ro
http://kernel.umbrella.ro/
Look at this case, it even does no work!
(following command run on ssh server.)
tc qdisc add dev eth0 root handle 1: htb default 13
tc class add dev eth0 parent 1: classid 1:1 htb rate 500kbit ceil 500kbit tc class add dev eth0 parent 1:1 classid 1:11 htb rate 100kbit ceil 500kbit prio 1 tc class add dev eth0 parent 1:1 classid 1:12 htb rate 100kbit ceil 500kbit prio 1 tc class add dev eth0 parent 1:1 classid 1:13 htb rate 100kbit ceil 500kbit prio 1 tc qdisc add dev eth0 parent 1:11 handle 111: sfq perturb 5
tc qdisc add dev eth0 parent 1:12 handle 112: sfq perturb 5
tc qdisc add dev eth0 parent 1:13 handle 113: sfq perturb 5
iptables -t mangle -A OUTPUT -d 10.190.6.16 -j MARK --set-mark 20 iptables -t mangle -A OUTPUT -d 10.190.6.16 -j RETURN
tc filter add dev eth0 parent 1:0 prio 1 protocol ip handle 20 fw flowid 1:11
I expect data from ssh server to my client 10.190.6.16 should goes into 1:11, and other data goes into default 1:13. But when I use ssh client on other machine(not 10.190.6.16), the data seems also goes into 1:11(I got this from tc -s -d class show dev eth0). Why?
"Catalin(ux aka Dino) BOIE" <[email protected]> wrote:
Quoted 11 lines · CcM
Now I want to control ports with ips specified, like following, it seems not work, only --sport effect. Ftp-data goes to ips beside 10.190.6.16 also goes into 1:12 while default is 1:13. Why?
tc qdisc add dev eth0 root handle 1: htb default 13
tc class add dev eth0 parent 1: classid 1:1 htb rate 80000kbit ceil 80000kbit prio 1 tc class add dev eth0 parent 1:1 classid 1:11 htb rate 40kbit ceil 40kbit prio 1 tc class add dev eth0 parent 1:1 classid 1:12 htb rate 800kbit ceil 1600kbit prio 1 tc class add dev eth0 parent 1:1 classid 1:13 htb rate 70000kbit ceil 80000kbit prio 1 tc qdisc add dev eth0 parent 1:11 handle 111: sfq perturb 5
tc qdisc add dev eth0 parent 1:12 handle 112: sfq perturb 5
tc qdisc add dev eth0 parent 1:13 handle 113: sfq perturb 5
Quoted 5 lines
iptables -t mangle -A OUTPUT -p tcp -m tcp --sport 22 -j MARK --set-mark 20 iptables -t mangle -A OUTPUT -p tcp -m tcp --sport 22 -j RETURN
iptables -t mangle -A POSTROUTING -d 10.190.6.16 -p tcp --sport ftp-data -j MARK --set-mark 21 iptables -t mangle -A POSTROUTING -d 10.190.6.16 -p tcp --sport ftp-data -j RETURN
I bet you use passive mode in ftp so you get a weird port, not ftp-data (20). ftp is tricky to match. You can use this:
iptables -t mangle -A POSTROUTING -d x.x.x.x -m helper --helper ftp \
-j MARK --set-mark 21
This will mark with 21 all ftp control+data connections.
Quoted 40 lines
tc filter add dev eth0 parent 1:0 prio 1 protocol ip handle 20 fw flowid 1:11 tc filter add dev eth0 parent 1:0 prio 1 protocol ip handle 21 fw flowid 1:12
"Catalin(ux aka Dino) BOIE" wrote:
Quoted 7 lines · CcM
It does work! Thanks!
But many articles write like what I did, what's the difference between POSTROUTING and PREROUTING. I mean I know these are two hook point in ip stack, but why should be POSTROUTING here when do mangle?"Catalin(ux aka Dino) BOIE" wrote:
Use:
iptables -t mangle -A POSTROUTING -p tcp -m tcp --sport 22 -j MARK \
--set-mark 20Because local generated packets doesn't go through PREROUTING. But, best is to use OUTPUT.
Quoted 11 lines
---
Catalin(ux aka Dino) BOIE
catab at deuroconsult.ro
http://kernel.umbrella.ro/
_______________________________________________
LARTC mailing list / [email protected]
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/Quoted 3 lines
---------------------------------
Do You Yahoo!?
注册世界一流品质的雅虎免费电邮---
Catalin(ux aka Dino) BOIE
catab at deuroconsult.ro
http://kernel.umbrella.ro/
Quoted 3 lines
---------------------------------
Do You Yahoo!?
注册世界一流品质的雅虎免费电邮
---
Catalin(ux aka Dino) BOIE
catab at deuroconsult.ro
http://kernel.umbrella.ro/
---------------------------------
Do You Yahoo!?
注册世界一流品质的雅虎免费电邮
Quoted 6 lines
iptables -t mangle -A OUTPUT -d 10.190.6.16 -j MARK --set-mark 20 iptables -t mangle -A OUTPUT -d 10.190.6.16 -j RETURN
tc filter add dev eth0 parent 1:0 prio 1 protocol ip handle 20 fw flowid 1:11
I expect data from ssh server to my client 10.190.6.16 should goes into 1:11, and other data goes into default 1:13. But when I use ssh client on other machine(not 10.190.6.16), the data seems also goes into 1:11(I got this from tc -s -d class show dev eth0). Why?
Because you didn't flush the mangle table. Your example works ok for me. Add a iptables -t mangle -F before running the script.
Quoted 77 lines
"Catalin(ux aka Dino) BOIE" <[email protected]> wrote:
Quoted 11 lines · CcM
Now I want to control ports with ips specified, like following, it seems not work, only --sport effect. Ftp-data goes to ips beside 10.190.6.16 also goes into 1:12 while default is 1:13. Why?
tc qdisc add dev eth0 root handle 1: htb default 13
tc class add dev eth0 parent 1: classid 1:1 htb rate 80000kbit ceil 80000kbit prio 1 tc class add dev eth0 parent 1:1 classid 1:11 htb rate 40kbit ceil 40kbit prio 1 tc class add dev eth0 parent 1:1 classid 1:12 htb rate 800kbit ceil 1600kbit prio 1 tc class add dev eth0 parent 1:1 classid 1:13 htb rate 70000kbit ceil 80000kbit prio 1 tc qdisc add dev eth0 parent 1:11 handle 111: sfq perturb 5
tc qdisc add dev eth0 parent 1:12 handle 112: sfq perturb 5
tc qdisc add dev eth0 parent 1:13 handle 113: sfq perturb 5Quoted 5 lines
iptables -t mangle -A OUTPUT -p tcp -m tcp --sport 22 -j MARK --set-mark 20 iptables -t mangle -A OUTPUT -p tcp -m tcp --sport 22 -j RETURN
iptables -t mangle -A POSTROUTING -d 10.190.6.16 -p tcp --sport ftp-data -j MARK --set-mark 21 iptables -t mangle -A POSTROUTING -d 10.190.6.16 -p tcp --sport ftp-data -j RETURN
I bet you use passive mode in ftp so you get a weird port, not ftp-data (20). ftp is tricky to match. You can use this:
iptables -t mangle -A POSTROUTING -d x.x.x.x -m helper --helper ftp \
-j MARK --set-mark 21
This will mark with 21 all ftp control+data connections.Quoted 40 lines
tc filter add dev eth0 parent 1:0 prio 1 protocol ip handle 20 fw flowid 1:11 tc filter add dev eth0 parent 1:0 prio 1 protocol ip handle 21 fw flowid 1:12
"Catalin(ux aka Dino) BOIE" wrote:
Quoted 7 lines · CcM
It does work! Thanks!
But many articles write like what I did, what's the difference between POSTROUTING and PREROUTING. I mean I know these are two hook point in ip stack, but why should be POSTROUTING here when do mangle?"Catalin(ux aka Dino) BOIE" wrote:
Use:
iptables -t mangle -A POSTROUTING -p tcp -m tcp --sport 22 -j MARK \
--set-mark 20Because local generated packets doesn't go through PREROUTING. But, best is to use OUTPUT.
Quoted 11 lines
---
Catalin(ux aka Dino) BOIE
catab at deuroconsult.ro
http://kernel.umbrella.ro/
_______________________________________________
LARTC mailing list / [email protected]
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/Quoted 3 lines
---------------------------------
Do You Yahoo!?
×¢²áÊÀ½çÒ»Á÷Æ·ÖʵÄÑÅ»¢Ãâ·ÑµçÓÊ---
Catalin(ux aka Dino) BOIE
catab at deuroconsult.ro
http://kernel.umbrella.ro/Quoted 3 lines
---------------------------------
Do You Yahoo!?
×¢²áÊÀ½çÒ»Á÷Æ·ÖʵÄÑÅ»¢Ãâ·ÑµçÓÊ---
Catalin(ux aka Dino) BOIE
catab at deuroconsult.ro
http://kernel.umbrella.ro/
Quoted 3 lines
---------------------------------
Do You Yahoo!?
×¢²áÊÀ½çÒ»Á÷Æ·ÖʵÄÑÅ»¢Ãâ·ÑµçÓÊ
---
Catalin(ux aka Dino) BOIE
catab at deuroconsult.ro
http://kernel.umbrella.ro/
You're right. Thank you very much!
"Catalin(ux aka Dino) BOIE" <[email protected]> wrote:> iptables -t mangle -A OUTPUT -d 10.190.6.16 -j MARK --set-mark 20
Quoted 8 lines
iptables -t mangle -A OUTPUT -d 10.190.6.16 -j RETURN
tc filter add dev eth0 parent 1:0 prio 1 protocol ip handle 20 fw flowid 1:11
I expect data from ssh server to my client 10.190.6.16 should goes into 1:11, and other data goes into default 1:13. But when I use ssh client on other machine(not 10.190.6.16), the data seems also goes into 1:11(I got this from tc -s -d class show dev eth0). Why?
Because you didn't flush the mangle table. Your example works ok for me. Add a iptables -t mangle -F before running the script.
Quoted 77 lines
"Catalin(ux aka Dino) BOIE" wrote:
Quoted 11 lines · CcM
Now I want to control ports with ips specified, like following, it seems not work, only --sport effect. Ftp-data goes to ips beside 10.190.6.16 also goes into 1:12 while default is 1:13. Why?
tc qdisc add dev eth0 root handle 1: htb default 13
tc class add dev eth0 parent 1: classid 1:1 htb rate 80000kbit ceil 80000kbit prio 1 tc class add dev eth0 parent 1:1 classid 1:11 htb rate 40kbit ceil 40kbit prio 1 tc class add dev eth0 parent 1:1 classid 1:12 htb rate 800kbit ceil 1600kbit prio 1 tc class add dev eth0 parent 1:1 classid 1:13 htb rate 70000kbit ceil 80000kbit prio 1 tc qdisc add dev eth0 parent 1:11 handle 111: sfq perturb 5
tc qdisc add dev eth0 parent 1:12 handle 112: sfq perturb 5
tc qdisc add dev eth0 parent 1:13 handle 113: sfq perturb 5Quoted 5 lines
iptables -t mangle -A OUTPUT -p tcp -m tcp --sport 22 -j MARK --set-mark 20 iptables -t mangle -A OUTPUT -p tcp -m tcp --sport 22 -j RETURN
iptables -t mangle -A POSTROUTING -d 10.190.6.16 -p tcp --sport ftp-data -j MARK --set-mark 21 iptables -t mangle -A POSTROUTING -d 10.190.6.16 -p tcp --sport ftp-data -j RETURN
I bet you use passive mode in ftp so you get a weird port, not ftp-data (20). ftp is tricky to match. You can use this:
iptables -t mangle -A POSTROUTING -d x.x.x.x -m helper --helper ftp \
-j MARK --set-mark 21
This will mark with 21 all ftp control+data connections.Quoted 40 lines
tc filter add dev eth0 parent 1:0 prio 1 protocol ip handle 20 fw flowid 1:11 tc filter add dev eth0 parent 1:0 prio 1 protocol ip handle 21 fw flowid 1:12
"Catalin(ux aka Dino) BOIE" wrote:
Quoted 7 lines · CcM
It does work! Thanks!
But many articles write like what I did, what's the difference between POSTROUTING and PREROUTING. I mean I know these are two hook point in ip stack, but why should be POSTROUTING here when do mangle?"Catalin(ux aka Dino) BOIE" wrote:
Use:
iptables -t mangle -A POSTROUTING -p tcp -m tcp --sport 22 -j MARK \
--set-mark 20Because local generated packets doesn't go through PREROUTING. But, best is to use OUTPUT.
Quoted 11 lines
---
Catalin(ux aka Dino) BOIE
catab at deuroconsult.ro
http://kernel.umbrella.ro/
_______________________________________________
LARTC mailing list / [email protected]
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/Quoted 3 lines
---------------------------------
Do You Yahoo!?
注册世界一流品质的雅虎免费电邮---
Catalin(ux aka Dino) BOIE
catab at deuroconsult.ro
http://kernel.umbrella.ro/Quoted 3 lines
---------------------------------
Do You Yahoo!?
注册世界一流品质的雅虎免费电邮---
Catalin(ux aka Dino) BOIE
catab at deuroconsult.ro
http://kernel.umbrella.ro/
Quoted 3 lines
---------------------------------
Do You Yahoo!?
注册世界一流品质的雅虎免费电邮
---
Catalin(ux aka Dino) BOIE
catab at deuroconsult.ro
http://kernel.umbrella.ro/
---------------------------------
Do You Yahoo!?
注册世界一流品质的雅虎免费电邮