Bonding balance-xor (mode 2) using only one network interface
I am using Ubuntu 16.04.6 LTS and bonded 2 network interfaces with the following config:
auto eno0
iface eno0 inet manual
bond-master bond0
auto eno1
iface eno1 inet manual
bond-master bond0
auto bond0
iface bond0 inet static
bond-slaves none
bond-miimon 100
bond-mode balance-xor
address [IP]
netmask [IP]
network [IP]
broadcast [IP]
gateway [IP]
# dns-* options are implemented by the resolvconf package, if installed
dns-nameservers 8.8.8.8 8.8.4.4
Network is working, but traffic goes almost exclusively only through one interface:
eno0 eno1 bond0
KB/s in KB/s out KB/s in KB/s out KB/s in KB/s out
3436.42 100942.1 11.59 0.00 3447.97 100929.5
3450.31 98191.30 10.32 0.00 3461.29 98208.12
3426.57 94762.22 9.16 0.00 3436.65 94754.99
3579.97 101313.8 10.66 0.00 3588.80 101302.2
4029.16 97184.86 9.93 0.00 4038.42 97196.67
3225.66 90987.53 13.48 0.00 3239.43 90991.49
When I unplug eno0, traffic moves to eno1. When I plug it back, it goes back to eno0. AFAIK, traffic should be more or less evenly split between the two interfaces since it's generated by thousands of users.
Any ideas what could be wrong?
EDIT:
cat /sys/class/net/bond0/bonding/mode
balance-xor 2
Solution 1:
If both eno0 and eno1 are connected to the same switch, or there is some form of interconnection between the two switches. Then you need to configure static aggregation on the switch.
This is because the switch acts as a Layer 2 device, it will automatically records the mapping between MAC addresses and ports (By default, Each MAC address can only be mapped to one port at a time). But in mode 2, all NICs under bond0 share one same MAC address.
If your switch supports LACP, consider using 802.3ad (mode 4). Otherwise, if there is no switch configuration permission, only mode 1, 5 or 6 can be used.