Skip to content

Instantly share code, notes, and snippets.

@slickplaid
Last active May 8, 2018 01:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save slickplaid/a55bdcd5ad9c1ecc933bb0fd245dbbf6 to your computer and use it in GitHub Desktop.
Save slickplaid/a55bdcd5ad9c1ecc933bb0fd245dbbf6 to your computer and use it in GitHub Desktop.
Create an AP on a raspberry pi

Raspi Atlas AP

This will set up a raspbian access point with all traffic masqueraded through eth0

Usage

wget -O- https://gist.githubusercontent.com/slickplaid/a55bdcd5ad9c1ecc933bb0fd245dbbf6/raw/df2b624fc25ee742d971f999de85a4f4e2daaaf8/raspi-chromecast-ap.sh | sh

Connect to the AP through the SSID atlas and password chromecastftw

Recovery

If you need to revert these changes, you should be able to log in through wlan0 on 10.0.42.1

#!/bin/bash
# prep
sudo apt-get update
sudo apt-get install dnsmasq hostapd -y
sudo systemctl stop dnsmasq
sudo systemctl stop hostapd
sudo cp /etc/dhcpcd.conf /etc/dhcpcd.conf.default
sudo mv /etc/dnsmasq.conf /etc/dnsmasq.conf.default
sudo cat >> /etc/dhcpcd.conf <<'_EOF'
interface wlan0
static ip_address=10.0.42.1/24
_EOF
sudo cat >> /etc/dnsmasq.conf <<'_EOF'
interface=wlan0
dhcp-range=10.0.42.50,10.0.42.100,24h
_EOF
sudo cat >> /etc/hostapd/hostapd.conf <<'_EOF'
interface=wlan0
driver=nl80211
ssid=atlas
hw_mode=g
channel=6
wmm_enabled=0
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=chromecastftw
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
_EOF
sudo sed -i -e 's/#net.ipv4.ip_forward=1/net.ipv4.ip_forward=1/g' /etc/sysctl.conf
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
sudo sh -c "iptables-save > /etc/iptables.ipv4.nat"
sudo sed -i -e '$i \iptables-restore < /etc/iptables.ipv4.nat\n' /etc/rc.local
sudo service dhcpcd restart
sudo service hostapd start
sudo service dnsmasq start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment