我有一个tc过滤规则:
tc filter add dev eth0 protocol ip prio 1 u32 match ip dst 10.0.0.3 flowid 1:14
如果我尝试“更改”这个过滤规则,我得到一个错误:
# tc filter change dev eth0 protocol ip prio 1 u32 match ip dst 10.0.0.2 flowid 1:14 # RTNETLINK answers: No such file or directory # We have an error talking to the kernel
'replace'添加一个新的,但不要删除旧的规则。
replace / change命令的语法是否正确?
CentOS 6.4 iptables-1.4.7-9.el6.x86_64 iproute-2.6.32-23.el6.x86_64
一个完整的脚本:
tc qdisc add dev eth0 root handle 1:htb tc class add dev eth0 parent 1:classid 1:1 htb rate 1000Mbps tc class add dev eth0 parent 1:1 classid 1:11 htb rate 100Mbps tc class add dev eth0 parent 1:1 classid 1:12 htb rate 100Mbps tc class add dev eth0 parent 1:1 classid 1:13 htb rate 100Mbps tc class add dev eth0 parent 1:1 classid 1:14 htb rate 100Mbps tc qdisc add dev eth0 parent 1:11句柄10:netem延迟0ms tc qdisc add dev eth0 parent 1:12句柄20:netem延迟500ms tc qdisc add dev eth0 parent 1:13 handle 30:netem delay 1000ms tc qdisc add dev eth0 parent 1:14句柄40:netem延迟1500ms tcfilteradd dev eth0协议ip prio 1 u32匹配ip dst 10.0.0.3 flowid 1:11 tcfilteradd dev eth0协议ip prio 1 u32匹配ip dst 10.0.0.8 flowid 1:12 tcfilteradd dev eth0协议ip prio 1 u32匹配ip dst 10.0.0.9 flowid 1:13 tcfilter添加dev dev eth0协议ip prio 1 u32匹配ip dst 10.0.0.7 flowid 1:14
我认为你必须使用句柄,就像这样:
sudo tc filter change dev eth0 pref 1 protocol ip handle 800::800 u32 match ip dst 10.0.0.5 flowid 1:15
– 这样我可以用不同的ip dst发出相同的命令,并且成功应用。
PS句柄显示为tc show ,或者,我相信您可以在第一次添加规则时指定它们。