📜 ⬆️ ⬇️

Linux networking interface

It so happened that he wrote an article for howtoforge. And of course, all this was immediately in the Russian version on other sites. But that's bad luck: there were inaccuracies in the article, and publicists from other “sites” inserted as-is.
I want to try to fix this mistake.
What is it for?
Let me explain with an example: I had a FTP with 2 network cards, but only one was used. Over time, the entire 1GB / s began to get clogged up in the evenings - and people are bad, and my iowait is growing. But there is a second network card. So such a union will allow to use 2 (3, 4, 5 ...) as one with 2 Gb / s.
But this is not a “ceiling”; here is the full list of modes:
mode = 0 (balance-rr)
Sequentially throws packets, from first to last interface.
mode = 1 (active-backup)
One of the interfaces is active. If the active interface fails (link down, etc.), another interface replaces the active one. Does not require additional configuration of the switch
mode = 2 (balance-xor)
Transmissions are distributed between interfaces based on the formula ((source MAC address) XOR (destination MAC address))% number of interfaces. The same interface works with a specific recipient. The mode provides load balancing and fault tolerance.
mode = 3 (broadcast)
All packages for all interfaces
mode = 4 (802.3ad)
Link Agregation - IEEE 802.3ad, requires configuration from the switch.
mode = 5 (balance-tlb)
Incoming packets are accepted only by the active network interface, and outgoing packets are distributed depending on the current load of each interface. Does not require a switch configuration.
mode = 6 (balance-alb)
The same as 5, only incoming traffic is also distributed between the interfaces. Does not require switch configuration, but interfaces must be able to change the MAC.
Customization
Very simple. You choose a mode, you plug a second cable into the switch.
Further depending on the system, I did it on Debian Lenny
#apt-get install ifenslave-2.6
Then there are 2 options:
Option number 1 Correct / etc / network / interfaces for example like this.
iface bond0 inet static
address 10.0.1.5
netmask 255.255.255.0
network 10.0.1.0
gateway 10.0.1.254
up /sbin/ifenslave bond0 eth0 eth1
down /sbin/ifenslave -d bond0 eth0 eth1

and tweak /etc/modprobe.d/arch/i386 like so
alias bond0 bonding
options bonding mode=5 miimon=100 downdelay=200 updelay=200

Naturally specify your mode and network settings.
# update-modules
# ifdown eth0 eth1
# ifup bond0
# /etc/init.d/networking restart

Option number 2 All settings via / etc / network / interfaces
iface bond0 inet static
address 10.0.1.5
netmask 255.255.255.0
network 10.0.1.0
gateway 10.0.1.254
bond_mode balance-tlb
bond_miimon 100
bond_downdelay 200
bond_updelay 200
slaves eth0 eth1

Save and write:
update-modules
# ifdown eth0 eth1
# ifup bond0
# /etc/init.d/networking restart

After that should appear one interface bond0. Then you can produce interfaces bon0: 0, etc.
UPD: Transferred from your blog to the desired
UPD 2: Thanks infotim , for the edits.

')

Source: https://habr.com/ru/post/58218/


All Articles