Skip to content

Instantly share code, notes, and snippets.

@floviolleau
Forked from acoomans/pihole.md
Created June 12, 2023 20:47
Show Gist options
  • Save floviolleau/1e944101ebc92899903fe556e232075a to your computer and use it in GitHub Desktop.
Save floviolleau/1e944101ebc92899903fe556e232075a to your computer and use it in GitHub Desktop.
Pi-hole as WiFi AP

SSD card

On the ssd card:

touch ssh

Rasberry Pi

Log in:

ssh pi@raspberrypi.local

Configure

sudo raspi-config

then:

2 Network Options > N1 Hostname > pihole
5 Interfacing Options > P2 SSH > yes

Upgrade system

echo -e 'APT::Install-Recommends "0";\nAPT::Install-Suggests "0";' | sudo tee /etc/apt/apt.conf.d/01norecommend	
sudo apt update
sudo apt full-upgrade

Set static ip:

sudo vi /etc/dhcpcd.conf

interface wlan0
    static ip_address=192.168.4.1/24
    nohook wpa_supplicant

sudo systemctl daemon-reload
sudo service dhcpcd restart

Set as wifi ap:

sudo apt install hostapd
sudo vi /etc/hostapd/hostapd.conf

interface=wlan0
driver=nl80211
ssid=0wa
hw_mode=g
channel=7
wmm_enabled=0
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=abcdefgh
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP

sudo chmod 600 /etc/hostapd/hostapd.conf
sudo vi /etc/default/hostapd

DAEMON_CONF="/etc/hostapd/hostapd.conf"

sudo systemctl unmask hostapd
sudo systemctl enable hostapd
sudo systemctl start hostapd

Add routing and masquerade:

sudo vi /etc/sysctl.conf

net.ipv4.ip_forward=1

sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
sudo sh -c "iptables-save > /etc/iptables.ipv4.nat"

sudo vi /etc/rc.local

iptables-restore < /etc/iptables.ipv4.nat

Install:

wget -O basic-install.sh https://install.pi-hole.net
sudo bash basic-install.sh

Post-install configuration:

pihole admin -i all
pihole admin -i local

Enable DHCP server:

http://192.168.10.69/admin/settings.php?tab=piholedhcp

Repair/reconfigure:

sudo vi /etc/pihole/setupVars.conf
pihole reconfigure

Update:

pihole update

Security

Change pi user password:

passwd

Change wifi password:

sudo vi /etc/hostapd/hostapd.conf

Change pi-hole admin password:

pihole admin -p
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment