Different bandwidthctl limits on each network interface

Discussions about using Linux guests in VirtualBox.
Post Reply
mikebo
Posts: 10
Joined: 8. Sep 2008, 21:09

Different bandwidthctl limits on each network interface

Post by mikebo »

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
mikebo
Posts: 10
Joined: 8. Sep 2008, 21:09

Re: Different bandwidthctl limits on each network interface

Post by mikebo »

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
fth0
Volunteer
Posts: 5668
Joined: 14. Feb 2019, 03:06
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Linux, Windows 10, ...
Location: Germany

Re: Different bandwidthctl limits on each network interface

Post by fth0 »

Post Reply