|     Inicio    |   |         |  |   FOROS      |  |      |      
   Elastix - VoIP B4A (Basic4Android) App inventor 2 PHP - MySQL
  Estación meteorológica B4J (Basic4Java) ADB Shell - Android Arduino
  Raspberry Pi Visual Basic Script (VBS) FireBase (BD autoactualizable) NodeMCU como Arduino
  AutoIt (Programación) Visual Basic Cosas de Windows Webs interesantes
Translate:
Búsqueda en este sitio:


.

Raspberry Pi

Tutorial de Rapberry Pi en español.
- Juan Antonio Villalpando -

Volver al índice del tutorial

____________________________

18.- Instalación de un Punto de Acceso en el Raspberry Pi.

- Podemos crear una red propia con el RP sin tener que estar conectado a Internet, eso se denomina Punto de Acceso. Hotspot.

- También podemos configurarlo como bridge, es decir el RP conectado a Internet por cable y los clientes se conectan a Internet a través del RP y WiFi.

- Seguimos este tutorial

https://www.raspberrypi.org/documentation/configuration/wireless/access-point.md

https://thepi.io/how-to-use-your-raspberry-pi-as-a-wireless-access-point/

https://raspberrytips.com/raspberry-pi-firewall/

- Vamos a crear un Punto de acceso con el Raspberry Pi, esto es como una nueva red independiente de nuestro Router. En un primer momento no le pondremos conexión a Internet, será una red aislada.

- Aconsejo hacer una copia de seguridad de toda la SdCard, tendrá unos 4.3 GB cuando esté comprimida, para hacer esa copia utiliza Win32DiskImager: 1_noobs.htm

- Si escribimos al principio sudo su, entraremos en modo root # y no será necesario comenzar las órdenes con sudo.

1.- Instalación de dnsmasq y hostapd

sudo apt install dnsmasq hostapd -y

- El -y es para que haga la instalación por defecto y no realice preguntas durante la instalación.

2.- Configuracion de IP estática.

- Crearemos una red con IP de la forma 192.168.4.1

- Para ello vamos a configurar el archivo dhcpcd.conf

sudo nano /etc/dhcpcd.conf

Vamos al final de ese archivo y escribiremos:

interface wlan0
static ip_address=192.168.4.1/24
nohook wpa_supplicant

Reiniciamos el demonio dhcpcd

sudo systemctl restart dhcpcd

3.- Configuración del servidor DHCP (dnsmasq)

- El servidor DHCP se crea mediante dnsmasq. Vamos a realizar una copia de seguridad del archivo de configuracion y crear uno nuevo.

sudo mv /etc/dnsmasq.conf /etc/dnsmasq.conf.orig           [copia de seguridad]

sudo nano /etc/dnsmasq.conf

Borramos todo el contenido de ese archivo y copiamos esto:

interface=wlan0 # Use the require wireless interface - usually wlan0
dhcp-range=192.168.4.2,192.168.4.20,255.255.255.0,24h

- Vamos a crear una nueva red cuyas IP serán desde el 192.168.4.2 hasta el 192.168.4.20, con un alquiler de 24 horas.

- Reiniciamos dnsmasq

sudo systemctl reload dnsmasq

4.- Configuración del Punto de Acceso (hostapd).

- Configuramos el archivo para el Punto de Acceso. Copiamos y guardamos:

sudo nano /etc/hostapd/hostapd.conf

interface=wlan0
driver=nl80211
ssid=Nombre_de_la_Nueva_Red
hw_mode=g
channel=7
wmm_enabled=0
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=Contraseña_de_la_Nueva_Red
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP

- Le indicamos al sistema dónde se encuentra el archivo anterior:

sudo nano /etc/default/hostapd

Esta línea debe estar así:

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

[Nota: no confundas esa línea con la DAEMON_OPTS ]

5.- Arranque.

sudo systemctl unmask hostapd
sudo systemctl enable hostapd
sudo systemctl start hostapd

[esta última orden da error: https://www.raspberrypi.org/forums/viewtopic.php?t=235145 ]
Job for hostapd.service failed because the control process exited with error code.
See "systemctl status hostapd.service" and "journalctl -xe" for details.

sudo systemctl enable hostapd
sudo apt-get autoremove --purge git lighttpd php7.0-cgi vnstat dnsmasq hostapd
sudo apt-get clean
wget -q https://git.io/voEUQ -O /tmp/raspap && bash /tmp/raspap


sudo service hostapd status

6.- ruta y máscara.

Editamos:

sudo /etc/sysctl.conf

Descomentamos esta línea:

net.ipv4.ip_forward=1

- Añadimos una máscara de salida a eth0

sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

- Guardamos las reglas de iptables.

sudo sh -c "iptables-save > /etc/iptables.ipv4.nat"

Editamos:

sudo /etc/rc.local

Añadimos esto encima de "exit 0" para instalar las reglas de inicio.

iptables-restore < /etc/iptables.ipv4.nat

- Ya lo tenemos ahora vamos a un dispositivo con WiFi, un móvil, un portátil, una tablet,... y buscamos la nueva red.

- En esta nueva red también podemos entrar mediante ssh

ssh pi@192.168.4.1

----------------------------------------------------------------------------------

Using the Raspberry Pi as an access point to share an internet connection (bridge)

One common use of the Raspberry Pi as an access point is to provide wireless connections to a wired Ethernet connection, so that anyone logged into the access point can access the internet, providing of course that the wired Ethernet on the Pi can connect to the internet via some sort of router.

To do this, a 'bridge' needs to put in place between the wireless device and the Ethernet device on the access point Raspberry Pi. This bridge will pass all traffic between the two interfaces. Install the following packages to enable the access point setup and bridging.

sudo apt install hostapd bridge-utils

Bridging creates a higher-level construct over the two ports being bridged. It is the bridge that is the network device, so we need to stop the eth0 and wlan0 ports being allocated IP addresses by the DHCP client on the Raspberry Pi.

sudo nano /etc/dhcpcd.conf

Add denyinterfaces wlan0 and denyinterfaces eth0 to the end of the file (but above any other added interface lines) and save the file.

Now the interfaces file needs to be edited to adjust the various devices to work with bridging. sudo nano /etc/network/interfaces make the following edits.

Add the bridging information at the end of the file.

# Bridge setup auto br0 iface br0 inet manual bridge_ports eth0 wlan0

Bring up the new br0 interface and restart dhcpcd for the changes to take effect:

sudo ifup br0 sudo systemctl restart dhcpcd

The access point setup is almost the same as that shown in the previous section. Follow all the instructions in the Configuring the access point host software (hostapd) section above to set up the hostapd.conf file and the system location, but add bridge=br0 below the interface=wlan0 line, and remove or comment out the driver line. The passphrase must be between 8 and 64 characters long.

To use the 5 GHz band, you can change the operations mode from 'hw_mode=g' to 'hw_mode=a'. The possible values for hw_mode are:

  • a = IEEE 802.11a (5 GHz)
  • b = IEEE 802.11b (2.4 GHz)
  • g = IEEE 802.11g (2.4 GHz)
  • ad = IEEE 802.11ad (60 GHz). Not available on Raspberry Pi.
interface=wlan0 bridge=br0 #driver=nl80211 ssid=NameOfNetwork hw_mode=g channel=7 wmm_enabled=0 macaddr_acl=0 auth_algs=1 ignore_broadcast_ssid=0 wpa=2 wpa_passphrase=AardvarkBadgerHedgehog wpa_key_mgmt=WPA-PSK wpa_pairwise=TKIP rsn_pairwise=CCMP

Start it up

Now enable and start hostapd :

sudo systemctl unmask hostapd sudo systemctl enable hostapd sudo systemctl start hostapd

There should now be a functioning bridge between the wireless LAN and the Ethernet connection on the Raspberry Pi, and any device associated with the Raspberry Pi access point will act as if it is connected to the access point's wired Ethernet.

The ifconfig command will show the bridge, which will have been allocated an IP address via the wired Ethernet's DHCP server. The wlan0 and eth0 no longer have IP addresses, as they are now controlled by the bridge. It is possible to use a static IP address for the bridge if required, but generally, if the Raspberry Pi access point is connected to a ADSL router, the DHCP address will be fine.

_______________________________________

- Otro tutorial

https://howtoraspberrypi.com/create-a-wi-fi-hotspot-in-less-than-10-minutes-with-pi-raspberry/

 

___________________________________________________

 

- Mi correo:
juana1991@yahoo.com
- KIO4.COM - Política de cookies. Textos e imágenes propiedad del autor:
© Juan A. Villalpando
No se permite la copia de información ni imágenes.
Usamos cookies propias y de terceros que entre otras cosas recogen datos sobre sus hábitos de navegación y realizan análisis de uso de nuestro sitio.
Si continúa navegando consideramos que acepta su uso. Acepto    Más información