Join us Dec. 16 for The Community Hour, our first global virtual User Group event!
AP2K
ServiceNow Employee

Many organizations start Discovery with firewall rules that let MID Servers reach any port on any device in the scanned IP ranges. The reasoning is sound: you don't want to miss a device. Sooner or later a cyber team asks for specific firewall rules limiting which ports are scanned. This article covers what to consider so you can give them a precise answer and keep your CMDB complete.

An analogy

Imagine a building inspector who has to catalog every office in a city. The original policy says "knock on any door, any time." Security now asks for a list of doors the inspector is allowed to knock on, and a record of who sent them.

Discovery's port scanner (the Shazzam probe) is that inspector. The goal isn't fewer doors. It's a documented, defensible list of doors, and a process for adding one when a new kind of building appears.

 

 Instance (ServiceNow)

      ▲

      │  HTTPS 443 (outbound from MID only)

      │

 ┌────┴─────┐   Zone A rules      ┌───────────────┐

 │ MID  (A) │ ──────────────────► │ Zone A targets│

 └──────────┘  only the ports     └───────────────┘

               Zone A needs,

 ┌──────────┐  source = this MID  ┌───────────────┐

 │ MID  (B) │ ──────────────────► │ Zone B targets│

 └──────────┘   Zone B rules      └───────────────┘

 

 

  1. Build the allow-list from your instance, not a generic document

Port scanning is the first step of Discovery, and the Shazzam probe performs it regardless of whether you use patterns for horizontal discovery. The documentation lists the default port probes and common ports, and it carries a clear warning to review the table before you block any ports with a firewall. 

 

The documentation is a starting point. Your instance is the source of truth:

  1. Go to Discovery Definition > Port Probes.
  2. Review the behavior records your schedules actually use.
  3. Export the list. This is the exact, environment-specific set of ports Shazzam will hit, and it becomes the allow-list for your cyber team.

A typical active set looks like this. Treat it as illustrative and use your own export.

Purpose

Port / Protocol

Windows (WMI/RPC)

135 TCP

Windows (WinRM)

5985 (HTTP) / 5986 (HTTPS)

Linux/Unix

22 (SSH)

Network devices

161 (SNMP, UDP)

vCenter

443

CIM / storage (WBEM)

5989

Directory

389 (LDAP)

Printers

9100, 515

 

  1. Windows: The real sticking point is usually WMI

Windows discovery over WMI needs port 135 from the MID to the target for the initial handshake. The rest of the conversation then moves to dynamic high ports, and the documentation notes that supported Windows machines can have dynamic port ranges of 49152-65535 for both TCP and UDP. That range is what security teams object to most. 

The single biggest win you can offer them is to move Windows discovery from WMI to WinRM. Instead of a large dynamic range, you need fixed ports: 5985 for HTTP or 5986 for HTTPS. Use 5986 where TLS is mandated. Pilot this first, because port 135 may still be used for initial classification, and confirm the impact in your environment before you tighten rules.

 

  1. Place MIDs close to their targets and lock the source
  • Segment by zone: Deploy MIDs per network segment instead of one MID that reaches everything. Each segment's rules stay tight and point-to-point, and fewer hops usually improves performance.
  • Limit by source, not just port: Write rules with the specific MID Server IPs as the source, so even allowed ports are reachable only from your MIDs.
  • Keep redundancy: For production, configure at least two MIDs per IP range in a cluster. Plan the firewall rules for every member of the cluster.
  • Use the right method per use case: Where firewall access to MIDs isn't realistic (DMZ servers, cloud workloads, air-gapped networks), consider agent-based collection (ACC-V) or cloud API-based discovery through Service Graph Connectors instead of opening more ports.
  1. Remember the MID is an integration host

The firewall request should reflect every role the MID plays:

Role

Ports

MID to instance (ECC queue, file transfers)

Outbound HTTPS 443 only. No inbound rules are required, because the MID polls.

File-based integrations

SMB 445, SFTP 22, FTP 21

Database integrations (JDBC/import)

e.g., 1433 (SQL Server), 1521 (Oracle), 3306 (MySQL)

Event Management, Orchestration, other MID-hosted work

Own ports, depending on the feature

If you only scope for Discovery, a file import or integration will fail the first time it runs.

 

  1. How will you know when a new port is needed?

Build this into process rather than waiting for failures:

  • Intake and onboarding: Any new IP range, new device class, or newly activated Discovery pattern should go through intake. Check whether it needs a port probe you haven't opened.
  • Watch the early-warning signs: If Shazzam finds a device alive but no configured port probe gets a response, the device fails to classify. Devices stuck as Unclassified or No Protocol in discovery status and logs are your signal. Discovery Admin Workspace (error grouping, anomaly detection, Shazzam Insights) makes this easier to track.
  • Lightweight change control: Treat any new port probe as a firewall change request.

 

  1. Will limiting ports affect software discovery (SAM)?

Generally no, as long as OS-level discovery ports stay open. Software inventory is collected inside the credentialed session to the host (SSH for Linux/Unix, WMI or WinRM for Windows), not through separate per-application ports. If Windows discovery works over 135 plus WinRM/WMI, and Linux over 22, installed-software collection rides along on the same sessions.

 

  1. The firewall is one layer: harden credentials and the MID too

Security teams usually respond well when you show the whole posture:

  • Credentials: use an external credential store (e.g., CyberArk, HashiCorp Vault, Azure Key Vault), Group Managed Service Accounts, and Just Enough Administration where possible.
  • Local admin on Windows targets: it's needed mainly for application dependency mapping, because that runs netstat, which only shows connections in the user's own context for non-admins. For asset-only inventory, a read-only account can be enough. Be explicit with security about which use case needs which level.
  • MID hardening: encrypt MID configuration values and ECC queue data, enable mutual authentication (client certificate), use code signing and the ECC firewall, and review the MID Server command audit log.
  • Partner early: Involve information security in approving discovery methods, obtaining credentials, opening firewall paths (MID to devices, MID to instance), and defining allowed protocols.

 A short checklist for the conversation with your cyber team

  • Export the port-probe list from your instance (the allow-list).
  • Decide WMI vs. WinRM for Windows.
  • Define MID placement per zone, with source-restricted rules.
  • Add non-Discovery MID ports (443 outbound, file, database, integrations).
  • Document the intake and firewall-change process for new ports.
  • Agree on monitoring for unclassified and No Protocol devices.
  • Review credential and MID hardening options.
  1. Trade-offs to weigh

No single choice is free. Here is what each option gains and costs, so you can decide with your security team rather than just tell them.

 

i) Restricting scan ports vs. leaving them open

Pros

Cons

A documented, defensible allow-list that cyber can approve

Devices that respond only on an unlisted port can fail to classify and drop out of the CMDB

Smaller attack surface and cleaner firewall audits

Ongoing effort: every new device class or pattern needs a port review

Faster troubleshooting, because unexpected traffic stands out

Firewall change cycles can slow onboarding of new ranges

Mitigation: the intake process and the Unclassified / No Protocol monitoring described above.

 

ii) WinRM instead of WMI for Windows

Pros

Cons

Fixed ports (5985/5986) replace the large dynamic range

WinRM must be enabled and configured on targets (listeners, GPO, certificates for HTTPS)

HTTPS option (5986) satisfies TLS-mandated policies

Some older or locked-down hosts may behave differently, so pilot before a broad cutover

Easier for security to review and monitor

Port 135 may still be needed for initial classification

 

iii) Many MIDs segmented by zone vs. a few central MIDs

Pros

Cons

Tight, point-to-point rules per segment

More MIDs to build, patch, monitor, and cluster

Fewer hops, so usually better performance

More hosts and change requests to manage

Smaller blast radius if one MID is compromised

Needs good IP-range and schedule design to avoid gaps or overlap

 

iv) Locking rules to MID source IPs

Pros

Cons

Allowed ports are reachable only from your MIDs

Replacing, adding, or re-IPing a MID needs a rule update first

Strong evidence for audit and exception requests

Cluster members must all be covered in the rules

 

v) Where the agents or connectors fit?

Agent-based collection (ACC-V) and cloud API-based discovery avoid opening inbound firewall paths, which helps in DMZs, cloud, and air-gapped networks. The cost is deploying and maintaining agents, and a hybrid approach with more moving parts.