mirror of
https://github.com/pi-hole/pi-hole.git
synced 2024-11-15 02:42:58 +00:00
Merge pull request #2978 from Mograine/patch-1
Add commands to add/remove custom DNS records
This commit is contained in:
commit
5c6dd3f6f4
2 changed files with 26 additions and 0 deletions
|
@ -19,6 +19,7 @@
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
addn-hosts=/etc/pihole/local.list
|
addn-hosts=/etc/pihole/local.list
|
||||||
|
addn-hosts=/etc/pihole/custom.list
|
||||||
|
|
||||||
domain-needed
|
domain-needed
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@ readonly FTLconf="/etc/pihole/pihole-FTL.conf"
|
||||||
# 03 -> wildcards
|
# 03 -> wildcards
|
||||||
readonly dhcpstaticconfig="/etc/dnsmasq.d/04-pihole-static-dhcp.conf"
|
readonly dhcpstaticconfig="/etc/dnsmasq.d/04-pihole-static-dhcp.conf"
|
||||||
readonly PI_HOLE_BIN_DIR="/usr/local/bin"
|
readonly PI_HOLE_BIN_DIR="/usr/local/bin"
|
||||||
|
readonly dnscustomfile="/etc/pihole/custom.list"
|
||||||
|
|
||||||
readonly gravityDBfile="/etc/pihole/gravity.db"
|
readonly gravityDBfile="/etc/pihole/gravity.db"
|
||||||
|
|
||||||
|
@ -599,6 +600,28 @@ SetPrivacyLevel() {
|
||||||
fi
|
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() {
|
main() {
|
||||||
args=("$@")
|
args=("$@")
|
||||||
|
|
||||||
|
@ -630,6 +653,8 @@ main() {
|
||||||
"audit" ) addAudit "$@";;
|
"audit" ) addAudit "$@";;
|
||||||
"clearaudit" ) clearAudit;;
|
"clearaudit" ) clearAudit;;
|
||||||
"-l" | "privacylevel" ) SetPrivacyLevel;;
|
"-l" | "privacylevel" ) SetPrivacyLevel;;
|
||||||
|
"addcustomdns" ) AddCustomDNSAddress;;
|
||||||
|
"removecustomdns" ) RemoveCustomDNSAddress;;
|
||||||
* ) helpFunc;;
|
* ) helpFunc;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue