Bandwidth control script for some ips


#!/bin/bash

BANDWIDTH_KBIT=7000
BANDWIDTH_INTERFACE=eth0
FINAL_IPs_WITH_BANDWIDTH_CONTROL=(7 8 50 111)
LAN_IP=$( ip addr show $BANDWIDTH_INTERFACE | grep -Eo '([0-9]{1,3}\.){3}' | sed -n 1p )

# clear all tc rules
tc qdisc del dev $BANDWIDTH_INTERFACE root

# create tc rules
tc qdisc add dev $BANDWIDTH_INTERFACE root handle 1: htb

for i in ${FINAL_IPs_WITH_BANDWIDTH_CONTROL[*]}; do
  tc class add dev $BANDWIDTH_INTERFACE classid 1:${i} htb rate ${BANDWIDTH_KBIT}kbit
  tc filter add dev $BANDWIDTH_INTERFACE parent 1: protocol ip prio 1 u32 match ip dst $LAN_IP${i} flowid 1:${i}
done

to list only machines that have traffic
tc -s -d class show dev eth0 | awk '$1 == "Sent" && $2 { print "\n"x; print } { x=$0 }'

to list only machines that have traffic order by traffic usage
tc -s -d class show dev eth0 | awk 'BEGIN{ ORS=" " } $1 == "Sent" && $2 { print "\n"x; print } { x=$0 }' | cut -d' ' -f1,3,9,10,29,30 | sort -k6n

Updatable objects appear as 'no longer supported'

  Symptoms In some scenarios, the following validation warning appears on an updatable object: " Object is no longer supported. Enforci...

Mais vistos