Convertir una debian en un punto de acceso wifi

Ayer hice un post sobre como instalar debian en una placa Alix 2d2 por puerto COM, ahora vamos a convertir esta preciosidad en un punto de acceso wifi :)

Como disponemos de dos tarjetas wifi de fabricantes que respetan el software libre y liberan sus drivers, no será necesario instalar el paquete firmware-iwlwifi o firmware-linux-nonfree, así que un pasito mas para un punto de acceso totalmente libre! :D

root@alix2d2:/home/blackhold# lspci |grep Atheros
00:0c.0 Ethernet controller: Atheros Communications Inc. AR5413 802.11abg NIC (rev 01)
00:0e.0 Ethernet controller: Atheros Communications Inc. AR5413 802.11abg NIC (rev 01)

Si nos fijamos, las dos tarjetas minipci ya aparecen en el sistema sin tener que instalar nada adicional :)

root@alix2d2:/home/blackhold# ifconfig -a
eth0      Link encap:Ethernet  HWaddr 00:0d:b9:1f:fc:28  
          inet addr:192.168.1.104  Bcast:192.168.1.255  Mask:255.255.255.0
          BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:634 errors:0 dropped:0 overruns:0 frame:0
          TX packets:278 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:56911 (55.5 KiB)  TX bytes:37568 (36.6 KiB)
          Interrupt:10 Base address:0x1000 

eth1      Link encap:Ethernet  HWaddr 00:0d:b9:1f:fc:29  
          inet addr:192.168.1.52  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::20d:b9ff:fe1f:fc29/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1970 errors:0 dropped:0 overruns:0 frame:0
          TX packets:654 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:1616997 (1.5 MiB)  TX bytes:77305 (75.4 KiB)
          Interrupt:15 Base address:0x1400 

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:8 errors:0 dropped:0 overruns:0 frame:0
          TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:560 (560.0 B)  TX bytes:560 (560.0 B)

wlan0     Link encap:Ethernet  HWaddr 00:0b:6b:22:d2:83  
          BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

wlan1     Link encap:Ethernet  HWaddr 00:80:48:6b:f6:57  
          BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

Como hemos instalado una debian pelada, tendremos que instalar wireless-tools para poder usar iwconfig & co y luego hostapd que es el paquete que convierte nuestro sistema en un punto de acceso wifi

root@alix2d2:/home/blackhold# apt-get install hostapd wireless-tools

Ahora vamos a indicarle a hostapd donde se encuentra el fichero de configuración, para ello editaremos /etc/default/hostapd

# Defaults for hostapd initscript
#
# See /usr/share/doc/hostapd/README.Debian for information about alternative
# methods of managing hostapd.
#
# Uncomment and set DAEMON_CONF to the absolute path of a hostapd configuration
# file and hostapd will be started during system boot. An example configuration
# file can be found at /usr/share/doc/hostapd/examples/hostapd.conf.gz
#
#DAEMON_CONF=""

DAEMON_CONF="/etc/hostapd/hostapd.conf"

# Additional daemon options to be appended to hostapd command:-
#       -d   show more debug messages (-dd for even more)
#       -K   include key data in debug messages
#       -t   include timestamps in some debug messages
#
# Note that -B (daemon mode) and -P (pidfile) options are automatically
# configured by the init.d script and must not be added to DAEMON_OPTS.
#
#DAEMON_OPTS=""

Ahora creamos el fichero /etc/hostapd/hostapd.conf con éste contenido:

interface=wlan0
bridge=br0
driver=nl80211
auth_algs=1
ignore_broadcast_ssid=0
logger_syslog=-1
logger_syslog_level=0
hw_mode=g
ssid=blackhold_wifi_test
channel=11
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=MiClave1234
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP

Aquí estamos creando una red wifi en wlan0 que se llame blackhold_wifi_test a 2,4Ghz con clave WPA-PSK+TKIP con password MiClave1234

En esta prueba lo que vamos a hacer va a ser montar un punto de acceso wifi que funcione como un bridge, lo que coja de la red de por cable la va a pasar por la red wifi que acabamos de crear. Una vez tengamos esto ya podremos complicarlo tanto como queramos ;)

Editamos pues /etc/network/interfaces y lo dejamos así

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
allow-hotplug eth0
iface eth0 inet dhcp

# INTERNET
auto eth1
allow-hotplug eth1
iface eth1 inet dhcp


# WiFi Access Point
auto br0
iface br0 inet dhcp
bridge-ports eth1 wlan0

Debian pelada, no hay muchos paquetes, uno de ellos los bridge-utils, que no está de mas instalarlas si las queremos usar ;)

root@alix2d2:/etc/network# apt-get install bridge-utils

Y reiniciamos el servicio de red y hostapd

root@alix2d2:~# service networking stop
root@alix2d2:~# service networking start
root@alix2d2:~# service hostapd restart

Y la cosa queda así

root@alix2d2:/home/blackhold# ifconfig
br0       Link encap:Ethernet  HWaddr 00:0b:6b:22:d2:83  
          inet addr:192.168.1.51  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::20b:6bff:fe22:d283/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:258 errors:0 dropped:0 overruns:0 frame:0
          TX packets:62 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:39697 (38.7 KiB)  TX bytes:8828 (8.6 KiB)

eth1      Link encap:Ethernet  HWaddr 00:0d:b9:1f:fc:29  
          inet6 addr: fe80::20d:b9ff:fe1f:fc29/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:9092 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1754 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:9187845 (8.7 MiB)  TX bytes:247347 (241.5 KiB)
          Interrupt:15 Base address:0x1400 

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:8 errors:0 dropped:0 overruns:0 frame:0
          TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:560 (560.0 B)  TX bytes:560 (560.0 B)

mon.wlan0 Link encap:UNSPEC  HWaddr 00-0B-6B-22-D2-83-65-74-00-00-00-00-00-00-00-00  
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:15 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:1674 (1.6 KiB)  TX bytes:0 (0.0 B)

wlan0     Link encap:Ethernet  HWaddr 00:0b:6b:22:d2:83  
          inet6 addr: fe80::20b:6bff:fe22:d283/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:108 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:20602 (20.1 KiB)
root@alix2d2:/home/blackhold# iwconfig
lo        no wireless extensions.

eth0      no wireless extensions.

eth1      no wireless extensions.

wlan0     IEEE 802.11abg  Mode:Master  Frequency:2.462 GHz  Tx-Power=20 dBm   
          Retry  long limit:7   RTS thr:off   Fragment thr:off
          Power Management:off
          
wlan1     IEEE 802.11abg  ESSID:off/any  
          Mode:Managed  Access Point: Not-Associated   Tx-Power=0 dBm   
          Retry  long limit:7   RTS thr:off   Fragment thr:off
          Encryption key:off
          Power Management:off
          
br0       no wireless extensions.

mon.wlan0  IEEE 802.11abg  Mode:Monitor  Frequency:2.462 GHz  Tx-Power=20 dBm   
          Retry  long limit:7   RTS thr:off   Fragment thr:off
          Power Management:off

Y en mi equipo puedo ver la wifi creada por la placa Alix

root@carboni:/home/laura# iwlist wlan0 scanning
[...]
          Cell 12 - Address: 00:0B:6B:22:D2:83
                    Channel:11
                    Frequency:2.462 GHz (Channel 11)
                    Quality=58/70  Signal level=-52 dBm  
                    Encryption key:on
                    ESSID:"blackhold_wifi_test"
                    Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 6 Mb/s
                              9 Mb/s; 12 Mb/s; 18 Mb/s
                    Bit Rates:24 Mb/s; 36 Mb/s; 48 Mb/s; 54 Mb/s
                    Mode:Master
                    Extra:tsf=0000000075fc585a
                    Extra: Last beacon: 72ms ago
                    IE: Unknown: 0013626C61636B686F6C645F776966695F74657374
                    IE: Unknown: 010882848B960C121824
                    IE: Unknown: 03010B
                    IE: Unknown: 2A0100
                    IE: Unknown: 32043048606C
                    IE: IEEE 802.11i/WPA2 Version 1
                        Group Cipher : CCMP
                        Pairwise Ciphers (1) : CCMP
                        Authentication Suites (1) : PSK
[...]

Para configuraciones mas avanzadas recomiendo pegarle una ojeadilla a éste fichero.

6 Comments

  1. Saudações!. Estive lendo seu blog por muito tempo e agora, finalmente, criei coragem para
    ir em frente e dar meu start no meu negócio . Só queria dizer muito obrigado por ter escrito
    este material.

    Respon

Respon a sisco_garcia Cancel·la les respostes

L'adreça electrònica no es publicarà. Els camps necessaris estan marcats amb *

Aquest lloc utilitza Akismet per reduir els comentaris brossa. Apreneu com es processen les dades dels comentaris.