Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/pi-hole/pi-hole.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDL6ER <DL6ER@users.noreply.github.com>2019-11-29 15:25:09 +0300
committerGitHub <noreply@github.com>2019-11-29 15:25:09 +0300
commit5c6dd3f6f4660bda116aae971128c6fb7c5e239d (patch)
treeeb93635845e5be2c652d470f20051a5902d5c6a3 /advanced
parent9248c92b5cc53926b24febec7f6d13906e5402ea (diff)
parentc809c34024ac302e11ba90761526d2c57a006f45 (diff)
Merge pull request #2978 from Mograine/patch-1
Add commands to add/remove custom DNS records
Diffstat (limited to 'advanced')
-rw-r--r--advanced/01-pihole.conf1
-rwxr-xr-xadvanced/Scripts/webpage.sh25
2 files changed, 26 insertions, 0 deletions
diff --git a/advanced/01-pihole.conf b/advanced/01-pihole.conf
index cd74e186..2c8b3749 100644
--- a/advanced/01-pihole.conf
+++ b/advanced/01-pihole.conf
@@ -19,6 +19,7 @@
###############################################################################
addn-hosts=/etc/pihole/local.list
+addn-hosts=/etc/pihole/custom.list
domain-needed
diff --git a/advanced/Scripts/webpage.sh b/advanced/Scripts/webpage.sh
index 7bbdabdf..829ba57b 100755
--- a/advanced/Scripts/webpage.sh
+++ b/advanced/Scripts/webpage.sh
@@ -17,6 +17,7 @@ readonly FTLconf="/etc/pihole/pihole-FTL.conf"
# 03 -> wildcards
readonly dhcpstaticconfig="/etc/dnsmasq.d/04-pihole-static-dhcp.conf"
readonly PI_HOLE_BIN_DIR="/usr/local/bin"
+readonly dnscustomfile="/etc/pihole/custom.list"
readonly gravityDBfile="/etc/pihole/gravity.db"
@@ -599,6 +600,28 @@ SetPrivacyLevel() {
fi
}
+AddCustomDNSAddress() {
+ echo -e " ${TICK} Adding custom DNS entry..."
+
+ ip="${args[2]}"
+ host="${args[3]}"
+ echo "${ip} ${host}" >> "${dnscustomfile}"
+
+ # Restart dnsmasq to load new custom DNS entries
+ RestartDNS
+}
+
+RemoveCustomDNSAddress() {
+ echo -e " ${TICK} Removing custom DNS entry..."
+
+ ip="${args[2]}"
+ host="${args[3]}"
+ sed -i "/${ip} ${host}/d" "${dnscustomfile}"
+
+ # Restart dnsmasq to update removed custom DNS entries
+ RestartDNS
+}
+
main() {
args=("$@")
@@ -630,6 +653,8 @@ main() {
"audit" ) addAudit "$@";;
"clearaudit" ) clearAudit;;
"-l" | "privacylevel" ) SetPrivacyLevel;;
+ "addcustomdns" ) AddCustomDNSAddress;;
+ "removecustomdns" ) RemoveCustomDNSAddress;;
* ) helpFunc;;
esac