Linux – Configuración bonding en Debian

por | 8 noviembre, 2011

El channel bonding o unión de interfaces de red consiste en simular un dispositivo de red con gran ancho de banda uniendo varias tarjetas de red independientes, de manera que las aplicaciones sólo verán un interfaz de red. Con el channel bonding conseguimos varias cosas:

  • Aumento del ancho de banda: el ancho de banda de la interfaz virtual será la suma de los anchos de banda de las interfaces reales.
  • Balanceo de carga: tendremos balanceo de carga del tráfico de red entre todas las interfaces reales (por defecto Round Robin).
  • Redundancia: si falla una tarjeta de red los datos irán sólo por las que estén en buen estado.

En Linux se encarga del channel bonding el módulo Linux Channel Bonding. Veamos cómo activarlo en un equipo con dos interfaces de red (eth0 y eth1):

Resumen:
– Cargar el módulo de bonding
– Instalar el paquete ifenslave (interfaz virtual)
– Configurar los interfaces.
1. instalación de ifenslave (interface enslave, paquete ifenslave):

# apt-get install ifenslave

2. Carga del módulo de bonding en el kernel

# modprobe bonding miimon=100

(El parámetro miimon=100 significa que monitoriza cada 100 ms si las tarjetas reales funcionan)

3. Editar /etc/network/interfaces

Editar /etc/network/interfaces y configuramos la interfaz virtual bond0 (con la directiva slaves definimos las tarjetas de red reales que forman bond0):

auto bond0
iface bond0 inet static
      address 192.168.0.100
      netmask 255.255.255.0
      broadcast 192.168.0.255
      gateway 192.168.0.1
      slaves eth0 eth1

Para que al arrancar sólo se active bond0 eliminaremos las líneas auto eth0 y auto eth1.

4.  Levantar el interfaz virtual

# ifup bond0

5. Comprobar si todo está correcto (las tres interfaces deben tener la misma MAC):

$ ifconfig
bond0     Link encap:Ethernet  HWaddr 00:00:DE:50:D5:34
          inet addr:192.168.3.13  Bcast:192.168.3.255  Mask:255.255.255.0
          inet6 addr: fe80::200:deff:fe50:d534/64 Scope:Link
          UP BROADCAST RUNNING MASTER MULTICAST  MTU:1500  Metric:1
          RX packets:72442 errors:0 dropped:0 overruns:0 frame:0
          TX packets:22419 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:70488186 (67.2 MiB)  TX bytes:3149570 (3.0 MiB)

eth0      Link encap:Ethernet  HWaddr 00:00:DE:50:D5:34
          inet6 addr: fe80::200:deff:fe50:d534/64 Scope:Link
          UP BROADCAST RUNNING SLAVE MULTICAST  MTU:1500  Metric:1
          RX packets:68687 errors:0 dropped:0 overruns:0 frame:0
          TX packets:22413 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:70242832 (66.9 MiB)  TX bytes:3149078 (3.0 MiB)
          Base address:0x2020 Memory:c0160000-c0180000

eth1      Link encap:Ethernet  HWaddr 00:00:DE:50:D5:34
          inet6 addr: fe80::200:deff:fe50:d534/64 Scope:Link
          UP BROADCAST RUNNING SLAVE MULTICAST  MTU:1500  Metric:1
          RX packets:3755 errors:0 dropped:0 overruns:0 frame:0
          TX packets:6 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:245354 (239.6 KiB)  TX bytes:492 (492.0 b)
          Base address:0x2000 Memory:c0120000-c0140000

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:274 errors:0 dropped:0 overruns:0 frame:0
          TX packets:274 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:27664 (27.0 KiB)  TX bytes:27664 (27.0 KiB)
$
5.  Verificar el funcionamiento del bonding

[root@localhost]$ 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): 0
Down Delay (ms): 0

Slave Interface: eth0
MII Status: up
Link Failure Count: 0
Permanent HW addr: 00:00:de:50:d5:34

Slave Interface: eth1
MII Status: up
Link Failure Count: 0
Permanent HW addr: 00:00:de:50:d5:35
[root@localhost]$
Para ver los parámetros configurados en el interfaz bond0:

$ ls /proc/sys/net/ipv4/conf/bond0 -l
total 0
-rw-r–r– 1 root root 0 Jul  7 09:24 accept_redirects
-rw-r–r– 1 root root 0 Jul  7 09:24 accept_source_route
-rw-r–r– 1 root root 0 Jul  7 09:24 arp_accept
-rw-r–r– 1 root root 0 Jul  7 09:24 arp_announce
-rw-r–r– 1 root root 0 Jul  7 09:24 arp_filter
-rw-r–r– 1 root root 0 Jul  7 09:24 arp_ignore
-rw-r–r– 1 root root 0 Jul  7 09:24 bootp_relay
-rw-r–r– 1 root root 0 Jul  7 09:24 disable_policy
-rw-r–r– 1 root root 0 Jul  7 09:24 disable_xfrm
-rw-r–r– 1 root root 0 Jul  7 09:24 force_igmp_version
-rw-r–r– 1 root root 0 Jul  7 09:24 forwarding
-rw-r–r– 1 root root 0 Jul  7 09:24 log_martians
-r–r–r– 1 root root 0 Jul  7 09:24 mc_forwarding
-rw-r–r– 1 root root 0 Jul  7 09:24 medium_id
-rw-r–r– 1 root root 0 Jul  7 09:24 promote_secondaries
-rw-r–r– 1 root root 0 Jul  7 09:24 proxy_arp
-rw-r–r– 1 root root 0 Jul  7 09:24 rp_filter
-rw-r–r– 1 root root 0 Jul  7 09:24 secure_redirects
-rw-r–r– 1 root root 0 Jul  7 09:24 send_redirects
-rw-r–r– 1 root root 0 Jul  7 09:24 shared_media
-rw-r–r– 1 root root 0 Jul  7 09:24 tag
$
$ ls  /proc/sys/net/ipv4/neigh/bond0/ -l
total 0
-rw-r–r– 1 root root 0 Jul  7 09:27 anycast_delay
-rw-r–r– 1 root root 0 Jul  7 09:27 app_solicit
-rw-r–r– 1 root root 0 Jul  7 09:27 base_reachable_time
-rw-r–r– 1 root root 0 Jul  7 09:27 base_reachable_time_ms
-rw-r–r– 1 root root 0 Jul  7 09:27 delay_first_probe_time
-rw-r–r– 1 root root 0 Jul  7 09:27 gc_stale_time
-rw-r–r– 1 root root 0 Jul  7 09:27 locktime
-rw-r–r– 1 root root 0 Jul  7 09:27 mcast_solicit
-rw-r–r– 1 root root 0 Jul  7 09:27 proxy_delay
-rw-r–r– 1 root root 0 Jul  7 09:27 proxy_qlen
-rw-r–r– 1 root root 0 Jul  7 09:27 retrans_time
-rw-r–r– 1 root root 0 Jul  7 09:27 retrans_time_ms
-rw-r–r– 1 root root 0 Jul  7 09:27 ucast_solicit
-rw-r–r– 1 root root 0 Jul  7 09:27 unres_qlen
$

(Parte de este artículo está basado en http://www.estrellateyarde.es/so/channel-bonding-en-linux)

Deja un comentario

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *