Skip to content

Instantly share code, notes, and snippets.

@lacrosse
Created January 2, 2014 04:04
Show Gist options
  • Save lacrosse/8214897 to your computer and use it in GitHub Desktop.
Save lacrosse/8214897 to your computer and use it in GitHub Desktop.
#!/bin/bash
if [[ -n "$2" ]]; then
device=$2
else
device="eth0"
fi
if [ "start" = "$1" ]; then
ifconfig wlan0 192.168.150.1
service dnsmasq restart
sysctl net.ipv4.ip_forward=1
iptables -t nat -A POSTROUTING -o $device -j MASQUERADE
hostapd /etc/hostapd.conf
elif [ "stop" = "$1" ]; then
iptables -t nat -D POSTROUTING -o $device -j MASQUERADE
sysctl net.ipv4.ip_forward=0
service dnsmasq stop
service hostapd stop
else
echo "usage:"
echo " wifi [start|stop] [device]"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment