Skip to content

Instantly share code, notes, and snippets.

@acoomans
Created November 27, 2019 05:18
Show Gist options
  • Save acoomans/ee909ea00b4b83c5767d0674156b4775 to your computer and use it in GitHub Desktop.
Save acoomans/ee909ea00b4b83c5767d0674156b4775 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 [email protected]

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
@NikoQT
Copy link

NikoQT commented Sep 19, 2024

sadly not working anymore

@EggToaster
Copy link

Biggest facepalm of all time. Forcing all copy-pasters who does not read the command to not install recommended software by default which is weird.

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