Detect and Block Port Scanners setting blocking outbound

Post new topic   Reply to topic    DD-WRT Forum Index -> General Questions
Author Message
falk0069
DD-WRT Novice


Joined: 08 Dec 2013
Posts: 7

PostPosted: Sat Apr 12, 2025 20:50    Post subject: Detect and Block Port Scanners setting blocking outbound Reply with quote
I noticed that enabling "Detect and Block Port Scanners" in the Security Firewall sections adds these lines to iptables:

Code:
-A INPUT -i vlan2 -m psd --psd-weight-threshold 15 --psd-delay-threshold 300 --psd-lo-ports-weight 3 --psd-hi-ports-weight 3  -j DROP
-A FORWARD -i vlan2 -m psd --psd-weight-threshold 15 --psd-delay-threshold 300 --psd-lo-ports-weight 3 --psd-hi-ports-weight 3  -j DROP


And after little time the FORWARD lines starts incrementing (with iptables -v -L -n) and all my DNS queries to 8.8.8.8 start to fail. I can switch DNS servers and it starts to work again, but that isn't a workable option.

I also wonder if this isn't caused by frustrated port-scanners/hackers and are spoofing with common DNS IPs to get this rule to trigger.

In any case, I feel like this is a bug and LAN traffic should not be impacted by a rule meant to block WAN traffic. Thoughts?
Sponsor
kernel-panic69
DD-WRT Guru


Joined: 08 May 2018
Posts: 15923
Location: Texas, USA

PostPosted: Sat Apr 12, 2025 20:55    Post subject: Reply with quote
Is this on the current release? Also, why would you use only one DNS server?
_________________
"Life is but a fleeting moment, a vapor that vanishes quickly; All is vanity"
Contribute To DD-WRT
Pogo - A minimal level of ability is expected and needed...
RSS feed for DD-WRT releases (2025)
RSS feed for DD-WRT releases (2024)
RSS feed for DD-WRT releases (2023)

----------------------
Linux User #377467 counter.li.org / linuxcounter.net
falk0069
DD-WRT Novice


Joined: 08 Dec 2013
Posts: 7

PostPosted: Sun Apr 13, 2025 16:57    Post subject: Reply with quote
kernel-panic69 wrote:
Is this on the current release? Also, why would you use only one DNS server?


Yes, the most recent version as of 3 days ago: v3.0-r60662 std (04/10/25)

Technically I use pi-hole as my LAN's DNS server but it in turn goes out and hits the Google DNS servers (8.8.8.8 and 8.8.4.4). I can change the DNS servers and add more, but if the first (primary) DNS address is blocked, it really slows down all Internet browsing.

I feel like the iptables rule that is used should be modified to avoid this problem. Perhaps it is just a UDP/DNS issue if you don't use dd-wrt as your LAN's DNS service?
kernel-panic69
DD-WRT Guru


Joined: 08 May 2018
Posts: 15923
Location: Texas, USA

PostPosted: Sun Apr 13, 2025 17:27    Post subject: Reply with quote
If you don't need the firewall option, don't enable it...
_________________
"Life is but a fleeting moment, a vapor that vanishes quickly; All is vanity"
Contribute To DD-WRT
Pogo - A minimal level of ability is expected and needed...
RSS feed for DD-WRT releases (2025)
RSS feed for DD-WRT releases (2024)
RSS feed for DD-WRT releases (2023)

----------------------
Linux User #377467 counter.li.org / linuxcounter.net
ho1Aetoo
DD-WRT Guru


Joined: 19 Feb 2019
Posts: 3571
Location: Germany

PostPosted: Sun Apr 13, 2025 18:34    Post subject: Reply with quote
I have connected smartdns as a DoH proxy upstream of the Pi-hole.
No problems with any UDP stuff

(and it's encrypted and secure)

Edit:

with a current debian installation

Code:
sudo apt install smartdns


then copy the following configuration file to /etc/smartdns/smartdns.conf

Code:
bind :6053
prefetch-domain yes
serve-expired yes
log-size 1M
log-num 1
log-level info
log-file /tmp/smartdns.log
ca-file /etc/ssl/certs/ca-certificates.crt
ca-path /etc/certs/ssl
server-https https://8.8.8.8/dns-query -host-name dns.google.com -tls-host-verify dns.google.com
server-https https://8.8.4.4/dns-query -host-name dns.google.com -tls-host-verify dns.google.com



if your Pi-Hole has no RTC then a bootstrap dns server can help...

Code:
bind :6053
prefetch-domain yes
serve-expired yes
log-size 1M
log-num 1
log-level info
log-file /tmp/smartdns.log
ca-file /etc/ssl/certs/ca-certificates.crt
ca-path /etc/certs/ssl
server 8.8.8.8 -bootstrap-dns
server 8.8.8.8 -group time -exclude-default-group
nameserver /...../time
server-https https://8.8.8.8/dns-query -host-name dns.google.com -tls-host-verify dns.google.com
server-https https://8.8.4.4/dns-query -host-name dns.google.com -tls-host-verify dns.google.com


Quote:
nameserver /URL of the NTP SERVER/time


restart smartdns

Code:
sudo service smartdns restart


enter the following as custom DNS server in the Pi-Hole

Code:
127.0.0.1#6053


take a look at the log

Code:
sudo cat /tmp/smartdns.log


See also

https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=323896&start=0

_________________
Quickstart guides:
use Pi-Hole as simple DNS-Server with DD-WRT
VLAN configuration via GUI - 1 CPU port
VLAN configuration via GUI - 2 CPU ports (R7800, EA8500 etc)

Routers
Marvell OCTEON TX2 - QHora-322 - OpenWrt 24.10.1 - Gateway
Qualcomm IPQ8065 - R7800 - DD-WRT - WAP
falk0069
DD-WRT Novice


Joined: 08 Dec 2013
Posts: 7

PostPosted: Mon Apr 14, 2025 1:12    Post subject: Reply with quote
@ho1Aetoo thanks for the smartdns option but I'm not completely following. I just want to turn on the port scanners blocking feature without my internal DNS server (pi-hole) getting blocked when it reaches out to external DNS services. Or it might in the DNS-response coming back that gets blocked--I'm not really sure. Is your pi-hole on the WAN side of dd-wrt? Mine has to be in the LAN side. So it is going to have to make many 53/UDP calls to DNS IPs. Or 443/TCP if DoH is used, but I have not really looked into that much.

I just don't really get why a DNS service using a single port would get flagged as a port scan with the iptables psd option. I might try my local ISP's DNS service and see if that gets blocked. I have this suspicion that port-scanners spoof common DNS IPs to cause this problem.
kernel-panic69
DD-WRT Guru


Joined: 08 May 2018
Posts: 15923
Location: Texas, USA

PostPosted: Mon Apr 14, 2025 2:27    Post subject: Reply with quote
This could also be possibly due to the new firewall feature bug that will be fixed in the next release:

https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=338451

https://svn.dd-wrt.com/changeset/60612
https://svn.dd-wrt.com/changeset/60664
https://svn.dd-wrt.com/changeset/60678
https://svn.dd-wrt.com/changeset/60679

_________________
"Life is but a fleeting moment, a vapor that vanishes quickly; All is vanity"
Contribute To DD-WRT
Pogo - A minimal level of ability is expected and needed...
RSS feed for DD-WRT releases (2025)
RSS feed for DD-WRT releases (2024)
RSS feed for DD-WRT releases (2023)

----------------------
Linux User #377467 counter.li.org / linuxcounter.net
ho1Aetoo
DD-WRT Guru


Joined: 19 Feb 2019
Posts: 3571
Location: Germany

PostPosted: Mon Apr 14, 2025 7:28    Post subject: Reply with quote
@falk0069

as KP has already written, this is probably a bug
i posted this because DoH is by far the better solution compared to plain DNS

_________________
Quickstart guides:
use Pi-Hole as simple DNS-Server with DD-WRT
VLAN configuration via GUI - 1 CPU port
VLAN configuration via GUI - 2 CPU ports (R7800, EA8500 etc)

Routers
Marvell OCTEON TX2 - QHora-322 - OpenWrt 24.10.1 - Gateway
Qualcomm IPQ8065 - R7800 - DD-WRT - WAP
falk0069
DD-WRT Novice


Joined: 08 Dec 2013
Posts: 7

PostPosted: Thu Apr 17, 2025 1:07    Post subject: Reply with quote
Thanks everyone. That bug is kind of related. It seems to do with the TCP-SYN Flood flag not being able to be disable which is something I did try to see if my DNS calls would stop getting tarpitted. I saw the same behavior of it not being disabled and figured it just wasn't meant to be disabled Smile .

In that thread, though, it said that the "Detect and Block Port Scanners" and "Slowdown connection attempts (Tarpit)" really shouldn't be enabled unless you want to mess with attackers. Having them enabled is going to make it appear your ports are open and might cause attackers to hit you harder. So, I guess I'm better off not having those settings enable which has been working much better for me.

https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=338452&start=10
Display posts from previous:    Page 1 of 1
Post new topic   Reply to topic    DD-WRT Forum Index -> General Questions All times are GMT

Navigation

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum