我想在路由器的wlan0设备上删除输出数据包&busy;' Linux版本2.6.30.9' tc实用程序,iproute2-ss060323&#39 ;,' iptables v1.3.5'。
我的所作所为:
tc qdisc add dev wlan0 root handle 1:htb default 0
tc class add dev wlan0 parent 1:classid 1:1 htb rate 3mbit ceil 3mbit burst 15k
tc class add dev wlan0 parent 1:1 classid 1:10 htb rate 100kbps ceil 100kbps burst 15k
tc class add dev wlan0 parent 1:1 classid 1:20 htb rate 84kbps ceil 84kbps burst 15k
tc class add dev wlan0 parent 1:1 classid 1:30 htb rate 200kbps ceil 200kbps burst 15k
tc qdisc add dev wlan0 parent 1:10 pfifo
tc qdisc add dev wlan0 parent 1:20 pfifo
tc qdisc add dev wlan0 parent 1:30 pfifo
# tc -s -d qdisc show dev wlan0
qdisc htb 1: r2q 10 default 0 direct_packets_stat 3252 ver 3.17
Sent 4494542 bytes 3262 pkt (dropped 0, overlimits 0 requeues 0)
rate 0bit 0pps backlog 0b 0p requeues 0
qdisc pfifo 8001: parent 1:10 [Unknown qdisc, optlen=4]
Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
rate 0bit 0pps backlog 0b 0p requeues 0
qdisc pfifo 8002: parent 1:20 [Unknown qdisc, optlen=4]
Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
rate 0bit 0pps backlog 0b 0p requeues 0
qdisc pfifo 8003: parent 1:30 [Unknown qdisc, optlen=4]
Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
rate 0bit 0pps backlog 0b 0p requeues 0
tc filter add dev wlan0 parent 1:0 protocol ip prio 1 u32 match ip src 192.168.1.202/32 classid 1:30
tc filter add dev wlan0 parent 1:0 protocol ip prio 2 u32 match ip dst 192.168.1.202/32 classid 1:30
# tc -s -d qdisc show dev wlan0
qdisc htb 1: r2q 10 default 0 direct_packets_stat 9754 ver 3.17
Sent 14208062 bytes 9928 pkt (dropped 0, overlimits 0 requeues 0)
rate 0bit 0pps backlog 0b 0p requeues 0
qdisc pfifo 8001: parent 1:10 [Unknown qdisc, optlen=4]
Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
rate 0bit 0pps backlog 0b 0p requeues 0
qdisc pfifo 8002: parent 1:20 [Unknown qdisc, optlen=4]
Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
rate 0bit 0pps backlog 0b 0p requeues 0
qdisc pfifo 8003: parent 1:30 [Unknown qdisc, optlen=4]
Sent 26713 bytes 164 pkt (dropped 0, overlimits 0 requeues 0)
rate 0bit 0pps backlog 0b 0p requeues 0
tc filter del dev wlan0 parent 1:0 protocol ip prio 1 u32 match ip src 192.168.1.202/32 classid 1:30
tc filter del dev wlan0 parent 1:0 protocol ip prio 2 u32 match ip dst 192.168.1.202/32 classid 1:30
tc filter add dev wlan0 parent 1:0 protocol ip prio 50 u32 match ip src 0.0.0.0/0 flowid 1:30
# tc -s -d qdisc show dev wlan0
qdisc htb 1: r2q 10 default 0 direct_packets_stat 9796 ver 3.17
Sent 25807228 bytes 17790 pkt (dropped 276, overlimits 9955 requeues 0)
rate 0bit 0pps backlog 0b 0p requeues 0
qdisc pfifo 8001: parent 1:10 [Unknown qdisc, optlen=4]
Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
rate 0bit 0pps backlog 0b 0p requeues 0
qdisc pfifo 8002: parent 1:20 [Unknown qdisc, optlen=4]
Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
rate 0bit 0pps backlog 0b 0p requeues 0
qdisc pfifo 8003: parent 1:30 [Unknown qdisc, optlen=4]
Sent 11616972 bytes 7984 pkt (dropped 276, overlimits 0 requeues 0)
rate 0bit 0pps backlog 0b 0p requeues 0
2,我得到了什么?
我可以过滤所有流量并将其指向1:30级别的速度限制。
我无法过滤从路由器到笔记本电脑的WGET流量。
3.问题:
如何创建过滤器,只能在1:30级从路由器到笔记本电脑的流量?
如何查看使用&t; tc过滤器添加的所有过滤器添加...'?
答案 0 :(得分:0)
Use this:
tc filter add dev wlan0 parent 10:0 protocol ip prio 50 u32 \
match ip dst 192.168.1.202 flowid 10:1
Where 10:1
is the classid of qdisc.
To view statistics of filters:
tc -s -d filter show dev wlan0 egress