|
|
Riga 1: |
Riga 1: |
| = Un hotspot con OSMC e Raspberry =
| |
|
| |
| == Scenario ==
| |
|
| |
| [https://osmc.tv/download/ OSMC] è un famoso media center basato su Linux. Sul Raspberry è una distribuzione basata su Debian, così come Raspbian.
| |
|
| |
| Per la gestione della rete non utilizza <code>/etc/network/interfaces</code> e nemmeno NetworkManager, ma ''connman'', un sistema abbastanza limitato sotto certi aspetti. Avrebbe la funzione di thetering, ma anche questa con delle limitazioni, fra cui qualche difficoltà ad usarlo con l'adattatore wifi qui utilizzato. Per cui non viene usato in questa configurazione.<br />
| |
| Molti comandi di uso comune vanno installati con apt: xz-utils, iwconfig, usbutils.
| |
|
| |
| === Hardware e software ===
| |
|
| |
| * Raspberry Pi 2
| |
| * Dongle WiFi USB <code>Bus 001 Device 006: ID 0bda:8176 Realtek Semiconductor Corp. RTL8188CUS 802.11n WLAN Adapter</code>
| |
| * hostapd
| |
| * dnsmasq
| |
| * iptables-persistent
| |
|
| |
| === Hostapd e RTL8188CUS ===
| |
|
| |
| Non funziona il driver nl80211, quindi per usare hostapd, va scaricata una versione modificata del programma.
| |
|
| |
| == Configurazione ==
| |
|
| |
| === IP statico scheda WiFi ===
| |
|
| |
| Come facevano gli antichi, e per i motivi detti prima, ghiozzamente ho aggiunto la configurazione al file <code>/etc/rc.local</code>
| |
|
| |
| echo "ifconfig wlan0 10.10.10.1 255.255.255.0" >> /etc/rc.local
| |
|
| |
| === DHCP ===
| |
|
| |
| apt-get install dnsmasq
| |
|
| |
| File di configurazione <code>/etc/dnsmasq.conf</code>
| |
|
| |
| interface=wlan0
| |
| no-dhcp-interface=lo,eth0
| |
| dhcp-range=10.10.10.11,10.10.10.40,255.255.255.0,12h
| |
|
| |
| Abilitiamolo all'avvio
| |
|
| |
| systemctl enable dnsmasq
| |
|
| |
| === HOSTAPD === | | === HOSTAPD === |
|
| |
|
Riga 84: |
Riga 41: |
| systemctl enable hostapd | | systemctl enable hostapd |
|
| |
|
| === NAT ===
| | Per la questione del drier Realtek vedi: |
| | | * https://www.raspberrypi.org/forums/viewtopic.php?f=29&t=103825 |
| Abilitare il forward dei pacchetti fra le schede di rete
| | * https://github.com/PirateBox-Dev/arch_rpi_image_prepare/tree/master/packages/rpi2/hostapd |
| | |
| echo net.ipv4.ip_forward=1 >> /etc/sysctl.conf
| |
| sysctl -p
| |
| | |
| Installare <code>iptables-persistent</code>. http://blog.mxard.com/persistent-iptables-on-raspberry-pi-raspbian
| |
| | |
| iptables -t nat -A POSTROUTING -s 10.10.10.0/24 ! -d 10.10.10.0/24 -j MASQUERADE
| |
| | |
| <code>dpkg-reconfigure iptables-persistent</code> e dirgli di salvare le regole attuali.
| |
HOSTAPD
Questo è il servizio che fa da access point.
apt-get install hostapd
File di configurazione /etc/hostapd/hostapd.conf
# Wireless interface
interface=wlan0
driver=rtl871xdrv
ieee80211n=1
device_name=RTL8188CUS
manufacturer=Realtek
ssid=ILSSID
channel=8
country_code=IT
hw_mode=g
# 802.11n
wme_enabled=1
ieee80211n=1
#ht_capab=[HT40+][SMPS-STATIC][SHORT-GI-20][SHORT-GI-40][DSSS_CCK-40]
# Authentication and encryption
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=lapassword
wpa_key_mgmt=WPA-PSK WPA-EAP
wpa_pairwise=TKIP
rsn_pairwise=CCMP
wmm_enabled=0
In /etc/default/hostapd
aggiungiamo
DAEMON_CONF="/etc/hostapd/hostapd.conf"
Abilitiamolo all'avvio
systemctl enable hostapd
Per la questione del drier Realtek vedi: