Linux 流量控制中的入口过滤:将流量重定向到 IFB 设备

Linux 流量控制中的入口过滤:将流量重定向到 IFB 设备

我有一台 openwrt 路由器,我想对传入流量进行整形,以便将发往家庭网络中某个 IP 地址的所有流量归类为低优先级。为此,我想将所有传入 eth1 接口(连接到 DSL 调制解调器的接口)的流量重定向到 IFB 设备,我将在该设备上进行整形。以下是我的系统的详细信息:

Linux OpenWrt 2.6.32.27 #7 Fri Jul 15 02:43:34 CEST 2011 mips GNU/Linux

这是我正在使用的脚本,其中最后一条指令失败了:

# Variable definition
ETH=eth1
IFB=ifb1
IP_LP="192.168.1.22/32"
DL_RATE="900kbps"
HP_RATE="890kbps"
LP_RATE="10kbps"
TC="tc"

# Configuring the ifbX interface
insmod ifb
insmod sch_htb
insmod sch_ingress
ifconfig $IFB up

# Adding the HTB scheduler to the ingress interface
$TC qdisc add dev $IFB root handle 1: htb default 11

# Set the maximum bandwidth that each priority class can get, and the maximum borrowing they can do
$TC class add dev $IFB parent 1:1 classid 1:10 htb rate $LP_RATE ceil $DL_RATE
$TC class add dev $IFB parent 1:1 classid 1:11 htb rate $HP_RATE ceil $DL_RATE

# Redirect all ingress traffic arriving at $ETH to $IFB
$TC qdisc del dev $ETH ingress 2>/dev/null
$TC qdisc add dev $ETH ingress
$TC filter add dev $ETH parent ffff: protocol ip prio 1 u32 \
   match u32 0 0 flowid 1:1 \
   action mirred egress redirect dev $IFB

最后一条指令失败:

Action 4 device ifb1 ifindex 9
RTNETLINK answers: No such file or directory
We have an error talking to the kernel

有人知道我做错了什么吗?

答案1

尝试flowid 1:10flowid 1:11。过滤的目的是选择将数据包发送到哪个类,因此不要发送给父类!

相关内容