Raspberry pi as access point along with pihole

its 2018 these steps are a little old. you cant put static ips in /etc/netork/interfaces so after a day of fumbling through i figured id post my recipe to help someone else along the way

the key here is to install pihole after you set up you interfaces, and leave the dnsmasq til after its set up

most of this was derived from above and http://home.iitk.ac.in/~saiwal/electronics/using-pi-hole-and-raspberry-pi-as-hotspot-for-ad-less-online-experience/

along with the raspbian ap setup here https://www.raspberrypi.org/documentation/configuration/wireless/access-point.md#internet-sharing

install raspbian

raspi-config , enable ssh adjust keyboard n lang timezone

sudo apt update; sudo apt upgrade -y
sudo apt install hostapd -y

in /etc/dhcpcd.conf
interface wlan0
static ip_address=192.168.4.1/24

in /etc/hostapd/hostapd.conf
interface=wlan0
driver=nl80211
#driver=rtl871xdrv
hw_mode=g
channel=6
ieee80211n=1
wmm_enabled=1
ht_capab=[HT40][SHORT-GI-20][DSSS_CCK-40]
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_key_mgmt=WPA-PSK
rsn_pairwise=CCMP
ssid=Pi3-AP
wpa_passphrase=raspberry

/etc/default/hostapd
echo DAEMON_CONF="/etc/hostapd/hostapd.conf" | sudo tee -a /etc/default/hostapd

in /etc/sysctl.conf
uncomment net.ipv4.ip_forward=1

sudo iptables -t nat -A POSTROUTING -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
sudo sh -c "iptables-save > /etc/iptables.ipv4.nat"

echo 'iptables-restore < /etc/iptables.ipv4.nat' | sudo tee /lib/dhcpcd/dhcpcd-hooks/70-ipv4-nat

reboot

install pihole
curl -L https://install.pi-hole.net | bash

add in /etc/dnsmasq.conf
interface=wlan0
dhcp-range=192.168.4.2,192.168.4.20,255.255.255.0,24h
ot

then secure box

change pihole password
pihole -a -p