树莓派Pi

阅读: 评论:0

树莓派Pi

树莓派Pi

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

目录

  • 树莓派Pi-hole实操安装教程
  • 前言
    • 速览
    • 材料
  • 安装
    • 方法1(适合在港澳台以及国外的读者)
    • 方法2 (适合中国大陆的读者)
      • 1. 手动编译FTL
      • 2. 下载basic-install.sh的脚本文件
      • 3. 在脚本文件中,修改`FTLinstall()`
  • 验证
  • 引用

前言

Pi-hole 是一款开源且免费的 DNS 沉洞服务器(DNS sinkhole),能够在不安装任何客户端侧软件的前提下为设备提供网络内容屏蔽服务,非常轻量易用。搭配上家中吃灰已久的树莓派,我们就能够轻松打造属于自己的广告屏蔽助手。1
但我们该如何真正的配置它呢?在实操中会出现很多的问题,下面将为大家带来自己的一点操作流程以及体会。

速览

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

材料

  • 树莓派3B x 1
  • 笔记本 x 1
  • 家用路由器 x 1

安装

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

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

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

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

curl -sSL  | bash

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

方法2 (适合中国大陆的读者)

  • 首先提升通过修改hosts或者别的什么途径来提高你连接境外服务器的速度。(请读者自行查阅)
  • 做完了第一步后,你会发现……这样下载的网络永远会被FTL给卡断,所以我们查阅Github的官方文档,得到了以下的解决方案:

1. 手动编译FTL

  • Debian / Ubuntu / Raspbian,下载依赖
sudo apt install build-essential libgmp-dev m4 cmake libidn11-dev libreadline-dev
  • 从源文件编译 libnettle
wget .
tar -xzf nettle-3.
cd nettle-3.6
./configure --libdir=/usr/local/lib
make -j $(nproc)
sudo make install
  • Clone FTL
git clone .git && cd FTL
  • 编译 FTL
./build.sh

注意:这里可能会等很长一段时间,不要担心,你的树莓派没有坏掉,只是……慢……
你可以选择:砸掉买台新的泡杯茶打几把游戏 ,然后等待他慢慢的成功

  • 安装 FTL并重启服务
./build.sh install
sudo service pihole-FTL restart

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

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

wget -O basic-install.sh 

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

  • basic-install.sh中,按下ctrl+F,输入FTLinstall(),搜索到该函数,在函数的第一行添加return 0
    如:
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=""elseurl="/${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 &# "# Before stopping FTL, we download the macvendor databasecurl -sSL ".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,可以看到界面就展现在我们眼前了:

引用


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

本文发布于:2024-02-04 05:14:34,感谢您对本站的认可!

本文链接:https://www.4u4v.net/it/170699896752393.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:树莓派   Pi
留言与评论(共有 0 条评论)
   
验证码:

Copyright ©2019-2022 Comsenz Inc.Powered by ©

网站地图1 网站地图2 网站地图3 网站地图4 网站地图5 网站地图6 网站地图7 网站地图8 网站地图9 网站地图10 网站地图11 网站地图12 网站地图13 网站地图14 网站地图15 网站地图16 网站地图17 网站地图18 网站地图19 网站地图20 网站地图21 网站地图22/a> 网站地图23