mirror of
https://github.com/pi-hole/pi-hole.git
synced 2024-11-15 10:43:55 +00:00
IPTables Whiptal option to install.
Signed-off-by: Dan Schaper <dan.schaper@pi-hole.net>
This commit is contained in:
parent
2981f3cbd1
commit
00b28f0aed
1 changed files with 8 additions and 2 deletions
|
@ -869,20 +869,26 @@ configureFirewall() {
|
||||||
echo "::: Configuring FirewallD for httpd and dnsmasq.."
|
echo "::: Configuring FirewallD for httpd and dnsmasq.."
|
||||||
firewall-cmd --permanent --add-port=80/tcp --add-port=53/tcp --add-port=53/udp
|
firewall-cmd --permanent --add-port=80/tcp --add-port=53/tcp --add-port=53/udp
|
||||||
firewall-cmd --reload
|
firewall-cmd --reload
|
||||||
|
return 0
|
||||||
# Check for proper kernel modules to prevent failure
|
# Check for proper kernel modules to prevent failure
|
||||||
elif modinfo ip_tables &> /dev/null && command -v iptables &> /dev/null; then
|
elif modinfo ip_tables &> /dev/null && command -v iptables &> /dev/null; then
|
||||||
# If chain Policy is not ACCEPT or last Rule is not ACCEPT
|
# If chain Policy is not ACCEPT or last Rule is not ACCEPT
|
||||||
# then check and insert our Rules above the DROP/REJECT Rule.
|
# then check and insert our Rules above the DROP/REJECT Rule.
|
||||||
if iptables -S INPUT | head -n1 | grep -qv '^-P.*ACCEPT$' || iptables -S INPUT | tail -n1 | grep -qv '^-\(A\|P\).*ACCEPT$'; then
|
if iptables -S INPUT | head -n1 | grep -qv '^-P.*ACCEPT$' || iptables -S INPUT | tail -n1 | grep -qv '^-\(A\|P\).*ACCEPT$'; then
|
||||||
|
whiptail --title "Firewall in use" --yesno "We have detected a running firewall\n\nPi-hole currently requires HTTP and DNS port access.\n\n\n\nInstall Pi-hole default firewall rules?" ${r} ${c} || \
|
||||||
|
{ echo -e ":::\n::: Not installing firewall rulesets."; return 1; }
|
||||||
|
echo -e ":::\n::: Installing new IPTables firewall rulesets."
|
||||||
# Check chain first, otherwise a new rule will duplicate old ones
|
# Check chain first, otherwise a new rule will duplicate old ones
|
||||||
echo "::: Configuring iptables for httpd and dnsmasq.."
|
|
||||||
iptables -C INPUT -p tcp -m tcp --dport 80 -j ACCEPT &> /dev/null || iptables -I INPUT 1 -p tcp -m tcp --dport 80 -j ACCEPT
|
iptables -C INPUT -p tcp -m tcp --dport 80 -j ACCEPT &> /dev/null || iptables -I INPUT 1 -p tcp -m tcp --dport 80 -j ACCEPT
|
||||||
iptables -C INPUT -p tcp -m tcp --dport 53 -j ACCEPT &> /dev/null || iptables -I INPUT 1 -p tcp -m tcp --dport 53 -j ACCEPT
|
iptables -C INPUT -p tcp -m tcp --dport 53 -j ACCEPT &> /dev/null || iptables -I INPUT 1 -p tcp -m tcp --dport 53 -j ACCEPT
|
||||||
iptables -C INPUT -p udp -m udp --dport 53 -j ACCEPT &> /dev/null || iptables -I INPUT 1 -p udp -m udp --dport 53 -j ACCEPT
|
iptables -C INPUT -p udp -m udp --dport 53 -j ACCEPT &> /dev/null || iptables -I INPUT 1 -p udp -m udp --dport 53 -j ACCEPT
|
||||||
|
return 0
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "::: No active firewall detected.. skipping firewall configuration."
|
echo -e ":::\n::: No active firewall detected.. skipping firewall configuration."
|
||||||
|
return 0
|
||||||
fi
|
fi
|
||||||
|
echo -e ":::\n::: Skipping firewall configuration."
|
||||||
}
|
}
|
||||||
|
|
||||||
finalExports() {
|
finalExports() {
|
||||||
|
|
Loading…
Reference in a new issue