Доброго времени суток.
Проблема вот в чем: Есть машина A, которая через NAT дает интернет для машины B (ip 192.168.1.10). Хотел настроить приоретизацию/ограничение некоторого трафика, но почему-то не работает правило на основе ip_src:
qos.tc
#include "fields.tc"
#include "ports.tc"
#define INTERFACE ppp0
dev INTERFACE {
egress {
class ( <$games> )
if udp_sport == 27960 || udp_dport == 27960;
class ( <$client1> )
if ip_dst == 192.168.1.10 || ip_src == 192.168.1.10;
class ( <$other> )
if 1;
htb () {
class ( rate 600kbps, ceil 900kbps ) {
$games = class (rate 400kbps, ceil 800kbps, prio 1) { sfq; };
$other = class ( rate 600kbps, ceil 900kbps, prio 2 ) { sfq; };
$client1 = class ( rate 320kbps, ceil 400kbps, prio 3) { sfq; };
}
}
}
}
После преобразования этого в скрипта в правила для tc (tcng -r qos.tc > qos.sh) получаю вот что:
# cat qos.sh
tc qdisc del dev ppp0 root
# ================================ Device ppp0 ================================
tc qdisc add dev ppp0 handle 1:0 root dsmark indices 4 default_index 0
tc qdisc add dev ppp0 handle 2:0 parent 1:0 htb
tc class add dev ppp0 parent 2:0 classid 2:1 htb rate 75000bps ceil 112500bps
tc class add dev ppp0 parent 2:1 classid 2:2 htb rate 50000bps ceil 100000bps prio 1
tc qdisc add dev ppp0 handle 3:0 parent 2:2 sfq
tc class add dev ppp0 parent 2:1 classid 2:3 htb rate 75000bps ceil 112500bps prio 2
tc qdisc add dev ppp0 handle 4:0 parent 2:3 sfq
tc class add dev ppp0 parent 2:1 classid 2:4 htb rate 40000bps ceil 50000bps prio 3
tc qdisc add dev ppp0 handle 5:0 parent 2:4 sfq
tc filter add dev ppp0 parent 2:0 protocol all prio 1 tcindex mask 0x3 shift 0
tc filter add dev ppp0 parent 2:0 protocol all prio 1 handle 3 tcindex classid 2:3
tc filter add dev ppp0 parent 2:0 protocol all prio 1 handle 2 tcindex classid 2:4
tc filter add dev ppp0 parent 2:0 protocol all prio 1 handle 1 tcindex classid 2:2
tc filter add dev ppp0 parent 1:0 protocol all prio 1 handle 1:0:0 u32 divisor 1
tc filter add dev ppp0 parent 1:0 protocol all prio 1 u32 match u8 0x11 0xff at 9 offset at 0 mask 0f00 shift 6 eat link 1:0:0
tc filter add dev ppp0 parent 1:0 protocol all prio 1 handle 1:0:1 u32 ht 1:0:0 match u16 0x6d38 0xffff at 0 classid 1:1
tc filter add dev ppp0 parent 1:0 protocol all prio 1 handle 2:0:0 u32 divisor 1
tc filter add dev ppp0 parent 1:0 protocol all prio 1 u32 match u8 0x11 0xff at 9 offset at 0 mask 0f00 shift 6 eat link 2:0:0
tc filter add dev ppp0 parent 1:0 protocol all prio 1 handle 2:0:1 u32 ht 2:0:0 match u16 0x6d38 0xffff at 2 classid 1:1
tc filter add dev ppp0 parent 1:0 protocol all prio 1 u32 match u32 0xc0a8010a 0xffffffff at 16 classid 1:2
tc filter add dev ppp0 parent 1:0 protocol all prio 1 u32 match u32 0xc0a8010a 0xffffffff at 12 classid 1:2
tc filter add dev ppp0 parent 1:0 protocol all prio 1 u32 match u32 0x0 0x0 at 0 classid 1:3
Запускаю:
# sh qos.sh
RTNETLINK answers: No such file or directory
# tc -s class show dev ppp0
class htb 2:1 root rate 600000bit ceil 900000bit burst 1599b cburst 1599b
Sent 6093205 bytes 12514 pkt (dropped 0, overlimits 0 requeues 0)
rate 576664bit 143pps backlog 0b 0p requeues 0
lended: 0 borrowed: 0 giants: 0
tokens: -1323080 ctokens: -11919
class htb 2:2 parent 2:1 leaf 3: prio 1 rate 400000bit ceil 800000bit burst 1599b cburst 1599b
Sent 110129 bytes 1972 pkt (dropped 0, overlimits 0 requeues 0)
rate 10376bit 23pps backlog 0b 0p requeues 0
lended: 1972 borrowed: 0 giants: 0
tokens: 30156 ctokens: 15078
class htb 2:3 parent 2:1 leaf 4: prio 2 rate 600000bit ceil 900000bit burst 1599b cburst 1599b
Sent 6058857 bytes 10599 pkt (dropped 1, overlimits 0 requeues 0)
rate 568096bit 120pps backlog 0b 57p requeues 0
lended: 10542 borrowed: 0 giants: 0
tokens: -38714 ctokens: -11919
class htb 2:4 parent 2:1 leaf 5: prio 3 rate 320000bit ceil 400000bit burst 1599b cburst 1599b
Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
rate 0bit 0pps backlog 0b 0p requeues 0
lended: 0 borrowed: 0 giants: 0
tokens: 39062 ctokens: 31249
И как видим, не работает правило с ip_src/ip_dst. Не могу понять в чем причина.