Install
upgrade system && update apt-get resources1
2
3
4
5
6
7
8
9
10/etc/apt/sources.list
deb http://mirrors.zju.edu.cn/raspbian/raspbian/ jessie main contrib non-free rpi
# Uncomment line below then 'apt-get update' to enable 'apt-get source'
#deb-src http://mirrors.zju.edu.cn/raspbian/raspbian/ jessie main contrib non-free rpi
#deb http://mirror.nus.edu.sg/raspbian/raspbian wheezy main contrib non-free rpi
#deb http://mirrordirector.raspbian.org/raspbian/ jessie main contrib non-free rpi
# Uncomment line below then 'apt-get update' to enable 'apt-get source'
#deb-src http://archive.raspbian.org/raspbian/ jessie main contrib non-free rpi
software1
git clone https://github.com/oblique/create_ap.git
dependencies1
sudo apt-get install util-linux procps iproute2 iw haveged hostapd dnsmasq
hostapd is the daemon thread of Host Access Point
used to provide WPA2
token check and authentication
dnsmasq used to config DNS
provide DHCP
service
Config
Wlan config
dispatch wlan0 a static ip address1
2
3
4sudo vim /etc/dhcpcd.conf
interface wlan0
static ip_address=192.168.0.1/24
comments the wlan0 wpa-conf to prevent distribute host mode1
2
3
4
5sudo nano /etc/network/interfaces
allow-hotplug wlan0
iface wlan0 inet manual
# wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
restart raspberry1
2
3sudo service dhcpcd restart
sudo reboot
sudo init 0
Host config
1 | sudo vim /etc/hostapd/hostapd.conf |
Web config
1 | sudo nano /etc/sysctl.conf |
if not want to reboot raspberry1
sudo sh -c "echo 1 >/proc/sys/net/ipv4/ip_forward"
For config NAT
, config firewall first1
2
3sudo iptables -t nat -APOSTROUTING -o eth0 -j MASQUERADE
sudo iptables -A FORWARD -i eth0-o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT
sudo iptables -A FORWARD -i wlan0-o eth0 -j ACCEPT
set rule autostart1
sudo sh -c "iptables-save> /etc/iptables.ipv4.nat"
run NAT
by DHCPCD
need a new config1
2sudo nano /lib/dhcpcd/dhcpcd-hooks/70-ipv4-nat
iptables-restore </etc/iptables.ipv4.nat
restart1
2
3sudo service hostapdstart
sudo service dnsmasq start
sudo reboot