#!/bin/bash # Based on Adafruit Learning Technologies Onion Pi project # But mainly fixed by Raspberry Pi FR... if (( $EUID != 0 )); then echo "This must be run as root. Try 'sudo bash $0'." exit 1 fi apt-get update -y apt install dnsmasq -y systemctl stop dnsmasq echo "interface wlan0 static ip_address=192.0.4.1/24 nohook wpa_supplicant" >> /etc/dhcpcd.conf service dhcpcd restart mv /etc/dnsmasq.conf /etc/dnsmasq.conf.orig echo "interface=wlan0 # Use the require wireless interface - usually wlan0 dhcp-range=192.0.4.2,192.0.4.22,255.255.255.0,24h" > /etc/dnsmasq.conf systemctl unmask dnsmasq systemctl enable dnsmasq systemctl restart dnsmasq if command -v rfkill &> /dev/null then rfkill unblock wlan fi apt-get install hostapd -y systemctl unmask hostapd systemctl enable hostapd ssid=Pyrale passphrase=Paypoo2016 echo "interface=wlan0 driver=nl80211 ssid=$ssid hw_mode=g channel=7 wmm_enabled=0 macaddr_acl=0 auth_algs=1 ignore_broadcast_ssid=0 wpa=2 wpa_passphrase=$passphrase wpa_key_mgmt=WPA-PSK wpa_pairwise=TKIP rsn_pairwise=CCMP " > /etc/hostapd/hostapd.conf echo 'DAEMON_CONF="/etc/hostapd/hostapd.conf"' >> /etc/default/hostapd systemctl start hostapd cp /etc/sysctl.conf /etc/sysctl.bak echo "net.ipv4.ip_forward=1" >> /etc/sysctl.conf echo "up iptables-restore < /etc/iptables.ipv4.nat" >> /etc/network/interfaces sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward" iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE iptables -A FORWARD -i eth0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT sh -c "iptables-save > /etc/iptables.ipv4.nat" sed -i '/exit 0/ i iptables-restore < /etc/iptables.ipv4.nat' /etc/rc.local exit 0