首页 >> 大全

树莓派Pi-hole实操安装教程

2023-12-09 大全 33 作者:考证青年

树莓派Pi-hole实操安装教程

目录 安装 验证引用

前言

Pi-hole 是一款开源且免费的 DNS 沉洞服务器(DNS ),能够在不安装任何客户端侧软件的前提下为设备提供网络内容屏蔽服务,非常轻量易用。搭配上家中吃灰已久的树莓派,我们就能够轻松打造属于自己的广告屏蔽助手。1

但我们该如何真正的配置它呢?在实操中会出现很多的问题,下面将为大家带来自己的一点操作流程以及体会。

速览

本文主要参考教程为此网站,并在此网站的基础上为大家排个雷。大家可以边看它边操作,出现的问题可以来对照解决。

材料 安装

首先我们需要将树莓派接入路由器,有线或无线均可,然后远程登录到树莓派上:

(现在默认大家已经来到了ssh或者远程连接的位置。 如果在这方面有所疑惑可以查询树莓派的SSH连接和 远程桌面连接树莓派。

方法1(适合在港澳台以及国外的读者)

_树莓派官方系统怎样安装软件_树莓派组装教程

Pi-hole 提供了一键安装脚本

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

当然我们也可以试试,因为这网络啊实在是太太太难成功了……

方法2 (适合中国大陆的读者) 1. 手动编译FTL

sudo apt install build-essential libgmp-dev m4 cmake libidn11-dev libreadline-dev

wget https://ftp.gnu.org/gnu/nettle/nettle-3.6.tar.gz
tar -xzf nettle-3.6.tar.gz
cd nettle-3.6
./configure --libdir=/usr/local/lib
make -j $(nproc)
sudo make install

git clone https://github.com/pi-hole/FTL.git && cd FTL

./build.sh

注意:这里可能会等很长一段时间,不要担心,你的树莓派没有坏掉,只是……慢……

你可以选择:砸掉买台新的 、泡杯茶 、打几把游戏 ,然后等待他慢慢的成功

./build.sh install
sudo service pihole-FTL restart

注:如果一切顺利,此时你应该已经成功下载好了FTL了

2. 下载basic-.sh的脚本文件

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

3. 在脚本文件中,修改()

FTLinstall() {return 0 # 这里是我添加的return代码# Local, named variableslocal latesttaglocal str="Downloading and Installing FTL"printf "  %b %s..." "${INFO}" "${str}"# Move into the temp ftl directorypushd "$(mktemp -d)" > /dev/null || { printf "Unable to make temporary directory for FTL binary download\\n"; return 1; }# Always replace pihole-FTL.serviceinstall -T -m 0755 "${PI_HOLE_LOCAL_REPO}/advanced/Templates/pihole-FTL.service" "/etc/init.d/pihole-FTL"local ftlBranchlocal urlif [[ -f "/etc/pihole/ftlbranch" ]];thenftlBranch=$(</etc/pihole/ftlbranch)elseftlBranch="master"filocal binarybinary="${1}"# Determine which version of FTL to downloadif [[ "${ftlBranch}" == "master" ]];thenurl="https://github.com/pi-hole/ftl/releases/latest/download"elseurl="https://ftl.pi-hole.net/${ftlBranch}"fi# If the download worked,if curl -sSL --fail "${url}/${binary}" -o "${binary}"; then# get sha1 of the binary we just downloaded for verification.curl -sSL --fail "${url}/${binary}.sha1" -o "${binary}.sha1"# If we downloaded binary file (as opposed to text),if sha1sum --status --quiet -c "${binary}".sha1; thenprintf "transferred... "# Before stopping FTL, we download the macvendor databasecurl -sSL "https://ftl.pi-hole.net/macvendor.db" -o "${PI_HOLE_CONFIG_DIR}/macvendor.db" || truechmod 644 "${PI_HOLE_CONFIG_DIR}/macvendor.db"chown pihole:pihole "${PI_HOLE_CONFIG_DIR}/macvendor.db"# Stop pihole-FTL service if availablestop_service pihole-FTL &> /dev/null# Install the new version with the correct permissionsinstall -T -m 0755 "${binary}" /usr/bin/pihole-FTL# Move back into the original directory the user was inpopd > /dev/null || { printf "Unable to return to original directory after FTL binary download.\\n"; return 1; }# Installed the FTL serviceprintf "%b  %b %s\\n" "${OVER}" "${TICK}" "${str}"return 0# Otherwise,else# the download failed, so just go back to the original directorypopd > /dev/null || { printf "Unable to return to original directory after FTL binary download.\\n"; return 1; }printf "%b  %b %s\\n" "${OVER}" "${CROSS}" "${str}"printf "  %bError: Download of %s/%s failed (checksum error)%b\\n" "${COL_LIGHT_RED}" "${url}" "${binary}" "${COL_NC}"return 1fi# Otherwise,elsepopd > /dev/null || { printf "Unable to return to original directory after FTL binary download.\\n"; return 1; }printf "%b  %b %s\\n" "${OVER}" "${CROSS}" "${str}"# The URL could not be foundprintf "  %bError: URL %s/%s not found%b\\n" "${COL_LIGHT_RED}" "${url}" "${binary}" "${COL_NC}"return 1fi
}

sudo bash basic-install.sh

验证

我们输入树莓派ip/admin,可以看到界面就展现在我们眼前了:

引用

基于树莓派的全能广告屏蔽助手 —— Pi-hole ↩︎

关于我们

最火推荐

小编推荐

联系我们


版权声明:本站内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 88@qq.com 举报,一经查实,本站将立刻删除。备案号:桂ICP备2021009421号
Powered By Z-BlogPHP.
复制成功
微信号:
我知道了