for desiredInterface in ${chooseInterfaceOptions};do
piholeInterface=${desiredInterface}
echo"::: Using interface: $piholeInterface"
PIHOLE_INTERFACE=${desiredInterface}
echo"::: Using interface: $PIHOLE_INTERFACE"
done
else
echo"::: Cancel selected, exiting...."
@ -280,8 +286,8 @@ chooseInterface() {
useIPv6dialog(){
# Show the IPv6 address used for blocking
IPv6_address=$(ip -6 route get 2001:4860:4860::8888 | awk -F " "'{ for(i=1;i<=NF;i++) if ($i == "src") print $(i+1) }')
whiptail --msgbox --backtitle "IPv6..." --title "IPv6 Supported""$IPv6_address will be used to block ads."${r}${c}
IPV6_ADDRESS=$(ip -6 route get 2001:4860:4860::8888 | awk -F " "'{ for(i=1;i<=NF;i++) if ($i == "src") print $(i+1) }')
whiptail --msgbox --backtitle "IPv6..." --title "IPv6 Supported""$IPV6_ADDRESS will be used to block ads."${r}${c}
}
@ -309,8 +315,8 @@ use4andor6() {
if[[${useIPv6}]];then
useIPv6dialog
fi
echo"::: IPv4 address: ${IPv4_address}"
echo"::: IPv6 address: ${IPv6_address}"
echo"::: IPv4 address: ${IPV4_ADDRESS}"
echo"::: IPv6 address: ${IPV6_ADDRESS}"
if[ ! ${useIPv4}]&&[ ! ${useIPv6}];then
echo"::: Cannot continue, neither IPv4 or IPv6 selected"
echo"::: Exiting"
@ -325,7 +331,7 @@ use4andor6() {
getStaticIPv4Settings(){
# Ask if the user wants to use DHCP settings as their static IP
if(whiptail --backtitle "Calibrating network interface" --title "Static IP Address" --yesno "Do you want to use your current network settings as a static address?
IP address: ${IPv4_address}
IP address: ${IPV4_ADDRESS}
Gateway: ${IPv4gw}"${r}${c}); then
# If they choose yes, let the user know that the IP address will not be available via DHCP and may cause a conflict.
whiptail --msgbox --backtitle "IP information" --title "FYI: IP Conflict""It is possible your router could still try to assign this IP to a device, which would cause a conflict. But in most cases the router is smart enough to not do that.
@ -338,16 +344,16 @@ It is also possible to use a DHCP reservation, but if you are going to do that,
# Start a loop to let the user enter their information with the chance to go back and edit it if necessary
ip addr replace dev "${piholeInterface}""${IPv4_address}"
ip addr replace dev "${PIHOLE_INTERFACE}""${IPV4_ADDRESS}"
if[ -x "$(command -v nmcli)"];then
# Tell NetworkManager to read our new sysconfig file
nmcli con load "${IFCFG_FILE}" > /dev/null
fi
echo":::"
echo"::: Setting IP to ${IPv4_address}. You may need to restart after the install is complete."
echo"::: Setting IP to ${IPV4_ADDRESS}. You may need to restart after the install is complete."
echo":::"
fi
else
@ -462,70 +468,70 @@ setDNS() {
case${DNSchoices} in
Google)
echo"::: Using Google DNS servers."
piholeDNS1="8.8.8.8"
piholeDNS2="8.8.4.4"
PIHOLE_DNS_1="8.8.8.8"
PIHOLE_DNS_2="8.8.4.4"
;;
OpenDNS)
echo"::: Using OpenDNS servers."
piholeDNS1="208.67.222.222"
piholeDNS2="208.67.220.220"
PIHOLE_DNS_1="208.67.222.222"
PIHOLE_DNS_2="208.67.220.220"
;;
Level3)
echo"::: Using Level3 servers."
piholeDNS1="4.2.2.1"
piholeDNS2="4.2.2.2"
PIHOLE_DNS_1="4.2.2.1"
PIHOLE_DNS_2="4.2.2.2"
;;
Norton)
echo"::: Using Norton ConnectSafe servers."
piholeDNS1="199.85.126.10"
piholeDNS2="199.85.127.10"
PIHOLE_DNS_1="199.85.126.10"
PIHOLE_DNS_2="199.85.127.10"
;;
Comodo)
echo"::: Using Comodo Secure servers."
piholeDNS1="8.26.56.26"
piholeDNS2="8.20.247.20"
PIHOLE_DNS_1="8.26.56.26"
PIHOLE_DNS_2="8.20.247.20"
;;
Custom)
until[[${DNSSettingsCorrect}= True ]];do
strInvalid="Invalid"
if[ ! ${piholeDNS1}];then
if[ ! ${piholeDNS2}];then
if[ ! ${PIHOLE_DNS_1}];then
if[ ! ${PIHOLE_DNS_2}];then
prePopulate=""
else
prePopulate=", ${piholeDNS2}"
prePopulate=", ${PIHOLE_DNS_2}"
fi
elif[${piholeDNS1}]&&[ ! ${piholeDNS2}];then
prePopulate="${piholeDNS1}"
elif[${piholeDNS1}]&&[${piholeDNS2}];then
prePopulate="${piholeDNS1}, ${piholeDNS2}"
elif[${PIHOLE_DNS_1}]&&[ ! ${PIHOLE_DNS_2}];then
prePopulate="${PIHOLE_DNS_1}"
elif[${PIHOLE_DNS_1}]&&[${PIHOLE_DNS_2}];then
prePopulate="${PIHOLE_DNS_1}, ${PIHOLE_DNS_2}"
fi
piholeDNS=$(whiptail --backtitle "Specify Upstream DNS Provider(s)" --inputbox "Enter your desired upstream DNS provider(s), seperated by a comma.\n\nFor example '8.8.8.8, 8.8.4.4'"${r}${c}"${prePopulate}" 3>&1 1>&2 2>&3)
if[[$?=0]];then
piholeDNS1=$(echo"${piholeDNS}"| sed 's/[, \t]\+/,/g'| awk -F, '{print$1}')
piholeDNS2=$(echo"${piholeDNS}"| sed 's/[, \t]\+/,/g'| awk -F, '{print$2}')
if ! valid_ip "${piholeDNS1}"||[ ! "${piholeDNS1}"];then
piholeDNS1=${strInvalid}
PIHOLE_DNS_1=$(echo"${piholeDNS}"| sed 's/[, \t]\+/,/g'| awk -F, '{print$1}')
PIHOLE_DNS_2=$(echo"${piholeDNS}"| sed 's/[, \t]\+/,/g'| awk -F, '{print$2}')
if ! valid_ip "${PIHOLE_DNS_1}"||[ ! "${PIHOLE_DNS_1}"];then
PIHOLE_DNS_1=${strInvalid}
fi
if ! valid_ip "${piholeDNS2}"&&["${piholeDNS2}"];then
piholeDNS2=${strInvalid}
if ! valid_ip "${PIHOLE_DNS_2}"&&["${PIHOLE_DNS_2}"];then
whiptail --msgbox --backtitle "Invalid IP" --title "Invalid IP""One or both entered IP addresses were invalid. Please try again.\n\n DNS Server 1: $piholeDNS1\n DNS Server 2: ${piholeDNS2}"${r}${c}
whiptail --msgbox --backtitle "Invalid IP" --title "Invalid IP""One or both entered IP addresses were invalid. Please try again.\n\n DNS Server 1: $PIHOLE_DNS_1\n DNS Server 2: ${PIHOLE_DNS_2}"${r}${c}
if[[${PIHOLE_DNS_1}=="${strInvalid}"]];then
PIHOLE_DNS_1=""
fi
if[[${piholeDNS2}=="${strInvalid}"]];then
piholeDNS2=""
if[[${PIHOLE_DNS_2}=="${strInvalid}"]];then
PIHOLE_DNS_2=""
fi
DNSSettingsCorrect=False
else
if(whiptail --backtitle "Specify Upstream DNS Provider(s)" --title "Upstream DNS Provider(s)" --yesno "Are these settings correct?\n DNS Server 1: $piholeDNS1\n DNS Server 2: ${piholeDNS2}"${r}${c});then
if(whiptail --backtitle "Specify Upstream DNS Provider(s)" --title "Upstream DNS Provider(s)" --yesno "Are these settings correct?\n DNS Server 1: $PIHOLE_DNS_1\n DNS Server 2: ${PIHOLE_DNS_2}"${r}${c});then
DNSSettingsCorrect=True
else
# If the settings are wrong, the loop continues
@ -541,6 +547,28 @@ setDNS() {
fi
}
setLogging(){
local LogToggleCommand
local LogChooseOptions
local LogChoices
LogToggleCommand=(whiptail --separate-output --radiolist "Do you want to log queries?\n (Disabling will render graphs on the Admin page useless):"${r}${c} 6)