Last active
March 21, 2017 15:44
-
-
Save josefmonje/b1e210e46dbad3d8795322549724a39d to your computer and use it in GitHub Desktop.
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
#https://nims11.wordpress.com/2013/05/22/using-hostapd-with-dnsmasq-to-create-virtual-wifi-access-point-in-linux/ | |
#!/bin/bash | |
#Initial wifi interface configuration | |
ifconfig $1 up 10.0.0.1 netmask 255.255.255.0 | |
sleep 2 | |
###########Start dnsmasq, modify if required########## | |
if [ -z "$(ps -e | grep dnsmasq)" ] | |
then | |
dnsmasq | |
fi | |
########### | |
#Enable NAT | |
iptables --flush | |
iptables --table nat --flush | |
iptables --delete-chain | |
iptables --table nat --delete-chain | |
iptables --table nat --append POSTROUTING --out-interface $2 -j MASQUERADE | |
iptables --append FORWARD --in-interface $1 -j ACCEPT | |
#Thanks to lorenzo | |
#Uncomment the line below if facing problems while sharing PPPoE, see lorenzo's comment for more details | |
#iptables -I FORWARD -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu | |
sysctl -w net.ipv4.ip_formard=1 | |
#start hostapd | |
sudo hostapd -B /home/pi/.hostapd.min.conf | |
killall dnsmasq |
In the original script it blocks. I have to hit ctrl+c to stop hostapd. I added the -B as suggested there but I haven't been using the script much but there's a note in the link about "taking care of dnsmasq". I honestly don't know about how all of these work but the script works nicely. Another nice thing about it is you can also select interfaces when activating it like ./initAP eth0 wlan1
(source interface to access point interface).
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Why do you start dnsmasq, start hostapd then kill dnsmasq? Does hostapd run in blocking (non-daemon) mode?