Skip to content

Instantly share code, notes, and snippets.

@amfg
Created March 14, 2017 17:12
Show Gist options
  • Save amfg/ff331a660e2d2bf36b36dd62e161c9a3 to your computer and use it in GitHub Desktop.
Save amfg/ff331a660e2d2bf36b36dd62e161c9a3 to your computer and use it in GitHub Desktop.
Linux AP
#!/bin/bash
export DEV_IN=wlan0;
ifconfig $DEV_IN down;
/etc/init.d/hostapd stop
/etc/init.d/dnsmasq stop
iptables -Z
iptables -F
iptables -X
ifconfig $DEV_IN up;
# /etc/dnsmasq.conf
interface=wlan0
dhcp-range=192.168.0.150,192.168.0.170,12h
# /etc/hostapd/hostapd.conf
ssid=Bait
interface=wlan0
hw_mode=g
channel=9
# for WPA
wpa=1
wpa_passphrase=whatever password
#!/bin/bash
export DEV_IN=wlan0;
export DEV_OUT=eth0;
echo "Bringing up $DEV_IN"
#This address/mask should match how you configured dnsmasq
ifconfig $DEV_IN up 192.168.0.129 netmask 255.255.255.0
echo "Starting dnsmasq"
/etc/init.d/dnsmasq start
echo "Configuring iptables"
#Clear everything in iptables
iptables -Z;
iptables -F;
iptables -X;
#Turn on iptables NAT, forwarding, and enable
#forwarding in the kernel
iptables --table nat --append POSTROUTING --out-interface $DEV_OUT -j MASQUERADE
iptables --append FORWARD --in-interface $DEV_IN -j ACCEPT
sysctl -w net.ipv4.ip_forward=1
echo "Starting hostapd"
/etc/init.d/hostapd start
#hostapd /etc/hostapd/hostapd.conf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment