Не хочу смотреть, так как задача, для простых конфигураций, состоит из двух этапов решения:
ISP на eth0 - 100Мбит/с, и на нём поднимается ppp0. Пропускная способность ppp0 - 1Мбит/с . Локалка eth1 - 100Мбит/с.
Предположим, что ip адрес выданный провайдером на ppp0 - 100.100.100.100, а на eth1 поднят адрес 10.100.1.1/24.
Описываем дисциплины для трафика приходящего к нам из локалки и уходящий в Инет:
Код: Выделить всё
*mangle
:PREROUTING ACCEPT [32379320:8999179347]
:INPUT ACCEPT [32372677:8998522669]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [45137527:54986372461]
:POSTROUTING ACCEPT [45138889:54986475929]
[0:0] -A PREROUTING -s 10.100.1.254/32 -j MARK --set-xmark 1001
[0:0] -A PREROUTING -s 10.100.1.254/32 -j RETURN
[0:0] -A PREROUTING -s 10.100.1.253/32 -j MARK --set-xmark 2002
[0:0] -A PREROUTING -s 10.100.1.253/32 -j RETURN
[0:0] -A PREROUTING -s 10.100.1.252/32 -j MARK --set-xmark 3003
[0:0] -A PREROUTING -s 10.100.1.252/32 -j RETURN
[0:0] -A PREROUTING -s 10.100.1.251/32 -j MARK --set-xmark 4004
[0:0] -A PREROUTING -s 10.100.1.251/32 -j RETURN
COMMIT
Код: Выделить всё
#define IFACE0 ppp0
#define LOCALRT 102400
#define RATE 1024
#define R2Q 7
$rate01 = (RATE/2)/4;
$rate02 = (RATE/2)/4;
$rate03 = (RATE/2)/4;
$rate04 = (RATE/2)/4;
$rate_other = RATE/2;
dev IFACE0 {
egress {
class (<$mark01>) if meta_nfmark==1001;
class (<$mark02>) if meta_nfmark==2002;
class (<$mark03>) if meta_nfmark==3003;
class (<$mark04>) if meta_nfmark==4004;
class (<$low>) if 1;
htb ( rate LOCALRT kbps, r2q R2Q ) {
class ( rate RATE kbps ) {
$mark01 = class ( rate $rate01 kbps ) { sfq(); }
$mark02 = class ( rate $rate02 kbps ) { sfq(); }
$mark03 = class ( rate $rate03 kbps ) { sfq(); }
$mark04 = class ( rate $rate04 kbps ) { sfq(); }
$low = class ( rate $rate_other kbps ) { sfq(); }
}
}
}
}
Преобразуем скрипт tcng в правила tc:
Код:
$ tcng -r linuxforum.ru-topic-79544.ppp0.tcc
tc qdisc del dev ppp0 root
tc qdisc del dev ppp0 ingress
# ================================ Device ppp0 ================================
tc qdisc add dev ppp0 handle 1:0 root dsmark indices 8 default_index 0
tc qdisc add dev ppp0 handle 2:0 parent 1:0 htb r2q 7
tc class add dev ppp0 parent 2:0 classid 2:1 htb rate 128000bps
tc class add dev ppp0 parent 2:1 classid 2:2 htb rate 16000bps
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 16000bps
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 16000bps
tc qdisc add dev ppp0 handle 5:0 parent 2:4 sfq
tc class add dev ppp0 parent 2:1 classid 2:5 htb rate 16000bps
tc qdisc add dev ppp0 handle 6:0 parent 2:5 sfq
tc class add dev ppp0 parent 2:1 classid 2:6 htb rate 64000bps
tc qdisc add dev ppp0 handle 7:0 parent 2:6 sfq
tc filter add dev ppp0 parent 2:0 protocol all prio 1 tcindex mask 0x7 shift 0
tc filter add dev ppp0 parent 2:0 protocol all prio 1 handle 5 tcindex classid 2:6
tc filter add dev ppp0 parent 2:0 protocol all prio 1 handle 4 tcindex classid 2:5
tc filter add dev ppp0 parent 2:0 protocol all prio 1 handle 3 tcindex classid 2:4
tc filter add dev ppp0 parent 2:0 protocol all prio 1 handle 2 tcindex classid 2:3
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 1001 fw classid 1:1
tc filter add dev ppp0 parent 1:0 protocol all prio 1 handle 2002 fw classid 1:2
tc filter add dev ppp0 parent 1:0 protocol all prio 1 handle 3003 fw classid 1:3
tc filter add dev ppp0 parent 1:0 protocol all prio 1 handle 4004 fw classid 1:4
tc filter add dev ppp0 parent 1:0 protocol all prio 2 u32 match u32 0x0 0x0 at 0 classid 1:5
На данном этапе мы закончили первую часть решения.
Что имеем? Спроектированные egress-правила. Жёсткие ограничения в скорости установленные для наших локальных адресов 10.100.1.254, 10.100.1.253, 10.100.1.252 и 10.100.1.251. Все остальные нашей сети используют остаток канала, который останется после распределения нагрузки этих хостов.
Поехали дальше. Рисуем скрипт tcng для eth1:
Код: Выделить всё
#define IFACE0 eth1
#define LOCALRT 102400
#define RATE 1024
#define R2Q 7
$rate01 = (RATE/2)/4;
$rate02 = (RATE/2)/4;
$rate03 = (RATE/2)/4;
$rate04 = (RATE/2)/4;
$rate_other = RATE/2;
dev IFACE0 {
egress {
class (<$mark01>) if ip_dst == 10.100.1.254;
class (<$mark02>) if ip_dst == 10.100.1.253;
class (<$mark03>) if ip_dst == 10.100.1.252;
class (<$mark04>) if ip_dst == 10.100.1.251;
class (<$low>) if ip_dst/24 == 10.100.1.0;
htb ( rate LOCALRT kbps, r2q R2Q ) {
class ( rate RATE kbps ) {
$mark01 = class ( rate $rate01 kbps ) { sfq(); }
$mark02 = class ( rate $rate02 kbps ) { sfq(); }
$mark03 = class ( rate $rate03 kbps ) { sfq(); }
$mark04 = class ( rate $rate04 kbps ) { sfq(); }
$low = class ( rate $rate_other kbps ) { sfq(); }
}
}
}
}
Преобразуем скрипт tcng в правила tc:
Код:
$ tcng -r linuxforum.ru-topic-79544.eth1.tcc
tc qdisc del dev eth1 root
tc qdisc del dev eth1 ingress
# ================================ Device eth1 ================================
tc qdisc add dev eth1 handle 1:0 root dsmark indices 8 default_index 0
tc qdisc add dev eth1 handle 2:0 parent 1:0 htb r2q 7
tc class add dev eth1 parent 2:0 classid 2:1 htb rate 128000bps
tc class add dev eth1 parent 2:1 classid 2:2 htb rate 16000bps
tc qdisc add dev eth1 handle 3:0 parent 2:2 sfq
tc class add dev eth1 parent 2:1 classid 2:3 htb rate 16000bps
tc qdisc add dev eth1 handle 4:0 parent 2:3 sfq
tc class add dev eth1 parent 2:1 classid 2:4 htb rate 16000bps
tc qdisc add dev eth1 handle 5:0 parent 2:4 sfq
tc class add dev eth1 parent 2:1 classid 2:5 htb rate 16000bps
tc qdisc add dev eth1 handle 6:0 parent 2:5 sfq
tc class add dev eth1 parent 2:1 classid 2:6 htb rate 64000bps
tc qdisc add dev eth1 handle 7:0 parent 2:6 sfq
tc filter add dev eth1 parent 2:0 protocol all prio 1 tcindex mask 0x7 shift 0
tc filter add dev eth1 parent 2:0 protocol all prio 1 handle 5 tcindex classid 2:6
tc filter add dev eth1 parent 2:0 protocol all prio 1 handle 4 tcindex classid 2:5
tc filter add dev eth1 parent 2:0 protocol all prio 1 handle 3 tcindex classid 2:4
tc filter add dev eth1 parent 2:0 protocol all prio 1 handle 2 tcindex classid 2:3
tc filter add dev eth1 parent 2:0 protocol all prio 1 handle 1 tcindex classid 2:2
tc filter add dev eth1 parent 1:0 protocol all prio 1 u32 match u32 0xa6401fe 0xffffffff at 16 classid 1:1
tc filter add dev eth1 parent 1:0 protocol all prio 1 u32 match u32 0xa6401fd 0xffffffff at 16 classid 1:2
tc filter add dev eth1 parent 1:0 protocol all prio 1 u32 match u32 0xa6401fc 0xffffffff at 16 classid 1:3
tc filter add dev eth1 parent 1:0 protocol all prio 1 u32 match u32 0xa6401fb 0xffffffff at 16 classid 1:4
tc filter add dev eth1 parent 1:0 protocol all prio 1 u32 match u32 0xa640100 0xffffff00 at 16 classid 1:5
Собственно все

Разве это не решение Вашей задачи?
Естественно, что правила в tcng можно/нужно рисовать свои - они индивидуальны для каждого. Эти примеры носят лишь характер "для справки" и способствуют систематизации некоторых знаний

Достаточно наглядный пример?
