For the CarPi software, I had three constraints: phones must control the player; the CarPi needs occasional internet for updates; phones connected to the CarPi must also get internet.
Pour le logiciel du CarPi, j'avais trois contraintes : les téléphones doivent contrÎler le lecteur ; le CarPi doit avoir accÚs à internet de temps en temps pour les mises à jour ; les téléphones connectés au CarPi doivent aussi avoir internet.
Solution: two WiFi interfaces â one internal AP for phones (wlan1), one to connect upstream (wlan0). The CarPi acts as router/firewall.
Solution : deux interfaces WiFi â une en point d'accĂšs interne pour les tĂ©lĂ©phones (wlan1), une pour se connecter Ă l'extĂ©rieur (wlan0). Le CarPi joue le rĂŽle de routeur/pare-feu.
Install DHCP server and hostapd
Installer le serveur DHCP et hostapd
sudo apt-get update
sudo apt-get install hostapd isc-dhcp-serverConfigure DHCP
Configurer le DHCP
In /etc/dhcp/dhcpd.conf, make sure authoritative; is uncommented, then add:
Dans /etc/dhcp/dhcpd.conf, décommenter authoritative;, puis ajouter :
subnet 192.168.200.0 netmask 255.255.255.0 {
range 192.168.200.100 192.168.200.200;
option broadcast-address 192.168.200.255;
option routers 192.168.200.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;
}Make wlan1 static
Rendre wlan1 statique
auto wlan1
allow-hotplug wlan1
iface wlan1 inet static
address 192.168.200.1
netmask 255.255.255.0
network 192.168.200.0
broadcast 192.168.200.255Configure hostapd
Configurer hostapd
interface=wlan1
ssid=OnTheMove
hw_mode=g
channel=6
wpa=2
wpa_passphrase=VOTREMOTDEPASSE
wpa_key_mgmt=WPA-PSK
rsn_pairwise=CCMPEnable IP forwarding and NAT
Activer le routage IP et le NAT
sudo sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward"
sudo iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE
sudo iptables -A FORWARD -i wlan1 -o wlan0 -j ACCEPT
sudo iptables -A FORWARD -i wlan0 -o wlan1 -m state --state RELATED,ESTABLISHED -j ACCEPT
sudo sh -c "iptables-save > /etc/iptables.ipv4.nat"