Turn RPi into a NAS and running Pi-Hole

Jump to navigation Jump to search

Parent page: Boot Raspberry Pi 4 From a USB SSD or Flash Drive
RPi NAS.png

Turn RPi into a NAS


  • sudo chown -R pi:pi /media/pi/NAS where NAS is our disk label.
  • sudo apt install samba samba-common
  • sudo vim /etc/samba/smb.conf, add the following lines at the end
path = /media/pi/NAS
writable = yes
create mask = 0755
directory mask = 0755
  • sudo smbpasswd -a pi < Enter 'pi' as password
  • sudo systemctl restart smbd

Access the NAS

Using Samba username (pi) and password (pi)

  • For Mac, Finder > Go > Connect to Server
    • Enter smb://raspberrypi
  • For Windows, open File Explorer, type \\raspberrypi\NAS
    • Or type \\\NAS
Access with NetBIOS
  • net use <-- It can be mounted as a drive
Status       Local     Remote                    Network
OK                     \\raspberrypi\NAS         Microsoft Windows Network
  • ping raspberrypi <-- Using NetBIOS to discover it and use IPv6 to ping
Pinging raspberrypi.local [fe80::114c:1a15:39e8:d233%11] with 32 bytes of data:
Reply from fe80::114c:1a15:39e8:d233%11: time<1ms
  • ping fe80::114c:1a15:39e8:d233%11 <-- It works
  • ping

Install Pi-Hole as Ads DNS blocker

  • Switch to root
  • Execute: curl -sSL https://install.pi-hole.net | bash
  • Pick external DNS server to Cloudflare
  • Copy RPi static IP address if you have no idea RPi address
  • Install web admin (GUI interface)
  • Install the web server (lighttpd) which requires PHP modules
  • Enable log queries
  • Enable Show everything

Done. The URL should be http://static_IP/admin

  • Change your Router's DNS host to this RPi now.
  • Change DNSMasq in your router if the router supports this option
    • Change to: dhcp-option=6,__static_IP__

Reset the pihole password

  • sudo pihole -a -p
  • Enter the password twice.
  • This is the password to logon to Pi-Hole web admin page.