Install dnsmasq hostapd
apt-get install dnsmasq hostapd
nano /etc/dhcpcd.conf
denyinterfaces wlan0
nano /etc/hostapd/hostapd.conf
interface=wlan0 # This is the name of the WiFi interface we configured above
driver=nl80211 # Use the nl80211 driver with the brcmfmac driver
ssid=Pi3-AP # This is the name of the network
hw_mode=g # Use the 2.4GHz band
channel=6 # Use channel 6
ieee80211n=1 # Enable 802.11n
wmm_enabled=1 # Enable WMM
ht_capab=[HT40][SHORT-GI-20][DSSS_CCK-40] # Enable 40MHz channels with 20ns guard interval
macaddr_acl=0 # Accept all MAC addresses
auth_algs=1 # Use WPA authentication
ignore_broadcast_ssid=0 # Require clients to know the network name
wpa=2 # Use WPA2
wpa_key_mgmt=WPA-PSK # Use a pre-shared key
wpa_passphrase=raspberry # The network passphrase
rsn_pairwise=CCMP # Use AES, instead of TKIP
/usr/sbin/hostapd /etc/hostapd/hostapd.conf
nano /etc/default/hostapd
DAEMON_CONF="/etc/hostapd/hostapd.conf"
sudo mv /etc/dnsmasq.conf /etc/dnsmasq.conf.orig
sudo nano /etc/dnsmasq.conf
interface=wlan0 # Use interface wlan0
listen-address=10.0.0.1 # Explicitly specify the address to listen on
bind-interfaces # Bind to the interface to make sure we aren't sending things elsewhere
server=8.8.8.8 # Forward DNS requests to Google DNS
domain-needed # Don't forward short names
bogus-priv # Never forward addresses in the non-routed address spaces.
dhcp-range=10.0.0.10,10.0.0.20,2h # Assign IP addresses
sudo nano /etc/sysctl.conf
#remove the # from the beginning of the line containing net.ipv4.ip_forward=1
sudo sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward"
sudo iptables -t nat -A POSTROUTING -o wlan1 -j MASQUERADE
sudo iptables -A FORWARD -i wlan1 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT
sudo iptables -A FORWARD -i wlan0 -o wlan1 -j ACCEPT
sudo sh -c "iptables-save > /etc/iptables.ipv4.nat"
sudo nano /etc/rc.local
#just above the line exit 0, add the following line:
iptables-restore < /etc/iptables.ipv4.nat
sudo service hostapd start
sudo service dnsmasq start