How to scan the computer’s UDP ports

nmapSecurityudp

What command can I use to port scan UDP? I hear that UDP scanning has some specific issues, that do not apply to TCP scanning.

I tried running sudo nmap -p0-65535 -sU 192.168.1.97. But it has been running for a while now without showing any results…

Background information

I noticed that when I use nmap 192.168.0.97 to port-scan my computer, it only lists TCP ports.

For both TCP and UDP ports, I would start by asking the OS on my computer. I.e. How do I list all sockets which are open to remote machines?

But port scanning is still useful as a confirmation. Port scanning your computer from a different computer is a particularly good idea if you have set up a firewall, to confirm that the firewall is doing what you want. In contrast, ss -l and netstat -l will report listening sockets without regard to any local firewall.

Best Answer

That is one of the issues that might apply to UDP scanning. To be honest I have not bothered much with it. I think you can bump up the timing when you are on your nice fast local wired network. The -T5 option seems to work OK when I am scanning the same computer I run nmap on :-). In this case, it completed a full UDP scan in less than 3 minutes.

Another hint: press enter while nmap is running. It will show a progress indicator.

Another way to speed it up is to not scan all 65535 ports :-). If you only want to double-check that your firewall protects the ports you think it does, you can just pass a list of listening ports that you saw in netstat -l / ss -l. I do not tend to have many weird network services that are listening on physical interfaces but that I need to firewall, so I can just type them in manually :-P.

A second issue is that UDP scans may also show programs which are not listening, only making requests, e.g. a program which sent a DNS request and is waiting for a reply. So some judgement is required. This is easiest when using netstat -l -p / ss -l -p so they show the program name, and then you can start guessing how they are using UDP :-).

The paranoia value of a real scan from a different computer, is that it would help people start noticing things like the Intel ME stupidity.