iptables 's classify

 

說明

CLASSIFY target: only usable from FORWARD/OUTPUT/POSTROUTING

要載入 xt_CLASSIFY module

 


Example

 

Server 的 Web Upload 能力 (443/tcp)

host(ens4) --> Internet

rule

IF=ens4

QOS_CHAIN=outQoS
IPT="/usr/sbin/iptables -t mangle"
$IPT -N $QOS_CHAIN
$IPT -F $QOS_CHAIN

$IPT -I OUTPUT -o $IF -j $QOS_CHAIN
$IPT -A $QOS_CHAIN -o $IF -p tcp --sport 443 -j CLASSIFY --set-class 2:10

Server 的 Web Download 能力 (443/tcp)

Internet --> (ens4 -redirect-> ifb0)host

rule

IF=ens4

QOS_CHAIN=downQoS
IFB=ifb0
TC=/sbin/tc
IPT="/usr/sbin/iptables -t mangle"
$IPT -N $QOS_CHAIN
$IPT -F $QOS_CHAIN

$TC qdisc add dev $IF handle ffff: ingress
$TC filter add dev $IF parent ffff: protocol ip u32 match u32 0 0 action mirred egress redirect dev $IFB

$IPT -I OUTPUT -o $IFB -j $QOS_CHAIN
$IPT -A $QOS_CHAIN -p tcp --dport 443 -j CLASSIFY --set-class $classid

 

Creative Commons license icon Creative Commons license icon