Am I Getting Attacked
Am I Getting Attacked?
Introduction
The moment every system administrator dreads: you’re reviewing logs and discover a flood of blocked connection attempts. Your firewall shows hundreds of banned IP addresses, predominantly from foreign networks. Meanwhile, your web-facing services become intermittently unavailable. Sound familiar?
This scenario reflects a universal truth in modern internet operations: every public IPv4 address is under constant scanning and attack attempts. As highlighted in a recent Reddit discussion, users of self-hosted services like OPNsense firewalls and TrueNAS/NextCloud installations frequently observe these patterns:
“I noticed a bunch of bans on my OPNsense router CrowdSec logs - just a flood of blocked port scans originating from Brazil. Every time this happens, my TrueNAS/Nextcloud (web-facing) service goes down.”
For DevOps engineers and homelab enthusiasts, understanding these events is critical. This guide examines:
- Why public-facing infrastructure constantly attracts malicious traffic
- How to distinguish between normal background noise and targeted attacks
- Advanced mitigation strategies beyond basic geo-blocking
- Architectural patterns for maintaining service availability during scans
We’ll analyze real-world attack patterns, dissect why simple WAF rules sometimes fail, and implement enterprise-grade protections in homelab environments.
Understanding Internet Background Radiation
The Constant Scanning Reality
Every public IPv4 address receives:
- 10-50 unauthorized connection attempts per minute
- Scanning from botnets covering 100+ countries
- Exploit attempts for known vulnerabilities (Log4j, ProxyShell, etc.)
According to Cloudflare’s network analysis, over 45% of internet traffic exhibits malicious characteristics.
Why Services Fail During Scans
Three primary failure mechanisms occur during scanning events:
- Resource Exhaustion:
- State table overload in firewalls
- Web server worker saturation
- Bandwidth consumption
- False Positives:
- Overly aggressive blocking rules
- GeoIP database inaccuracies
- Collateral Damage:
- Legitimate traffic blocked alongside malicious
- DNS/DHCP services impacted by firewall load
Geo-Blocking Limitations
The original poster attempted:
1
2
# Basic OPNsense geo-blocking rule
pass in quick on $WAN proto { tcp udp } from { US } to { $SERVER } port { 80,443 }
Why this fails:
- Attackers use cloud proxies in allowed regions
- IPv6 traffic bypasses IPv4 geo-filters
- Scans originate from compromised US systems
Prerequisites for Effective Protection
Infrastructure Requirements
Component | Minimum Specs | Recommended |
---|---|---|
Firewall/Router | 2-core CPU, 2GB RAM | 4-core CPU, 4GB RAM |
Web Server | 4GB RAM | 8GB RAM + SSD |
Network Bandwidth | 100Mbps | 1Gbps with QoS |
Critical Software Components
- Firewall: OPNsense 23.7+ or pfSense CE 2.7+
- Intrusion Prevention: CrowdSec 1.5.x or Suricata 6.0.12+
- Web Application Firewall: ModSecurity 3.0.8 with OWASP CRS 3.3.4
Security Foundations
Before implementing advanced protections:
- Confirm all services are patched to latest versions
- Verify SSH/RDP exposed only via VPN or tailscale
- Implement certificate-based authentication
- Establish complete offline backups
Installation & Configuration Walkthrough
OPNsense CrowdSec Deployment
- Install CrowdSec plugin:
1 2
opnsense-code tools ports cd /usr/ports/security/crowdsec && make install clean
- Configure acquisition for firewall logs:
1 2 3 4 5
# /usr/local/etc/crowdsec/acquis.yaml filenames: - /var/log/filter.log labels: type: opnsense
- Enable bouncers for automatic blocking:
1 2 3
pkg install crowdsec-firewall-bouncer sysrc crowdsec_firewall_enable="YES" service crowdsec_firewall start
Advanced Geo-Blocking Implementation
Overcome basic geo-filter limitations with:
1
2
3
4
5
6
7
8
9
10
11
12
13
# /usr/local/etc/OPNsense.xml excerpt
<rule>
<description>Strict GeoIP Filter</description>
<source>
<address>!US</address>
<address>::/0</address> <!-- Block all IPv6 -->
</source>
<destination>
<network>wanip</network>
</destination>
<target>block</target>
<protocol>any</protocol>
</rule>
Key improvements:
- Explicit IPv6 blocking (scanners increasingly use IPv6)
- Inverted logic: block all non-US instead of allowing US
- Applies to all destination ports
TrueNAS SCALE Hardening
Mitigate NextCloud outages during attacks:
- Configure resource limits:
1 2 3 4
# /etc/systemd/system/nextcloud.service.d/limits.conf [Service] LimitNOFILE=65535 LimitNPROC=4096
- Implement adaptive rate limiting:
1 2 3 4 5 6 7 8 9
# /usr/local/etc/nginx/nginx.conf http { limit_req_zone $binary_remote_addr zone=nextcloud:10m rate=30r/m; server { location / { limit_req zone=nextcloud burst=50 nodelay; } } }
Operational Optimization
Performance Tuning for High Scan Volumes
Adjust OPNsense kernel parameters:
1
2
3
4
# /boot/loader.conf
kern.ipc.maxsockets=2000000
net.inet.ip.portrange.first=1024
net.inet.tcp.msl=5000
Optimize CrowdSec decision making:
1
2
3
4
5
6
7
8
9
# /usr/local/etc/crowdsec/profiles.yaml
name: opnsense_throttle
filters:
- 'Alert.Remediation == true && Alert.GetScope() == "Ip"'
decisions:
- type: ban
duration: 4h
scope: Ip
on_success: break
Multi-Layered Defense Architecture
- Edge Protection (OPNsense):
- GeoIP blocking
- Port knocking for admin interfaces
- Protocol anomaly detection
- Service Layer (TrueNAS/NextCloud):
- Application-layer rate limiting
- CAPTCHA for failed logins
- File integrity monitoring
- Host Protection:
- Fail2ban for SSH/SMB
- Kernel hardening (sysctl.conf)
- Mandatory access control (AppArmor)
Troubleshooting Service Disruptions
Diagnostic Checklist
When services fail during scanning:
- Check State Table Utilization:
1 2
pfctl -si | grep states # Look for high "current" relative to "limit"
- Analyze Web Server Workers:
1 2
nginx -T | grep worker_connections systemctl status nextcloud | grep Active
- Verify Block Effectiveness:
1 2
crowdsec metrics -b crowdsec-firewall-bouncer # Confirm increasing blocked_ip count
Common Issues and Solutions
Problem: Geo-blocking rules bypassed Solution:
1
2
3
# Verify IPv6 blocking
pfctl -s rules | grep inet6
# Add explicit IPv6 deny if missing
Problem: NextCloud crashes under load Solution:
1
2
# Increase PHP memory limits
sed -i 's/memory_limit = .*/memory_limit = 512M/' /usr/local/etc/php.ini
Problem: False positives blocking legitimate users Solution:
1
2
3
4
5
6
# /usr/local/etc/crowdsec/parsers/s02-enrich/whitelist.yaml
name: corporate_whitelist
whitelist:
reason: 'Corporate IP Range'
expression:
- 192.168.0.0/24
Conclusion
The question “Am I getting attacked?” has a definitive answer: Yes, constantly. All public-facing infrastructure exists in a perpetual state of siege. However, through layered defenses and proper architecture, service disruptions become preventable.
Key takeaways:
- Basic geo-blocking is insufficient against modern scanners
- Service outages during scans indicate architectural gaps
- Defense-in-depth beats any single solution
Where to learn more:
- OPNsense CrowdSec Documentation
- Cloudflare Attack Analysis Reports
- OWASP Web Application Firewall Guide
Security isn’t about building impenetrable walls - it’s about creating resilient systems that withstand the internet’s constant background radiation while maintaining service availability. By implementing these patterns, you transform from passive victim to hardened operator.