etherne-wirelessJá pensou em configurar uma redundância entre uma interface ethernet (eth0) e uma wireless (wlan0)? Aqui você aprenderá como.

Usei o CentOS 5.6 como sistema operacional, mas o procedimento funciona em toda a família CentOS.

Primeiro devemos baixar o módulo wireless para o sistema:

<br /> wget http://elrepo.org/linux/elrepo/el5/i386/RPMS/iwl5000-firmware-8.24.2.12-1.elrepo.noarch.rpm<br />

E instalar

<br /> rpm -Uvh iwl5000-firmware-8.24.2.12-1.elrepo.noarch.rpm<br />

Agora vamos configurar a interface bond0

<br /> [root@zimbaro10 ~]# cd /etc/sysconfig/network-scripts/<br /> [root@zimbaro10 network-scripts]# cat ifcfg-bond0<br /> DEVICE=bond0<br /> #IPADDR=192.168.0.10<br /> #NETWORK=192.168.0.0<br /> #NETMASK=255.255.255.0<br /> USERCTL=no<br /> BOOTPROTO=none<br /> ONBOOT=yes<br /> BOOTPROTO=dhcp<br />

Aqui configuraremos a interface ethernet

<br /> [root@zimbaro10 network-scripts]# cat ifcfg-eth0<br /> # Realtek Semiconductor Co., Ltd. RTL8111/8168B PCI Express Gigabit Ethernet controller<br /> DEVICE=eth0<br /> USERCTL=no<br /> ONBOOT=yes<br /> MASTER=bond0<br /> SLAVE=yes<br /> BOOTPROTO=none<br />

E a interface wireless

<br /> [root@zimbaro10 network-scripts]# cat ifcfg-wlan0<br /> # Realtek Semiconductor Co., Ltd. RTL8111/8168B PCI Express Gigabit Ethernet controller<br /> DEVICE=wlan0<br /> USERCTL=no<br /> ONBOOT=yes<br /> MASTER=bond0<br /> SLAVE=yes<br /> #BOOTPROTO=dhcp<br /> TYPE=WIRELESS<br /> WLAN_ESSID[4]="Zimbaronet2"<br /> WLAN_WPA[4]="wpa_supplicant"<br /> WLAN_WPADRIVER[4]="wext"<br />

Agora devemos criar um script para inicialização do módulo

<br /> [root@zimbaro10 network-scripts]# cat /root/scripts/run_wpa.sh<br /> #!/bin/bash

<br /> wpa_supplicant -Dwext -iwlan0 -c/etc/wpa_supplicant.conf &

exit 0

E iniciarmos no boot inserindo o comando no rc.local

<br /> [root@zimbaro10 network-scripts]# cat /etc/rc.local<br /> #!/bin/sh<br /> #<br /> # This script will be executed *after* all the other init scripts.<br /> # You can put your own initialization stuff in here if you don't<br /> # want to do the full Sys V style init stuff.

<br /> touch /var/lock/subsys/local

chown szimbaro:gammu /dev/ttyACM0

sh /root/scripts/run_wpa.sh

Agora vamos as configurações do bonding. Altere o parâmetro mode de acordo com a sua preferência (veja aqui as opções).

<br /> [root@zimbaro10 network-scripts]# cat /etc/modprobe.d/bonding.conf<br /> alias bond0 bonding<br /> options bond0 mode=0 miimon=100 updelay=200 downdelay=200<br />

E inicialização do módulo

<br /> [root@zimbaro10 network-scripts]# modprobe bonding<br />

Aqui temos a configuração do wpa_supplicant para o módulo wireless.

<br /> [root@zimbaro10 network-scripts]# cat /etc/wpa_supplicant.conf<br /> ctrl_interface=/var/run/wpa_supplicant<br /> #ap_scan=2

<br /> network={<br /> ssid="Zimbaronet2"<br /> scan_ssid=1<br /> proto=WPA RSN<br /> key_mgmt=WPA-PSK<br /> pairwise=CCMP TKIP<br /> group=CCMP TKIP<br /> psk=57684e9c880c915c065c4653f2bb8d5cb2e59d0ccab1319a45e9f9e73ab5a763<br /> }<br />

O código psk acim foi gerado com base no SSID e senha da sua rede wireless

<br /> [root@zimbaro10 network-scripts]# wpa_passphrase Zimbaronet2 senharedewifi<br />

Agora podemos reiniciar o sistema. As configurações de interface devem ficar assim:

<br /> [root@zimbaro10 network-scripts]# ifconfig<br /> bond0 Link encap:Ethernet HWaddr 00:22:64:4D:22:CA<br /> inet addr:192.168.0.10 Bcast:192.168.0.255 Mask:255.255.255.0<br /> inet6 addr: fe80::222:64ff:fe4d:22ca/64 Scope:Link<br /> UP BROADCAST RUNNING MASTER MULTICAST MTU:1500 Metric:1<br /> RX packets:3283 errors:0 dropped:0 overruns:0 frame:0<br /> TX packets:2118 errors:0 dropped:0 overruns:0 carrier:0<br /> collisions:0 txqueuelen:0<br /> RX bytes:351568 (343.3 KiB) TX bytes:383828 (374.8 KiB)

<br /> eth0 Link encap:Ethernet HWaddr 00:22:64:4D:22:CA<br /> UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1<br /> RX packets:1026 errors:0 dropped:0 overruns:0 frame:0<br /> TX packets:1066 errors:0 dropped:0 overruns:0 carrier:0<br /> collisions:0 txqueuelen:1000<br /> RX bytes:99420 (97.0 KiB) TX bytes:175135 (171.0 KiB)<br /> Interrupt:177 Base address:0xa000

<br /> lo Link encap:Local Loopback<br /> inet addr:127.0.0.1 Mask:255.0.0.0<br /> inet6 addr: ::1/128 Scope:Host<br /> UP LOOPBACK RUNNING MTU:16436 Metric:1<br /> RX packets:113 errors:0 dropped:0 overruns:0 frame:0<br /> TX packets:113 errors:0 dropped:0 overruns:0 carrier:0<br /> collisions:0 txqueuelen:0<br /> RX bytes:23981 (23.4 KiB) TX bytes:23981 (23.4 KiB)<br />

<br /> wlan0 Link encap:Ethernet HWaddr 00:22:64:4D:22:CA<br /> UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1<br /> RX packets:2257 errors:0 dropped:0 overruns:0 frame:0<br /> TX packets:1054 errors:0 dropped:0 overruns:0 carrier:0<br /> collisions:0 txqueuelen:1000<br /> RX bytes:252148 (246.2 KiB) TX bytes:209769 (204.8 KiB)<br /> [root@zimbaro10 network-scripts]#<br />

É isso!