N
netmask
Guest
Hi All,
I limited only one ve's bandwidth using this script;
#!/bin/sh
#
# Incoming traffic control (from whole internet to your vms)
#
# HERE YOU PUT YOUR VMs IPS
# IF YOU LEAVE IT BLANK, IT WILL NOT BE USED
# CT_IP3 is blank then the CT_IP3 limit will be ignored below
CT_IP1=xx.xx.xx.xx
#CT_IP2=VM_IP_NUMBER_2
#CT_IP3=
#set the device name -- if your proxmox have the default config, it is venet0
DEV=venet0
#now we give a name for the rule
tc qdisc del dev $DEV root
#now we create a class inside it (1
tc qdisc add dev $DEV root handle 1: htb default 10
#now we set your main server connection (100mbit, 10mbit, etc)
#considering you asked 2mbps per VPS, i think you have 5 VMs and want 2mbps each
#so you probably have 10mbit, i'm right?
tc class add dev $DEV parent 1: classid 1:1 htb rate 100mbit burst 15k
#now we create sections for each speed limit you want to your VMs
tc class add dev $DEV parent 1:1 classid 1:10 htb rate 1mbit ceil 1mbit burst 15k
tc class add dev $DEV parent 1:1 classid 1:20 htb rate 2mbit ceil 2mbit burst 15k
tc class add dev $DEV parent 1:1 classid 1:30 htb rate 3mbit ceil 3mbit burst 15k
#
tc qdisc add dev $DEV parent 1:10 handle 10: sfq perturb 10
tc qdisc add dev $DEV parent 1:20 handle 20: sfq perturb 10
tc qdisc add dev $DEV parent 1:30 handle 30: sfq perturb 10
#this will limit your CT_IP1 (container ip 1) to the 1:10 speed limit (1mbps)
if [ ! -z $CT_IP1 ]; then
tc filter add dev $DEV protocol ip parent 1:0 prio 1 u32 match ip dst "$CT_IP1" flowid 1:10
fi
#this will limit your CT_IP2 (container ip 2) to the 1:20 speed limit (2mbps)
if [ ! -z $CT_IP2 ]; then
tc filter add dev $DEV protocol ip parent 1:0 prio 1 u32 match ip dst "$CT_IP2" flowid 1:20
fi
#this will limit your CT_IP3 (container ip 3) to the 1:30 speed limit (3mbps)
if [ ! -z $CT_IP3 ]; then
tc filter add dev $DEV protocol ip parent 1:0 prio 1 u32 match ip dst "$CT_IP3" flowid 1:30
fi
#
echo;echo "tc configuration for $DEV:"
tc qdisc show dev $DEV
tc class show dev $DEV
tc filter show dev $DEV
#
# Outgoing traffic control (from your vms to the whole internet)
#
DEV=eth0
#
tc qdisc del dev $DEV root
#
tc qdisc add dev $DEV root handle 1: htb default 10
#
tc class add dev $DEV parent 1: classid 1:1 htb rate 100mbit burst 15k
tc class add dev $DEV parent 1:1 classid 1:10 htb rate 1mbit ceil 1mbit burst 15k
tc class add dev $DEV parent 1:1 classid 1:20 htb rate 2mbit ceil 2mbit burst 15k
tc class add dev $DEV parent 1:1 classid 1:30 htb rate 3mbit ceil 3mbit burst 15k
#
tc qdisc add dev $DEV parent 1:10 handle 10: sfq perturb 10
tc qdisc add dev $DEV parent 1:20 handle 20: sfq perturb 10
tc qdisc add dev $DEV parent 1:30 handle 30: sfq perturb 10
#
if [ ! -z $CT_IP1 ]; then
tc filter add dev $DEV protocol ip parent 1:0 prio 1 u32 match ip src "$CT_IP1" flowid 1:10
fi
if [ ! -z $CT_IP2 ]; then
tc filter add dev $DEV protocol ip parent 1:0 prio 1 u32 match ip src "$CT_IP2" flowid 1:20
fi
if [ ! -z $CT_IP3 ]; then
tc filter add dev $DEV protocol ip parent 1:0 prio 1 u32 match ip src "$CT_IP3" flowid 1:30
fi
#
echo;echo "tc configuration for $DEV:"
tc qdisc show dev $DEV
tc class show dev $DEV
tc filter show dev $DEV
but all other containers and vps itself are limited.proxmox web admin interface comes very slowly.
I limited only one ve's bandwidth using this script;
#!/bin/sh
#
# Incoming traffic control (from whole internet to your vms)
#
# HERE YOU PUT YOUR VMs IPS
# IF YOU LEAVE IT BLANK, IT WILL NOT BE USED
# CT_IP3 is blank then the CT_IP3 limit will be ignored below
CT_IP1=xx.xx.xx.xx
#CT_IP2=VM_IP_NUMBER_2
#CT_IP3=
#set the device name -- if your proxmox have the default config, it is venet0
DEV=venet0
#now we give a name for the rule
tc qdisc del dev $DEV root
#now we create a class inside it (1
tc qdisc add dev $DEV root handle 1: htb default 10
#now we set your main server connection (100mbit, 10mbit, etc)
#considering you asked 2mbps per VPS, i think you have 5 VMs and want 2mbps each
#so you probably have 10mbit, i'm right?
tc class add dev $DEV parent 1: classid 1:1 htb rate 100mbit burst 15k
#now we create sections for each speed limit you want to your VMs
tc class add dev $DEV parent 1:1 classid 1:10 htb rate 1mbit ceil 1mbit burst 15k
tc class add dev $DEV parent 1:1 classid 1:20 htb rate 2mbit ceil 2mbit burst 15k
tc class add dev $DEV parent 1:1 classid 1:30 htb rate 3mbit ceil 3mbit burst 15k
#
tc qdisc add dev $DEV parent 1:10 handle 10: sfq perturb 10
tc qdisc add dev $DEV parent 1:20 handle 20: sfq perturb 10
tc qdisc add dev $DEV parent 1:30 handle 30: sfq perturb 10
#this will limit your CT_IP1 (container ip 1) to the 1:10 speed limit (1mbps)
if [ ! -z $CT_IP1 ]; then
tc filter add dev $DEV protocol ip parent 1:0 prio 1 u32 match ip dst "$CT_IP1" flowid 1:10
fi
#this will limit your CT_IP2 (container ip 2) to the 1:20 speed limit (2mbps)
if [ ! -z $CT_IP2 ]; then
tc filter add dev $DEV protocol ip parent 1:0 prio 1 u32 match ip dst "$CT_IP2" flowid 1:20
fi
#this will limit your CT_IP3 (container ip 3) to the 1:30 speed limit (3mbps)
if [ ! -z $CT_IP3 ]; then
tc filter add dev $DEV protocol ip parent 1:0 prio 1 u32 match ip dst "$CT_IP3" flowid 1:30
fi
#
echo;echo "tc configuration for $DEV:"
tc qdisc show dev $DEV
tc class show dev $DEV
tc filter show dev $DEV
#
# Outgoing traffic control (from your vms to the whole internet)
#
DEV=eth0
#
tc qdisc del dev $DEV root
#
tc qdisc add dev $DEV root handle 1: htb default 10
#
tc class add dev $DEV parent 1: classid 1:1 htb rate 100mbit burst 15k
tc class add dev $DEV parent 1:1 classid 1:10 htb rate 1mbit ceil 1mbit burst 15k
tc class add dev $DEV parent 1:1 classid 1:20 htb rate 2mbit ceil 2mbit burst 15k
tc class add dev $DEV parent 1:1 classid 1:30 htb rate 3mbit ceil 3mbit burst 15k
#
tc qdisc add dev $DEV parent 1:10 handle 10: sfq perturb 10
tc qdisc add dev $DEV parent 1:20 handle 20: sfq perturb 10
tc qdisc add dev $DEV parent 1:30 handle 30: sfq perturb 10
#
if [ ! -z $CT_IP1 ]; then
tc filter add dev $DEV protocol ip parent 1:0 prio 1 u32 match ip src "$CT_IP1" flowid 1:10
fi
if [ ! -z $CT_IP2 ]; then
tc filter add dev $DEV protocol ip parent 1:0 prio 1 u32 match ip src "$CT_IP2" flowid 1:20
fi
if [ ! -z $CT_IP3 ]; then
tc filter add dev $DEV protocol ip parent 1:0 prio 1 u32 match ip src "$CT_IP3" flowid 1:30
fi
#
echo;echo "tc configuration for $DEV:"
tc qdisc show dev $DEV
tc class show dev $DEV
tc filter show dev $DEV
but all other containers and vps itself are limited.proxmox web admin interface comes very slowly.