I have a CentOS 7 Linux guest with multiple network interfaces, and I'd like to set different bandwidth control limits on each network interface -or- set limits on only one of three interfaces, etc..
Is there a way to do this?
It appears that the limits I set are applied to all interfaces (except maybe loopback).
Thanks in advance for any tips or advice!
Regards,
Mike
Different bandwidthctl limits on each network interface
Re: Different bandwidthctl limits on each network interface
Figured this out on my own... but posting the solution here for others.
Assuming you want shaping for the 1st adapter, but not the 2nd adapter...
First disable shaping for the 2nd adapter of VM on the host:
VBoxManage modifyvm "VM name" --nicbandwidthgroup2 none
Next, be advised that, by default, Linux tries to reply on interface with the default route (eth0 in this case), even if request came from different interface (eth1).
On RHEL / CentOS guest, create ip rules with IP route table and configure it for both interfaces:
echo 200 reth0 >> /etc/iproute2/rt_tables
echo 201 reth1 >> /etc/iproute2/rt_tables
ip rule add from <IP ADDR of eth0> table reth0
ip rule add from <IP ADDR of eth1> table reth1
ip route add default via <IP ADDR of DEFAULT GATEWAY of eth0> dev eth0 table reth0
ip route add default via <IP ADDR of DEFAULT GATEWAY of eth1> dev eth1 table reth1
Traffic will then be shaped on requests to eth0, but not eth1.
Regards, Mike
Assuming you want shaping for the 1st adapter, but not the 2nd adapter...
First disable shaping for the 2nd adapter of VM on the host:
VBoxManage modifyvm "VM name" --nicbandwidthgroup2 none
Next, be advised that, by default, Linux tries to reply on interface with the default route (eth0 in this case), even if request came from different interface (eth1).
On RHEL / CentOS guest, create ip rules with IP route table and configure it for both interfaces:
echo 200 reth0 >> /etc/iproute2/rt_tables
echo 201 reth1 >> /etc/iproute2/rt_tables
ip rule add from <IP ADDR of eth0> table reth0
ip rule add from <IP ADDR of eth1> table reth1
ip route add default via <IP ADDR of DEFAULT GATEWAY of eth0> dev eth0 table reth0
ip route add default via <IP ADDR of DEFAULT GATEWAY of eth1> dev eth1 table reth1
Traffic will then be shaped on requests to eth0, but not eth1.
Regards, Mike