Last active
January 5, 2020 05:29
-
-
Save drdnar/43a5098adb6df59876e3133bc8047a8f to your computer and use it in GitHub Desktop.
Quick temporary Wi-Fi AP for Raspberry Pi 4B
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface=wlan0 | |
driver=nl80211 | |
ssid=linksys | |
hw_mode=a | |
ieee80211ac=1 | |
channel=149 | |
wmm_enabled=0 | |
macaddr_acl=0 | |
auth_algs=1 | |
ignore_broadcast_ssid=0 | |
wpa=2 | |
wpa_passphrase=1234 | |
wpa_key_mgmt=WPA-PSK | |
wpa_pairwise=CCMP | |
rsn_pairwise=CCMP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# There are plenty of guides to configuring a Raspberry Pi as a persistent Wi-Fi | |
# access point (AP) bridging to wired Ethernet, but I wanted a quick script that | |
# could set up an AP temporarily. This way, you can have the Pi default to | |
# accessing Wi-Fi as a client most of the time, but you can easily set up an AP | |
# whenever you want without worrying that some time later you'll forget it's in | |
# AP mode and then have trouble accessing it. | |
# | |
# Nothing this script changes is persistent, so when you want to stop AP mode, | |
# just reboot the Pi. Alternatively, you could read the man pages and undo | |
# everything the script does. | |
# | |
# This requires the hostapd and bridge-utils utilities, which you can install | |
# like so: | |
# sudo apt install hostapd bridge-utils | |
# | |
# The myhostapd.conf file (example included in this gist) should be in the same | |
# directory as this script (or otherwise findable), and remember to change the | |
# SSID and password in the configuration file. | |
echo "Stopping Wi-Fi. . . ." | |
sudo wpa_cli terminate | |
sudo ifdown wlan0 | |
echo "Stopping DHCP. . . ." | |
sudo dhcpcd --release | |
sudo dhcpcd --exit | |
echo "Starting hostapd. . . ." | |
sudo hostapd -B myhostapd.conf | |
sleep 10s | |
echo "Setting up bridge. . . ." | |
sudo brctl addbr br0 | |
sudo brctl addif br0 eth0 | |
sudo brctl addif br0 wlan0 | |
echo "Enabling IP forwarding. . . ." | |
sudo sysctl -w net.ipv4.ip_forward=1 | |
sudo sysctl -w net.ipv6.conf.all.forwarding=1 | |
echo "Getting IP addresses. . . ." | |
sudo dhcpcd --master --denyinterfaces=eth0,wlan0 --timeout=10 br0 | |
echo "Done." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment