Voor mijn gevoel zit ik al een eeuwigheid te hanessen met Traffic Classing onder Linux. Hierbij probeer ik gebruik te maken van het markeren van packets in de iptables.
Maar op een of andere manier, hoe het ook went of keert, vat 'tc' op als 1 markering.
Ik ben volgende code rijk:
Het zou zo moeten zijn dat pakjes die NAT translated worden die uitgaan op ppp0 ondergebracht worden in class 1:3 en alles wat binnenkomt in class 1:2
Maar alles wordt lukraak in class 1:3 gedonderd! Terwijl:
iptables wel zegt onderscheid te maken, maar 'tc' zegt:
Alles met markering 2 word niet opgepakt, of als class 1:3 (voor de upload) opgepakt. (1:2 is 0 bytes sent)
Wat zie ik over het hoofd? zijn er dingen die ik totaal verkeerd aan 'tc' begrepen heb?
Maar op een of andere manier, hoe het ook went of keert, vat 'tc' op als 1 markering.
Ik ben volgende code rijk:
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
| #!/bin/bash iptables -F iptables -t mangle -F iptables -t nat -F iptables -t nat -A POSTROUTING -j MASQUERADE iptables -t mangle -A FORWARD ! -s 192.168.1.0/24 -d 192.168.1.0/24 -p tcp --sport 1024:65535 --dport 1024:65535 -j MARK --set-mark 2 iptables -t mangle -A FORWARD -s 192.168.1.0/24 ! -d 192.168.1.0/24 -p tcp --sport 1024:65535 --dport 1024:65535 -j MARK --set-mark 3 # 2 = download # 3 = upload tc qdisc del dev ppp0 root tc qdisc add dev ppp0 root handle 1:0 htb tc class add dev ppp0 parent 1:0 classid 1:1 htb rate 100mbit tc class add dev ppp0 parent 1:1 classid 1:2 htb rate 5500kbit ceil 5500kbit tc class add dev ppp0 parent 1:1 classid 1:3 htb rate 500kbit ceil 500kbit tc filter add dev ppp0 parent 1:0 prio 0 protocol ip handle 2 fw flowid 1:2 tc filter add dev ppp0 parent 1:0 prio 0 protocol ip handle 3 fw flowid 1:3 |
Het zou zo moeten zijn dat pakjes die NAT translated worden die uitgaan op ppp0 ondergebracht worden in class 1:3 en alles wat binnenkomt in class 1:2
Maar alles wordt lukraak in class 1:3 gedonderd! Terwijl:
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
| root@mercury:~/shape# iptables -t mangle -vnL Chain PREROUTING (policy ACCEPT 2129M packets, 627G bytes) pkts bytes target prot opt in out source destination Chain INPUT (policy ACCEPT 1781M packets, 442G bytes) pkts bytes target prot opt in out source destination Chain FORWARD (policy ACCEPT 347M packets, 185G bytes) pkts bytes target prot opt in out source destination 35636 46M MARK tcp -- * * !192.168.1.0/24 192.168.1.0/24 tcp spts:1024:65535 dpts:1024:65535 MARK set 0x2 27225 2501K MARK tcp -- * * 192.168.1.0/24 !192.168.1.0/24 tcp spts:1024:65535 dpts:1024:65535 MARK set 0x3 Chain OUTPUT (policy ACCEPT 1917M packets, 227G bytes) pkts bytes target prot opt in out source destination Chain POSTROUTING (policy ACCEPT 2264M packets, 411G bytes) pkts bytes target prot opt in out source destination |
iptables wel zegt onderscheid te maken, maar 'tc' zegt:
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
| root@mercury:~/shape# tc -c -d class show dev ppp0 Option "-c" is unknown, try "tc -help". root@mercury:~/shape# tc -s -d class show dev ppp0 class htb 1:1 root rate 100Mbit ceil 100Mbit burst 51587b/8 mpu 0b overhead 0b cburst 51587b/8 mpu 0b overhead 0b level 7 Sent 3023574 bytes 34214 pkts (dropped 0, overlimits 0 requeues 0) rate 11609bit 155pps lended: 0 borrowed: 0 giants: 0 tokens: 4222 ctokens: 4222 class htb 1:2 parent 1:1 prio 0 quantum 68750 rate 5500Kbit ceil 5500Kbit burst 4349b/8 mpu 0b overhead 0b cburst 4349b/8 mpu 0b overhead 0b level 0 Sent 0 bytes 0 pkts (dropped 0, overlimits 0 requeues 0) lended: 0 borrowed: 0 giants: 0 tokens: 6478 ctokens: 6478 class htb 1:3 parent 1:1 prio 0 quantum 6250 rate 500Kbit ceil 500Kbit burst 1849b/8 mpu 0b overhead 0b cburst 1849b/8 mpu 0b overhead 0b level 0 Sent 3023574 bytes 34214 pkts (dropped 5, overlimits 0 requeues 0) rate 11587bit 155pps lended: 34214 borrowed: 0 giants: 0 tokens: 29262 ctokens: 29262 |
Alles met markering 2 word niet opgepakt, of als class 1:3 (voor de upload) opgepakt. (1:2 is 0 bytes sent)
Wat zie ik over het hoofd? zijn er dingen die ik totaal verkeerd aan 'tc' begrepen heb?
Solar @ Dongen: http://solar.searchy.net/ - Penpal International: http://ppi.searchy.net/