Issue with iptables rules

Hi,

I already created a topic in the german subforum, but I cannot find my post anywhere, not in my profile, not in the topic list (You have no activity yet.), so cannot delete it. So just creating an additional one here.

I've set up pi-hole and configured iptables as described here Why Some Pages Load Slow When Using Pi-hole And How To Fix It (for versions < v4.0) - Pi-hole

But portscan from other pi shows:

Why are the ports filtered, not closed? What is wrong with my config?

Raspberry Pi 3B+
DietPi v6.31.2
Debian 10

closed = not filtered and not listening
filtered = rejected/dropped by fw, regardless of listen state

BTW, global permissive INPUT is not very useful. A good practice is to drop incoming by default while a) allowing only necessary services and b) maintaining states (WARNING: use with understanding, otherwise you'll be disconnected):

...
# drop all incoming
iptables -P INPUT DROP
# allow necessary ports
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
iptables -A INPUT -p tcp --dport 53 -j ACCEPT
iptables -A INPUT -p udp --dport 53 -j ACCEPT
iptables -A INPUT -p tcp -m multiport --dport 80,443 -j ACCEPT
# allow all on lo if
iptables -A INPUT -i lo -j ACCEPT
# do not disconnect current and accept response from outgoing connections
iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
...

It is only accessible from my local network, why would I need to use a DROP policy?

I got the configuration from here Why Some Pages Load Slow When Using Pi-hole And How To Fix It (for versions < v4.0) - Pi-hole

And here it says

This is the case for me. So something is wrong with my rules, right?

It is only accessible from my local network, why would I need to use a DROP policy?

Local address space does not necessary mean safe. Malicious script in browser can query sites on local network or untrusted program could inspect the network (Steam is doing this for example, and it's known to contain exploits.). Sure, your wifi with untrusted devices and applications is also on the same address space.

As of v4.0, this should no longer be a problem unless you choose to deviate from the new default blocking mode 949 and return to the IP-based mode 154. And the iptables rules mentioned in this article should not be needed.

So your problem is not there most likely. What's happening exactly? What's the environment? Is this a clean install? Try other blocking modes as well.

Yes, this is a clean install. Installed DietPi OS, Unbound, Pi-Hole. Nothing else is running on that Pi.

Just replaced my Pi2 with a Pi3 after my SD card got corrupt.

Everything was fine before, but now when browsing webites, my browser is often stuck with "Looking up..." for seconds which did not happen before.

With full IP blocking, I need a webserver which answers the requests and displays a blocking page. This is not what I want. I just want performance.

I suggest you to try NODATA.

Does not make any difference.

I am experiencing issues resolving already known, not blocked domains. Browser says "Looking up..." for seconds before loading the page.

I have set

and

In my Unbound config.

But that does not seem to help.

Is this an issue with Pi-Hole or Unbound? Any idea?

And still the question: Why are my ports filtered, not closed?

pi@ph5:~ $ man nmap
[..]
       The output from Nmap is a list of scanned targets, with
       supplemental information on each depending on the options used.
       Key among that information is the “interesting ports table”.
       That table lists the port number and protocol, service name,
       and state. The state is either open, filtered, closed, or
       unfiltered.  Open means that an application on the target
       machine is listening for connections/packets on that port.
       Filtered means that a firewall, filter, or other network
       obstacle is blocking the port so that Nmap cannot tell whether
       it is open or closed.  Closed ports have no application
       listening on them, though they could open up at any time. Ports
       are classified as unfiltered when they are responsive to Nmap's
       probes, but Nmap cannot determine whether they are open or
       closed. Nmap reports the state combinations open|filtered and
       closed|filtered when it cannot determine which of the two
       states describe a port. The port table may also include
       software version details when version detection has been
       requested. When an IP protocol scan is requested (-sO), Nmap
       provides information on supported IP protocols rather than
       listening ports.

To see who is "listening":

sudo netstat -nltup

sudo ss -nltup

sudo lsof -i

EDIT:typo

Those won't be affected by iptables rules for ports 80 and 443 on your RPi at all.
It is only with a blocked domain and a blocking mode that involves Pi-hole's blocking page that those rules would kick in.

The blocking page itself will work for HTTP only, so why not consider switching to Pi-hole's default NULL blocking mode?
iptables for 80/443 would be completely obsolete then.

I am using NULL blocking mode. I used to using it and I am doing it right now. I just switched to NODATA for a few hours as nobody suggested.

I was just referring to the hint on Why Some Pages Load Slow When Using Pi-hole And How To Fix It (for versions < v4.0) - Pi-hole

That's why I am seeking for help here.

As explained, iptables rules won't do anything for you in that case.
We'd be hunting a ghost trying to fix why nmap does not respond as expected then.

If your issue is indeed independent from iptables, consider renaming it or open a new topic where you describe your actual problem.

Note that the link you reference is " FOR VERSIONS < V4.0"

Yeah better create new post stating the issue as this doesnt seem iptables related.

What leads you to believe you have an ipTables problem? Is Pi-hole not operating properly? If not, what Pi-hole problem are you experiencing?

Answers are in this thread.

Ok, I will create a new thread. Thanks for your help and explanations.

Dont forget creating debug token and post here.
Keep in mind the (default) NULL blocking mode is still preferred one.
Clients will query ad domains and they get 0.0.0.0 returned.
No errors or timeouts.

EDIT: sorry mistake

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.