0
# task - to limit incoming traffic by subnets / hosts
  2
  3 # clean up
  4 tc qdisc del dev ppp7 root
  5 tc qdisc del dev ifb0 root.
  6 tc qdisc del dev ppp7 handle ffff: ingress
  7
  8
  9 # raise the virtual interface
 10 modprobe ifb
 11 ifconfig ifb0 up
 12
 13
 14
 15 # redirect all incoming traffic to ppp7 from WAN interface to ifb0
 16 tc qdisc add dev ppp7 handle ffff: ingress
 17 tc filter add dev ppp7 parent ffff: protocol ip u32 match u32 0 0 action mirred egress redirect dev ifb0
 18
 19 # add root discipline to virtual interface
 20 tc qdisc add dev ifb0 root handle 2: htb default 100
 21
 22 # I limit "general" traffic.
 23 tc class add dev ifb0 parent 2: classid 2: 100 htb rate 300kbit
 24
 25 # create classes for hosts / networks
 26 tc class add dev ifb0 parent 2: classid 2: 1 htb rate 0.1mbit
 27 tc class add dev ifb0 parent 2: classid 2: 2 htb rate 0.1mbit
 28
 29 # add filters to sort traffic
 30 tc filter add dev ifb0 protocol ip parent 2: u32 match ip src 192.168.4.2 flowid 2: 1
 31 tc filter add dev ifb0 protocol ip parent 2: u32 match ip src 192.168.4.129 flowid 2: 2 

while watching the statistics

class htb 2:1 root prio 0 rate 100Kbit ceil 100Kbit burst 1600b cburst 1600b 
 Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) 
 rate 0bit 0pps backlog 0b 0p requeues 0 
 lended: 0 borrowed: 0 giants: 0
 tokens: 2000000 ctokens: 2000000

class htb 2:100 root prio 0 rate 1Mbit ceil 1Mbit burst 1600b cburst 1600b 
 Sent 18965519 bytes 17012 pkt (dropped 426, overlimits 0 requeues 0) 
 rate 0bit 0pps backlog 0b 0p requeues 0 
 lended: 17012 borrowed: 0 giants: 0
 tokens: 128500 ctokens: 128500

class htb 2:20 root prio 0 rate 400Mbit ceil 400Mbit burst 1600b cburst 1600b 
 Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) 
 rate 0bit 0pps backlog 0b 0p requeues 0 
 lended: 0 borrowed: 0 giants: 0
 tokens: 500 ctokens: 500

class htb 2:2 root prio 0 rate 100Kbit ceil 100Kbit burst 1600b cburst 1600b 
 Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) 
 rate 0bit 0pps backlog 0b 0p requeues 0 
 lended: 0 borrowed: 0 giants: 0
 tokens: 2000000 ctokens: 2000000

question: why filters for hosts / subnets don't work?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.