Vamos a configurar las tarjetas de red de un servidor linux Centos con múltiples vlans sobre la misma interfaz lógica y alta disponibilidad de red.
Además añadiremos un balanceo del tráfico de las interfaces físicas para equilibrarlo ( ambas activas ) y aumentar el ancho de banda disponible. Resumiendo, un bonding con trunk 802.1Q y balanceo lacp ( modo 4 del bonding ).
El modo 4 del bonding necesita configuración adicional sobre el switch y la veremos en el próximo post, esto es un port-channel o un lacp ( Link Aggregation Control Protocol ). Su funcionamiento se basa en 802.3ad. Las interfaces deben tener la misma velocidad y modo dúplex tanto en host como en switch.
Como ejemplo lo situaremos en un firewall y configuraremos el lado inside.
Los servidores están en 3 vlans diferentes ( web, correo y bases de datos ).
El firewall dispone de dos tarjetas de red físicas ( eth0 y eth1 ) que tienen el bonding ( interfaz lógico bond0 ) en modo 4, para balancear el tráfico y finalmente subimos las 3 vlans en un trunk.
Los puertos del switch que forman el trunk y el port-channel en lacp son las GigabitEthernet 1/0/1 y GigabitEthernet 2/0/1
Configuración de las interfaces físicas del firewall linux:
[root@firewall-linux ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0 DEVICE=eth0 ONBOOT=yes TYPE=ethernet SLAVE=yes MASTER=bond0 [root@firewall-linux ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth1 DEVICE=eth1 ONBOOT=yes TYPE=ethernet SLAVE=yes MASTER=bond0
Configuración de la interfaz lógica ( bond ):
[root@firewall-linux ~]# cat /etc/sysconfig/network-scripts/ifcfg-bond0 DEVICE=bond0 ONBOOT=yes
Configuración de las interfaces vlan con direccionamiento :
[root@firewall-linux ~]# cat /etc/sysconfig/network-scripts/ifcfg-vlan10 VLAN=yes VLAN_NAME_TYPE=VLAN_PLUS_VID_NO_PAD DEVICE=vlan10 PHYSDEV=bond0 BOOTPROTO=static ONBOOT=yes TYPE=Ethernet IPADDR=10.0.10.1 NETMASK=255.255.255.0 [root@firewall-linux ~]# cat /etc/sysconfig/network-scripts/ifcfg-vlan11 VLAN=yes VLAN_NAME_TYPE=VLAN_PLUS_VID_NO_PAD DEVICE=vlan11 PHYSDEV=bond0 BOOTPROTO=static ONBOOT=yes TYPE=Ethernet IPADDR=10.0.11.1 NETMASK=255.255.255.0 [root@firewall-linux ~]# cat /etc/sysconfig/network-scripts/ifcfg-vlan12 VLAN=yes VLAN_NAME_TYPE=VLAN_PLUS_VID_NO_PAD DEVICE=vlan12 PHYSDEV=bond0 BOOTPROTO=static ONBOOT=yes TYPE=Ethernet IPADDR=10.0.12.1 NETMASK=255.255.255.0
Configuración de modprobe en Centos 6 ( activamos lacp = modo 4 ):
[root@firewall-linux ~]# cat /etc/modprobe.d/bond0.conf alias bond0 bonding options bond0 miimon=100 mode=4
Finalmente hacemos un service network restart para aplicar los cambios.
Verificación del bonding :
[root@firewall-linux ~]# cat /proc/net/bonding/bond0 Ethernet Channel Bonding Driver: v2.6.3-rh (June 8, 2005) Bonding Mode: IEEE 802.3ad Dynamic link aggregation MII Status: up MII Polling Interval (ms): 100 Up Delay (ms): 0 Down Delay (ms): 0 802.3ad info LACP rate: slow Active Aggregator Info: Aggregator ID: 2 Number of ports: 2 Actor Key: 9 Partner Key: 44 Partner Mac Address: 00:13:1a:88:88:88 Slave Interface: eth0 MII Status: up Link Failure Count: 0 Permanent HW addr: 00:0b:cd:fe:98:98 Aggregator ID: 2 Slave Interface: eth1 MII Status: up Link Failure Count: 0 Permanent HW addr: 00:0b:cd:fe:99:99 Aggregator ID: 2
Verificación de las vlanes :
[root@firewall-linux ~]# cat /proc/net/vlan/config VLAN Dev name | VLAN ID Name-Type: VLAN_NAME_TYPE_PLUS_VID_NO_PAD vlan10 | 10 | bond0 vlan11 | 11 | bond0 vlan12 | 12 | bond0
Verificación de los contadores de las tramas dot1q con el tag de la vlan :
[root@firewall-linux ~]# cat /proc/net/vlan/vlan10 vlan10 VID: 10 REORDER_HDR: 1 dev->priv_flags: 81 total frames received 12567951177 total bytes received 17912768347897 Broadcast/Multicast Rcvd 0 total frames transmitted 6350258383 total bytes transmitted 455437547729 total headroom inc 0 total encap on xmit 0 Device: bond0 INGRESS priority mappings: 0:0 1:0 2:0 3:0 4:0 5:0 6:0 7:0 EGRESSS priority Mappings:
Si deseásemos configurar vlans inmediatamente, sin network restart, podemos introducir la configuración al vuelo sobre la shell linux mediante el comando vconfig :
Añadir una vlan sobre el interfaz bond0 ( en este caso vlan 11 )
[root@firewall-linux ~]# vconfig add bond0 11 Added VLAN with VID == 11 to IF -:bond0:- [root@firewall-linux ~]# ifconfig vlan11 10.0.11.1/24 up
Para borrar una vlan :
[root@firewall-linux ~]# vconfig rem vlan11
Removed VLAN -:vlan11:-
En el próximo post, veremos la configuración a aplicar en el switch.