Skip to main content

Comó hacer de la Raspberry Pi B+ un Access Point

¿Tiene problemas con la red Wi-Fi de su router, ya que el mismo  no da una cobertura total a su hogar u oficina? ¿Tienes una Raspberry Pi B+ y quiere expandir su red WI-FI, pero no sabe como hacerlo?¿No tienes muchos conocimientos en redes, pero quieres aprender?.

En este post encontrarás las respuestas de estas preguntas y más, en pasos muy sencillos y simples.

Precondiciones

  1. Tener acceso a internet  por Ethernet (cable).
  2. Adaptador Wireless USB usado: EW-7811Un (se recomienda usar el RTL8192cu Chipset con antena para cubrir una mayor área, lograr una mayor transmisión de los datos y una comunicación más estable).
  3. Hardware usado: Raspberry Pi B+ (debería funcionar para cualquier familia de Raspberry Pi u otro hardware).
  4. Sistema Operativo usado: Raspbian.

Paso #1: Instalar el servidor DHCP

Únicamente se debe ejecutar estos simples comandos en la terminal de la Raspberry Pi:
# Actualizar la RPI
sudo apt-get update
# Instalar el servidor de DHCP 
sudo apt-get install hostapd isc-dhcp-server
# Agregar en interfaces “wlan0” (interface por donde se va a transmitir la señal WI-FI)
sudo vim.tiny /etc/default/isc-dhcp-server
# Configuración del servidor DHCP
sudo vim.tiny /etc/dhcp/dhcpd.conf
Comentar (con el signo #)  las líneas:
#option domain-name "example.org";
#option domain-name-servers ns1.example.org, ns2.example.org;
Descomentar (quitar el signo #) la línea:
authoritative;
Agregar al final del archivo anterior (dhcpd.conf) estas líneas (esto es importante, ya aquí se establece la subred, máscara, los DNS, el rango a usar por el DHCP, entre otras cosas):
subnet 192.168.42.0 netmask 255.255.255.0 {
 range 192.168.42.10 192.168.42.50;
 option broadcast-address 192.168.42.255;
 option routers 192.168.42.1;
 default-lease-time 600;
 max-lease-time 7200;
 option domain-name "local";
 option domain-name-servers 8.8.8.8, 8.8.4.4;
}

Paso #2: Configurar la interface “wlan0″ con una Ip Estática

# Apagar la interface wlan0
sudo ifdown wlan0
sudo vim.tiny /etc/network/interfaces
Se comentan las líneas:
#iface wlan0 inet manual
#wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
#iface default inet dhcp
Y se agrega al final del archivo “interfaces” (se puede escoger una Ip con la respectiva máscara):
iface wlan0 inet static
     address 192.168.42.1
     netmask 255.255.255.0
Ejecutar en terminal:
# Asignar inmediatamente la IP Estática
sudo ifconfig wlan0 192.168.42.1

Paso #3: Configurar el Punto de Acceso

sudo vim.tiny /etc/hostapd/hostapd.conf
Agregar a este archivo lo siguiente (en esta parte se define la interface a transmitir la señal WI-FI, el driver del trasnmisor, en nombre de la red WI-FI, la contraseña de la misma, protocolos de seguridad, entre otras cosas):
interface=wlan0
driver=rtl871xdrv
ssid=RaspberryPI
hw_mode=g
channel=6
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=12345678
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
Definirle a la RPI donde está este archivo de configuración:
sudo vim.tiny /etc/default/hostapd
Agregar al final:
# Buscar DAEMON_CONF y agregar:
DAEMON_CONF="/etc/hostapd/hostapd.conf"

Paso #4: Establecer el NAT (Network Address Translation)

# Descomentar la línea: net.ipv4.ip_forward=1
sudo vim.tiny /etc/sysctl.conf
# Activar el forwarding, permite que usuarios de una red externa 
# acceder a una red privada por medio de una redirección
sudo sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward"

# Ejecutar estos comandos para hacer la TRADUCCIÓN de la red 
# entre el puerto eth0 (Ethernet) y el puerto wlan0 (wifi)
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
sudo iptables -A FORWARD -i eth0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT
sudo iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT

# Para hacer esto automáticamente en el reinicio de la RPI:
sudo sh -c "iptables-save > /etc/iptables.ipv4.nat"
# Ejecutar en terminal 
sudo vim.tiny /etc/network/interfaces
# Añadir al final archivo: up iptables-restore < /etc/iptables.ipv4.nat

Paso #5: Actualizar el hostapd (daemon para el Access Point y el servidor de autentificación)

# Descargar el hostapd 
wget http://adafruit-download.s3.amazonaws.com/adafruit_hostapd_14128.zip
unzip adafruit_hostapd_14128.zip
sudo mv /usr/sbin/hostapd /usr/sbin/hostapd.ORIG
sudo mv hostapd /usr/sbin
sudo chmod 755 /usr/sbin/hostapd

Paso #6: La primera prueba

# Con el siguiente comando, ya la señal WI-FI estaría disponible 
# para conectarse desde un celular o computadora.
sudo /usr/sbin/hostapd /etc/hostapd/hostapd.conf

# Para que se ejecute automáticamente cuando la RPI inicia:
sudo service hostapd start 
sudo service isc-dhcp-server start

# Comprobar los estados:
sudo service hostapd status
sudo service isc-dhcp-server status

# Para que inicie en el arranque:
sudo update-rc.d hostapd enable 
sudo update-rc.d isc-dhcp-server enable
Para ver el funcionamiento del mismo se puede observar el siguiente video (ahí se puede apreciar la conexión de una computadora a la red WI-FI que transmite la RPI, el registro de la misma y el acceso a Internet que obtiene):


Ahora tendrás una mayor cobertura de la señal WI-FI en partes de tu casa u oficina de trabajo, donde antes era muy inestable y lento el acceso a internet.
Agradezco a Ncubo por brindarme el equipo necesario para realizar el post.

Popular posts from this blog

ISTQB - Foundation Level Agile Tester Recap

ISTQB - Foundation Level Agile Tester Recap This is a summary that will help you to approve the Agile Tester certification test. 1 - Agile Software Development 1.1 - The fundamentals of Agile Software Development  The Agile Manifesto has 4 values : - Individuals and interactions over processes and tools (people-centered) - Working software over big documentations (time to market advantage) - Customer collaboration over contract negotiation (customer requirements) - Responding to change over following plan (change is more important)   The Agile Manifesto has 12 principles : - Satisfy the customer with continuous delivery - Changing requirements - Deliver software frequently (few weeks or months) - Business people and developer must work together - Build projects around motivated individuals - Face to face conversation - Working software is the primary measure of progress - The team should maintain a constant pace indefinitely - Technical excellence and good design - Simplic

RasPI Assistant: Google Assistant + Dialogflow + Raspberry Pi

Would you like to control the TV using your voice without spend a lot of money? ... Amazing right?. So, in this post, I will teach you how to do that and more. Some of my dreams always have been control things without touch them, for example: the television, due to tired to raise the hand to change the channel. So ... let's create a device that can do this action automatically. What things will we need? First, I should understand the problem and be aware about it. For example: if we want to control a TV that is not smart, how will we do that? ... a possibility is to send infrared signals (IR) to transmit the events that the person's desire. Also, if I want that the device can hear me, I may need a microphone. Additionally, it should have a speaker to talk with the people. Further, I will need a database to save all the information, APIs that can help me with the smart logic and cheap electronic components like a Raspberry Pi , resistors, leds, wires an

How to create a simple Chatbot?

Developing an amazing Chatbot ... What is a Chatbot? First to understand how it works, you need to know how it was originated and some algorithms  like  the Natural Language Processing (NLP). It is another AI area, but it is around the language (usually written), it is the component that bridges the gap between human conversation and understanding programmed by a computer. NLP allows the computer to interpret the vast and complicated human language, understand it, process it, and effectively "speak", just like humans. Through the process, the machine has to understand all the jargon that is being using and developing or adapting with the ability to respond, as a human computer. NLP has to do with the creation of systems that process or "understand" the language to perform certain tasks, such as answering questions, analyzing the sentiment in a sentence, making translations between different languages, and another. In the past, the NLP involved a lot