BASH   65

shape sh

Guest on 22nd September 2022 01:25:04 PM

  1. #!/bin/bash
  2.  
  3. # On 100Mbps network shape all traffic going to 192.168.42.11
  4. # to 256Kbps
  5.  
  6. PATH=/bin:/sbin
  7.  
  8. tc qdisc add dev eth1 root handle 1: htb default 1
  9. tc class add dev eth1 parent 1: classid 1:1 htb rate 102400kbit
  10. tc class add dev eth1 parent 1:1 classid 1:10 htb rate 256kbit
  11. tc filter add dev eth1 protocol ip parent 1:0 prio 1 u32 match ip dst 192.168.42.11 flowid 1:10
  12. # To match both IP and port, use:
  13. # tc filter add dev eth1 protocol ip parent 1:0 prio 1 u32 match ip dst 192.168.42.12 match ip dport 22 0xffff flowid 1:10
  14.  
  15. # To unshape, run:
  16. # tc filter del dev eth1 protocol ip parent 1:0 prio 1 u32 match ip dst 192.168.42.11 flowid 1:10

Raw Paste


Login or Register to edit or fork this paste. It's free.