Port scanning: understanding and detecting network reconnaissance
Port scanning examines which network services might be reachable at an address. The activity may originate from an authorized audit, monitoring software, an Internet measurement platform or unsolicited reconnaissance.
What is port scanning?
Network ports provide access to exposed services. Reconnaissance seeks to determine which services respond. An accessible port does not automatically mean a vulnerability exists.
- Identify exposed services
- Review the attack surface
- Compare expected and actual exposure
TCP versus UDP observations
TCP uses connection-oriented exchanges, whereas UDP has no equivalent connection handshake. Responses and logs vary according to protocols, services and filtering rules.
- TCP: connection attempts
- UDP: responses may be indirect or absent
- Firewalls: filtering may obscure service state
Indicators of unsolicited reconnaissance
Attempts against many ports, repeated refusals and coordinated access patterns can justify closer investigation. No single indicator establishes malicious intent.
- Number of destination ports
- Rate and timing of attempts
- Repeated failures
- Affected services and source context
Inspect listening ports on Linux
Start with an inventory of your own exposed services. The ss command lists listening sockets; elevated permissions may be required to identify the owning processes.
sudo ss -lntup
sudo systemctl --type=service --state=running
- Identify unnecessarily public services
- Map services to operational needs
- Verify listening interfaces and network policies
Review firewall and service logs
Firewall and application logs help interpret connection attempts, refusals and requests. Logging availability depends on system configuration and retention settings.
sudo journalctl --since '24 hours ago' --no-pager
sudo nft list ruleset
- Separate network refusals from application errors
- Correlate source, destination and time
- Apply appropriate retention and privacy practices
Why HTTP 404 responses are not port scans
An HTTP request for a missing resource and a port scan are different events. Probes for .env files or Git directories can indicate web reconnaissance without proving a TCP or UDP port sweep.
- Web reconnaissance targets HTTP resources
- Port scans discover network services
- Accurate analysis keeps these distinct
Reduce unnecessary exposure
Restrict listening services, apply least privilege and control inbound access. When changing a remote firewall, preserve administrative connectivity.
- Disable unnecessary services
- Restrict reachable interfaces and networks
- Patch exposed software
- Monitor exposure changes
Use Threat Radar observations responsibly
Observed IPs, networks and categories provide context but cannot represent all scanning activity on the Internet or serve as automatic proof of compromise.
- Examine historical patterns
- Verify the event type
- Prioritize investigation using context
Frequently asked questions
Is port scanning always malicious?
No. Authorized auditing, inventory and monitoring tools may also scan ports.
Does an open port prove a vulnerability?
No. Risk depends on the service, configuration, updates and access controls.
Do many HTTP 404 errors mean port scanning?
Not necessarily. They may indicate HTTP probing, which is distinct from port scanning.
How can I reduce exposed services?
Inventory listening services, disable unnecessary ones and restrict access to authorized networks.