Last active
March 3, 2017 06:03
-
-
Save intrd/b2405730be1f8591f012dcc1e98e27fe to your computer and use it in GitHub Desktop.
Tutorial - Create a wifi hotspot w/ hostapd and fwd internet (works on raspberrypi)
This file contains hidden or 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/bash | |
## Create a wifi hotspot w/ hostapd and fwd internet (works on raspberrypi) | |
# @author intrd - http://dann.com.br/ | |
# @license Creative Commons Attribution-ShareAlike 4.0 International License - http://creativecommons.org/licenses/by-sa/4.0/ | |
# /etc/network/interfaces | |
# auto wlan4 | |
# allow-hotplug wlan4 | |
# iface wlan4 inet static | |
# address 10.10.0.1 | |
# netmask 255.255.255.0 | |
# network 10.10.0.0 | |
# /etc/hostapd/hostapd.conf | |
# interface=wlan4 | |
# driver=nl80211 | |
# #driver=rtl871xdrv | |
# ssid=APINT | |
# hw_mode=g | |
# channel=6 | |
# macaddr_acl=0 | |
# auth_algs=1 | |
# ignore_broadcast_ssid=0 | |
# wpa=2 | |
# wpa_passphrase=Home123!!! | |
# wpa_key_mgmt=WPA-PSK | |
# wpa_pairwise=TKIP | |
# rsn_pairwise=CCMP | |
# hot_start.sh | |
sudo service hostapd stop | |
#sudo hostapd /etc/hostapd/hostapd.conf & | |
sudo route add 10.10.0.2 gw 10.10.0.1 wlan4 | |
sudo route add 10.10.0.3 gw 10.10.0.1 wlan4 | |
sudo route add 10.10.0.4 gw 10.10.0.1 wlan4 | |
sudo iptables -t nat -A POSTROUTING -o tun0 -j MASQUERADE | |
sudo iptables -A FORWARD -i eth0 -o tun0 -j ACCEPT | |
sudo hostapd /etc/hostapd/hostapd.conf & | |
echo "nameserver 10.10.0.1" > /etc/resolv.conf |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment