Dienstag, 6. Dezember 2016

Bonding mit Ubuntu 14.04 LTS

auto eth0
allow-bond0 eth0
iface eth0 inet manual
bond-master bond0

auto eth1
allow-bond0 eth1
iface eth1 inet manual
bond-master bond0

auto bond0
iface bond0 inet static
        address 192.0.2.2
        netmask 255.255.255.0
        bond-mode active-backup
        bond-primary eth0 eth1
        bond-slaves eth0 eth1
        bond-downdelay 200
        bond-updelay 200
        bond-miimon 100
        pre-up (sleep 5 && ifup eth0) &
        pre-up (sleep 5 && ifup eth1) &

Dienstag, 24. März 2015

Ethernet Bonding LACP/802.3ad Konfiguration mit Debian 8 "Jessie"


Änderungen im Bonding ab Debian 8 "Jessie":

  • das Paket "ifenslave" ist zu installieren
  • das Paket "ifenslave-2.6" wird nicht mehr benötigt, ist nur noch ein Übergangspaket für den Wechsel zu ifenslave.
  • /sbin/ifenslave ist ein Shell-Script, welches bonding über Dateien in /sys/class/net/$master/bonding/ konfiguriert

Nicht erst seit "Jessie":

  • "alias netdev-bond0 bonding" ist nicht mehr notwending
  • sämtliche Parameter für das Bonding können in /etc/network/interfaces eingetragen werden

LACP/802.3ad

So wird eine Konfiguration des Bondings im Modus LACP/802.3ad auf dem Server ganz einfach und übersichtlich:

1. Paket ifenslave installieren

2. Aus /etc/network/interfaces sind alle Definitionen für eth0 und eth1 zu entfernen und folgender Block ist einzufügen:

auto bond0
iface bond0 inet static
        address 192.0.2.2
        netmask 255.255.255.0
        gateway 192.0.2.1
        bond-slaves eth0 eth1
        bond-mode 802.3ad
        bond-miimon 100

IP-Adressen sind natürlich anzupassen und ich habe den Modus 802.3ad (LACP) gewählt. Evtl. wollt ihr auch "bond-mode active-backup", mit dem fault tolerance realisiert wird. Dann ist die Option "primary" zu beachten.

Setup für Modus Active-Backup in /etc/network/interfaces
auto bond0
iface bond0 inet static
        address 192.0.2.2
        netmask 255.255.255.0
        #gateway 192.0.2.1
        bond-slaves eth0 eth1
        bond-mode active-backup
        bond-miimon 100
        bond-primary eth0 eth1


3. Aktivierung

ifconfig eth0 down; ifconfig eth1 down; ifup bond0

und Bonding (LACP) läuft.

4. Status-Abfrage für bond0:

cat /proc/net/bonding/bond0

Referenzen:

Samstag, 13. April 2013

"curiosity killed the cat"

Hier eine Liste von Software-Projekten und Links, die mich neugierig machen::

Freitag, 18. September 2009

Freitag, 4. September 2009

moreutils

Das Debian-Paket "moreutils" habe ich zufällig entdeckt. Aus der Paketbeschreibung:

Dies ist eine wachsende Sammlung von Unix Werkzeugen, an deren Erstellung vor 30 Jahren noch niemand dachte.

Bis jetzt, enthält es folgende Funktionen:
- sponge: saugt die Standardeingabe auf und schreibt sie in eine Datei
- ifdata: holt Informationen zu Netzwerkschnittstellen ohne die
Ausgabe von ifconfig analysieren zu müssen
- ifne: startet ein Programm, wenn die Standardeingabe nicht leer ist
- vidir: editiert ein Verzeichnis in Ihrem Texteditor
- vipe: Einfügen eines Texteditors in eine Pipe
- ts: versieht die Standardeingabe mit einer Zeitmarkierung
- combine: kombiniert die Zeilen aus zwei Dateien mit booleschen
Operationen
- pee: verzweigt die Standardeingabe in Pipes
- zrun: entpackt die Argumente automatisch als Befehle
- mispipe: führt zwei Befehle in einer Pipe aus und gibt den Exit-Status
des ersten Befehls zurück
- isutf8: prüft, ob eine Datei oder die Standardeingabe utf-8 Format hat
- lckdo: führt ein Programm mit gehaltenem lock aus


sponge, vipe, pee hätte ich schon so manches Mal gebrauchen können!

Freitag, 14. November 2008

Ethernet Bonding mit Debian 4.0 "Etch"

Ich nutze Debian 4.0 "Etch" mit Kernel 2.6.18-6-686 auf einer schon etwas betagten Maxdata-Maschine. Da sich zwei 100MBit-Netzwerkkarten onboard befinden (e100) und wir auch mehrere Switches haben, war es an der Zeit das Bonding auszuprobieren, um die Ausfallsicherheit zu erhöhen.

Ein sehr gründliche und gut dokumentierte Überblick gibt die Datei
/usr/src/linux-source-2.6.18/Documentation/networking/bonding.txt
aus dem bz2-Archiv mit den Kernelsourcen (linux-source-2.6.18), aber für den Einstieg reichte ein Blick ins Debian-Wiki : http://wiki.debian.org/Bonding

Ich habe folgende Variante des Bondings realisiert bzw. folgende Parameter gesetzt:
  • bonding mode=active-backup"fault-tolerance (active-backup or 1) Active-backup policy: Only one slave in the bond is active. A different slave becomes active if, and only if, the active slave fails. The bond's MAC address is externally visible on only one port (network adapter) to avoid confusing the switch."Damit bekomme ich genau das, was ich wollte: Ausfallsicherheit
  • miimon=100"Specifies the MII link monitoring frequency in milliseconds. This determines how often the link state of each slave is inspected for link failures. A value of zero disables MII link monitoring. A value of 100 is a good starting point."
  • downdelay=200"Specifies the time, in milliseconds, to wait before disabling a slave after a link failure has been detected. This option is only valid for the miimon link monitor. The downdelay value should be a multiple of the miimon value; if not, it will be rounded down to the nearest multiple. The default value is 0."
  • updelay=200"Specifies the time, in milliseconds, to wait before enabling a slave after a link recovery has been detected. This option is only valid for the miimon link monitor. The updelay value should be a multiple of the miimon value; if not, it will be rounded down to the nearest multiple. The default value is 0."
  • primary=eth0
    "A string (eth0, eth2, etc) specifying which slave is the primary device. The specified device will always be the active slave while it is available. Only when the primary is off-line will alternate devices be used. This is useful when one slave is preferred over another, e.g., when one slave has higher throughput than another. The primary option is only valid for active-backup mode."

Damit wird diese Konfiguration gespeichert:

echo "alias bond0 bonding" > /etc/modprobe.d/bonding
echo "options bonding mode=active-backup miimon=100 downdelay=200 \
updelay=200 primary=eth0" >> /etc/modprobe.d/bonding

Update für Debian 6.0 "Squeeze":
(Dateinamen in /etc/modprobe.d/ müssen auf .conf enden)

echo "alias bond0 bonding" > /etc/modprobe.d/bonding.conf
echo "options bonding mode=active-backup miimon=100 downdelay=200 \
updelay=200 primary=eth0" >> /etc/modprobe.d/bonding.conf

Update für Debian 7.0 "Wheezy":
(bond0 wird zu netdev-bond0)

echo "alias netdev-bond0 bonding" > /etc/modprobe.d/bonding.conf
echo "options bonding mode=active-backup miimon=100 downdelay=200 \
updelay=200 primary=eth0" >> /etc/modprobe.d/bonding.conf

eth0 und eth1 wurden an Ports verschiedener Switches angeschlossen. Diese Ports befinden sich (natürlich) im selben VLAN.

Das Paket ifenslave (ifenslave-2.6) wurde installiert:

aptitude install ifenslave

Der Abschnitt für bond0 in /etc/network/interfaces sieht jetzt so aus:

auto bond0
iface bond0 inet static
address 10.49.1.222
netmask 255.255.0.0
network 10.49.0.0
broadcast 10.49.255.255
gateway 10.49.1.10
up /sbin/ifenslave bond0 eth0 eth1
down /sbin/ifenslave -d bond0 eth0 eth1

Mit den Kommandos

ifconfig eth0 down; ifup bond0

habe ich ich (über ssh im laufenden Betrieb!) die neue Netzwerkkonfiguration aktiviert.

Der aktuelle Status des Devices 'bond0' steht in /proc/net/bonding/bond0

cat /proc/net/bonding/bond0

Ethernet Channel Bonding Driver: v3.0.3 (March 23, 2006)

Bonding Mode: fault-tolerance (active-backup)
Primary Slave: eth0
Currently Active Slave: eth0
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 200
Down Delay (ms): 200

Slave Interface: eth0
MII Status: up
Link Failure Count: 2
Permanent HW addr: 00:03:47:bd:64:ee

Slave Interface: eth1
MII Status: up
Link Failure Count: 0
Permanent HW addr: 00:03:47:bd:64:ef

Bisherige Erfahrungen:
  1. Die Umschaltung auf das andere Slave-Interface eth1 klappt bei "link down" auf eth0. Im syslog sieht das so aus:

    e100: eth0: e100_watchdog: link down
    bonding: bond0: link status down for idle interface eth0, disabling it in 200 ms.
    bonding: bond0: link status definitely down for interface eth0, disabling it
    bonding: bond0: making interface eth1 the new active one.
  2. Sobald auf dem primären Slave-Interface eth0 der Link wieder da ist, wird nach kurzer Wartezeit (updelay=200) wieder zurückgeschaltet (primary=eth0). Im syslog sieht das so aus:

    e100: eth0: e100_watchdog: link up, 100Mbps, full-duplex
    bonding: bond0: link status up for interface eth0, enabling it in 200 ms.
    bonding: bond0: link status definitely up for interface eth0.
    bonding: bond0: making interface eth0 the new active one.

    Das Bonding im Modus 'active-backup' mit dem Parameter 'primary=' ist also revertiv.
  3. Nach der Umschaltung auf das sekundäre Slave-Interface eth1 ist das Interface bond0 weiterhin mit der MAC-Adresse von eth0 aktiv, so dass auch die Einträge in den ARP-Caches anderer Hosts nicht ungültig werden. Lediglich muss der andere Switch die für ihn neue MAC-Adresse am Port von eth1 lernen, was aber durch ein "Gratuitous ARP" unterstützt wird.
    Die MAC-Adresse von eth1 wird nie benutzt.