Port 138: NetBIOS Datagram

Port 138 (UDP) is used by NetBIOS Datagram. Legacy Windows browsing announcements.

138Port
UDPProtocol
netbios-dgmIANA service name
Windows networkingCategory

Port range

138 is a well-known (system) port (range 0–1023). On Linux and macOS, binding to it traditionally needs root or the CAP_NET_BIND_SERVICE capability.

Security

Port 138 should not be reachable from the public internet. Restrict it to trusted networks or a VPN, and scan your public IP to confirm it is closed.

Open port 138 in a firewall

ufw         sudo ufw allow 138/udp
iptables    sudo iptables -A INPUT -p udp --dport 138 -j ACCEPT
firewalld   sudo firewall-cmd --permanent --add-port=138/udp
Windows     New-NetFirewallRule -DisplayName "NetBIOS Datagram 138" -Direction Inbound -Protocol UDP -LocalPort 138 -Action Allow

Check if port 138 is open

nc -vzu example.com 138   # UDP checks are unreliable: no reply ≠ closed
sudo ss -tulpn | grep ':138 '   # what is listening locally (Linux)

Other windows networking ports

Frequently asked questions

What is port 138 used for?
NetBIOS Datagram. Legacy Windows browsing announcements.
Is port 138 TCP or UDP?
UDP.