Created
August 14, 2013 17:42
-
-
Save maurostorch/6233514 to your computer and use it in GitHub Desktop.
Following instructions from: http://code.google.com/p/quickanddirty/wiki/CreatingWirelessHotspotWithLinux
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/bash | |
# HotSpot creating script using hostapd, dnsmasq and iptables | |
# Following instructions from: http://code.google.com/p/quickanddirty/wiki/CreatingWirelessHotspotWithLinux | |
LAN=wlan2 | |
WAN=eth2 | |
startap(){ | |
# Start | |
# Enable routing | |
sysctl net.ipv4.ip_forward=1 | |
# Cleaning NAT | |
iptables -F | |
iptables -t nat -F | |
iptables -t mangle -F | |
iptables -X | |
iptables -t nat -X | |
iptables -t mangle -X | |
# Configure IP address for WLAN | |
ifconfig $LAN down | |
ifconfig $LAN 192.168.0.1 | |
iptables -A FORWARD -o $WAN -i $LAN -m conntrack --ctstate NEW -j ACCEPT | |
iptables -A FORWARD -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT | |
iptables -A POSTROUTING -t nat -j MASQUERADE | |
# Start DNSMasq | |
service dnsmasq restart | |
# Run access point daemon | |
hostapd /etc/hostapd.conf >> /var/log/hostapd 2>&1 & | |
} | |
stopap(){ | |
# Stop | |
# Disable NAT | |
iptables -F | |
iptables -t nat -F | |
iptables -t mangle -F | |
iptables -X | |
iptables -t nat -X | |
iptables -t mangle -X | |
ifconfig $LAN down | |
# Disable routing | |
#sysctl net.ipv4.ip_forward=0 | |
# Disable DHCP/DNS server | |
service dnsmasq stop | |
#Stop hostapd daemon | |
PID=`pidof hostapd || echo "not running"` | |
printf "Stopping hostapd..." | |
if [[ "$PID" != "not running" ]]; then | |
kill -9 $PID | |
printf "done\n" | |
else | |
printf "$PID\n" | |
fi | |
} | |
case $1 in | |
start) | |
startap | |
;; | |
stop) | |
stopap | |
;; | |
*) | |
echo "Usage: `basename ${0}` start|stop" | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://linux-sunxi.org/Mele_A1000#Mele_A1000G.2FA2000G.2FA100G