Skip to content

Instantly share code, notes, and snippets.

@acoomans
Created November 27, 2019 05:18
Show Gist options
  • Select an option

  • Save acoomans/ee909ea00b4b83c5767d0674156b4775 to your computer and use it in GitHub Desktop.

Select an option

Save acoomans/ee909ea00b4b83c5767d0674156b4775 to your computer and use it in GitHub Desktop.

Revisions

  1. Arnaud Coomans created this gist Nov 27, 2019.
    125 changes: 125 additions & 0 deletions pihole.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,125 @@

    ## 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

    ### [Wifi Access Point](https://www.raspberrypi.org/documentation/configuration/wireless/access-point.md)

    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

    ### [Pi-hole](https://pi-hole.net/)

    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