I haven't found an accurate online tutorial yet. I have my RPi3 working as an AP. This is what I do.
DO NOT MODIFY /etc/network/interfaces FILE! The only uncommented line in that file should be
source-directory /etc/network/interfaces.d
If you have connected to a wifi network, edit /etc/wpa_supplicant/wpa_supplicant.conf and remove the network part. It will look like this.
Code: Select all
network={
ssid="myssid'
psk="mypassphrase"
}
First, insure your OS is up to date.
Code: Select all
sudo apt-get update
sudo apt-get upgrade
sudo rpi-update
Then install the modules.
Code: Select all
sudo apt-get install dnsmasq hostapd
Replace wlx12345 with the name of your wifi interface and enx12345 with the ethernet interface from ifconfig in the following files. In the latest version of Stretch (2017-09-07), these will be wlan0 and eth0.
My /etc/dhcpcd.conf addition:
Code: Select all
interface wlx12345
static ip_address=192.168.4.1/24
My /etc/dnsmasq.conf file. I remove everything but these lines.
Code: Select all
interface=wlx12345
dhcp-range=192.168.4.8,192.168.4.250,255.255.255.0,12h
Create the file /etc/hostapd/hostapd.conf and insert this:
Code: Select all
interface=wlx12345
driver=nl80211
ssid=RPiNet
hw_mode=g
channel=7
wmm_enabled=0
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=mypassphrase
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
Edit /etc/default/hostapd, uncomment and change this:
Code: Select all
DAEMON_CONF="/etc/hostapd/hostapd.conf"
Edit /etc/sysctl.conf and uncomment
The next section is required only if you are wanting to access the internet through the ethernet connection.
My iptables rule.
Code: Select all
sudo iptables -t nat -A POSTROUTING -o enx12345 -j MASQUERADE
Then make the iptables rule permanent.
Code: Select all
sudo sh -c "iptables-save > /etc/iptables.ipv4.nat"
Then in /etc/rc.local, add this:
Code: Select all
iptables-restore < /etc/iptables.ipv4.nat