mirror of
https://github.com/pi-hole/pi-hole
synced 2024-11-18 06:08:21 +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
@ -869,20 +869,26 @@ configureFirewall() {
|
||||
echo "::: Configuring FirewallD for httpd and dnsmasq.."
|
||||
firewall-cmd --permanent --add-port=80/tcp --add-port=53/tcp --add-port=53/udp
|
||||
firewall-cmd --reload
|
||||
return 0
|
||||
# Check for proper kernel modules to prevent failure
|
||||
elif modinfo ip_tables &> /dev/null && command -v iptables &> /dev/null; then
|
||||
# If chain Policy is not ACCEPT or last Rule is not ACCEPT
|
||||
# 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
|
||||
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
|
||||
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 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
|
||||
return 0
|
||||
fi
|
||||
else
|
||||
echo "::: No active firewall detected.. skipping firewall configuration."
|
||||
echo -e ":::\n::: No active firewall detected.. skipping firewall configuration."
|
||||
return 0
|
||||
fi
|
||||
echo -e ":::\n::: Skipping firewall configuration."
|
||||
}
|
||||
|
||||
finalExports() {
|
||||
|
Loading…
Reference in New Issue
Block a user