Skip to content
statance
MenuClose
← All ports

Port 139: NetBIOS Session Service (SMB over NetBIOS)

High risk

TCP port 139 carries SMB file and printer sharing over NetBIOS. Modern Windows and Samba use SMB directly on port 445 instead. It should not be reachable from the public internet.

Port
139
Protocol
TCP
Service
NetBIOS Session Service (SMB over NetBIOS)
Expose to internet?
No
Also used by
Windows file sharing, Samba

Is port 139 safe to open?

Port 139 gives the same access as SMB on 445: shared folders, printers and authentication. It should never be reachable from the internet, and it is usually unnecessary on modern networks at all.

How to secure NetBIOS Session Service (SMB over NetBIOS)

  • Block TCP 139 at the network edge.
  • Disable NetBIOS over TCP/IP so SMB only runs on 445.
  • On Samba, set smb ports = 445 to stop listening on 139.

Check if port 139 is open

Linux: what is listening on this port

sudo ss -tlpn | grep ':139 '

Windows (PowerShell): what is listening

Get-NetTCPConnection -LocalPort 139 -State Listen | Select-Object LocalAddress, OwningProcess, @{n='Process';e={(Get-Process -Id $_.OwningProcess).Name}}

From another machine: is it reachable

nc -zv HOST 139 # or nmap -p 139 HOST # Windows Test-NetConnection HOST -Port 139

Restrict port 139 in the firewall

Replace 10.0.0.0/8 with the network or address that needs access. Docker publishes container ports through its own iptables rules, which bypass ufw; bind published ports to 127.0.0.1 (-p 127.0.0.1:139:139) instead of relying on the host firewall.

ufw: allow only your private network, deny everyone else

sudo ufw allow from 10.0.0.0/8 to any port 139 proto tcp sudo ufw deny 139/tcp

firewalld: allow one source network only

sudo firewall-cmd --permanent --remove-port=139/tcp sudo firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="10.0.0.0/8" port port="139" protocol="tcp" accept' sudo firewall-cmd --reload

iptables

sudo iptables -A INPUT -p tcp --dport 139 -s 10.0.0.0/8 -j ACCEPT sudo iptables -A INPUT -p tcp --dport 139 -j DROP

Windows Firewall (PowerShell, as Administrator)

New-NetFirewallRule -DisplayName "Block 139 from internet" -Direction Inbound -Protocol TCP -LocalPort 139 -RemoteAddress Internet -Action Block

Monitor port 139

Run a TCP port monitor against your public IP on port 139: here, a failed connection is the healthy result, so you know the firewall is still doing its job. On Linux, the Statance agent also reports every listening port on the server. TCP port monitoring.

Related ports

Port 445SMBCritical risk
Port 137NetBIOS Name ServiceHigh risk
Port 135Microsoft RPC endpoint mapperHigh risk

FAQ

What is port 139 used for?

TCP port 139 carries SMB file and printer sharing over NetBIOS. Modern Windows and Samba use SMB directly on port 445 instead. It is also used by Windows file sharing, Samba.

Is it safe to open port 139?

Not to the public internet. Port 139 gives the same access as SMB on 445: shared folders, printers and authentication. It should never be reachable from the internet, and it is usually unnecessary on modern networks at all.

Is port 139 TCP or UDP?

NetBIOS Session Service (SMB over NetBIOS) uses TCP on port 139.

How do I check if port 139 is open?

On the server, run sudo ss -tulpn | grep ':139 ' (Linux) or Get-NetTCPConnection -LocalPort 139 (Windows) to see what is listening. From another machine, run nc -zv HOST 139 or Test-NetConnection HOST -Port 139.

All ports →

Know the moment a port stops answering.

TCP, HTTP, DNS and SSL checks from six regions, plus server metrics from a one-line agent.