Created
March 14, 2017 17:12
-
-
Save amfg/ff331a660e2d2bf36b36dd62e161c9a3 to your computer and use it in GitHub Desktop.
Linux AP
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 | |
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; |
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
# /etc/dnsmasq.conf | |
interface=wlan0 | |
dhcp-range=192.168.0.150,192.168.0.170,12h |
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
# /etc/hostapd/hostapd.conf | |
ssid=Bait | |
interface=wlan0 | |
hw_mode=g | |
channel=9 | |
# for WPA | |
wpa=1 | |
wpa_passphrase=whatever password |
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 | |
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