mirror of
https://github.com/pi-hole/pi-hole.git
synced 2024-11-15 02:42:58 +00:00
Ditching the use of the loopback
Pushing files so they are available when the new article gets posted. If the Pi's loopback is set in the hosts file, clients using it as a DNS server will try to connect to their own loopback, which does not have a Web server. So the real IP of the Pi is used. It is recommended to use a static IP since this will be acting as a server. Made one small change from some hard coded values to a variable.
This commit is contained in:
parent
c563841714
commit
01ac3c1dd3
1 changed files with 8 additions and 4 deletions
12
gravity.sh
12
gravity.sh
|
@ -2,6 +2,9 @@
|
||||||
# http://pi-hole.net
|
# http://pi-hole.net
|
||||||
# Compiles a list of ad-serving domains by downloading them from multiple sources
|
# Compiles a list of ad-serving domains by downloading them from multiple sources
|
||||||
|
|
||||||
|
# This script should only be run after you have a static IP address set on the Pi
|
||||||
|
piholeIP=$(hostname -I)
|
||||||
|
|
||||||
# Ad-list sources--one per line in single quotes
|
# Ad-list sources--one per line in single quotes
|
||||||
sources=('https://adaway.org/hosts.txt'
|
sources=('https://adaway.org/hosts.txt'
|
||||||
'http://adblock.gjtech.net/?format=unix-hosts'
|
'http://adblock.gjtech.net/?format=unix-hosts'
|
||||||
|
@ -31,11 +34,11 @@ latentWhitelist=$origin/latentWhitelist.txt
|
||||||
echo "** Neutrino emissions detected..."
|
echo "** Neutrino emissions detected..."
|
||||||
|
|
||||||
# Create the pihole resource directory if it doesn't exist. Future files will be stored here
|
# Create the pihole resource directory if it doesn't exist. Future files will be stored here
|
||||||
if [[ -d /etc/pihole/ ]];then
|
if [[ -d $piholeDir ]];then
|
||||||
:
|
:
|
||||||
else
|
else
|
||||||
echo "** Creating pihole directory..."
|
echo "** Creating pihole directory..."
|
||||||
sudo mkdir /etc/pihole
|
sudo mkdir $piholeDir
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Loop through domain list. Download each one and remove commented lines (lines beginning with '# 'or '/') and blank lines
|
# Loop through domain list. Download each one and remove commented lines (lines beginning with '# 'or '/') and blank lines
|
||||||
|
@ -92,13 +95,14 @@ function gravity_advanced()
|
||||||
cat $origin/$supernova | sort | uniq > $origin/$eventHorizon
|
cat $origin/$supernova | sort | uniq > $origin/$eventHorizon
|
||||||
numberOf=$(cat $origin/$eventHorizon | wc -l | sed 's/^[ \t]*//')
|
numberOf=$(cat $origin/$eventHorizon | wc -l | sed 's/^[ \t]*//')
|
||||||
echo "** $numberOf unique domains trapped in the event horizon."
|
echo "** $numberOf unique domains trapped in the event horizon."
|
||||||
# Format domain list as "127.0.0.1 domain.com"
|
# Format domain list as "192.168.x.x domain.com"
|
||||||
echo "** Formatting domains into a HOSTS file..."
|
echo "** Formatting domains into a HOSTS file..."
|
||||||
cat $origin/$eventHorizon | awk '{sub(/\r$/,""); print "127.0.0.1 "$0"\n::1 "$0}' > $origin/$accretionDisc
|
cat $origin/$eventHorizon | awk '{sub(/\r$/,""); print "'"$piholeIP"'" $0}' > $origin/$accretionDisc
|
||||||
# Put the default host entries at the top of the file
|
# Put the default host entries at the top of the file
|
||||||
echo "::1 localhost" | cat - $origin/$accretionDisc > $origin/latent.$accretionDisc && mv $origin/latent.$accretionDisc $origin/$accretionDisc
|
echo "::1 localhost" | cat - $origin/$accretionDisc > $origin/latent.$accretionDisc && mv $origin/latent.$accretionDisc $origin/$accretionDisc
|
||||||
echo "255.255.255.255 broadcasthost" | cat - $origin/$accretionDisc > $origin/latent.$accretionDisc && mv $origin/latent.$accretionDisc $origin/$accretionDisc
|
echo "255.255.255.255 broadcasthost" | cat - $origin/$accretionDisc > $origin/latent.$accretionDisc && mv $origin/latent.$accretionDisc $origin/$accretionDisc
|
||||||
echo "127.0.0.1 localhost" | cat - $origin/$accretionDisc > $origin/latent.$accretionDisc && mv $origin/latent.$accretionDisc $origin/$accretionDisc
|
echo "127.0.0.1 localhost" | cat - $origin/$accretionDisc > $origin/latent.$accretionDisc && mv $origin/latent.$accretionDisc $origin/$accretionDisc
|
||||||
|
echo "127.0.0.1 raspberrypi" | cat - $origin/$accretionDisc > $origin/latent.$accretionDisc && mv $origin/latent.$accretionDisc $origin/$accretionDisc
|
||||||
# Copy the file so dnsmasq can use it
|
# Copy the file so dnsmasq can use it
|
||||||
sudo cp $origin/$accretionDisc $adList
|
sudo cp $origin/$accretionDisc $adList
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue