Recent Tips

How to test open UDP ports

Image result for How to test open UDP ports linux

You've opened a UDP port on your server but not sure how to check if you can reach it from the outside.

When testing TCP ports, you can check with tools like nmap or nc only from the outside, but the nature of UDP is that it doesn't send anything back so you need to monitor the port on the receiving server to see if you receive any packets from the remote server.

You can do this easily using tcpdump and nc.

First, log into the server with the open port. Let's say we opened 80.

Fire up tcpdump to listen on em1 (or whatever interface is listening), specifying UDP and port 80:
tcpdump -i em1 udp port 80 -vv -X
-i is interface
-vv is extra verbose
-X prints data of each packet

Next, use nc from a remote server to throw some UDP packets in the direction of the server on port 80:
nc -u $server 80
-u specifies UDP
$server here is the IP or hostname of your server

Now, on the sending machine, type some text. We'll run through it below.

Sending machine:
root@kali-arm64:~# nc -u 80
Receiving machine:
[root@backup ~]# tcpdump -i em1 udp port 80 -vv -X
tcpdump: listening on em1, link-type EN10MB (Ethernet), capture size 262144 bytes
13:00:30.959720 IP (tos 0x0, ttl 64, id 16117, offset 0, flags [DF], proto UDP (17), length 34)
    kali.41156 > backup.http: [udp sum ok] UDP, length 6
    0x0000:  4500 0022 3ef5 4000 4011 754c c0a8 02a2  E..">.@.@.uL....
    0x0010:  c0a8 0297 a0c4 0050 000e 9457 6865 6c6c  .......P...Whell
    0x0020:  6f0a 0000 0000 0000 0000 0000 0000       o.............
This shows that we can type data into nc on the sending machine and send it via UDP to the receiving machine, and view the data successfully.

So yes, the port is open and you can move on to your next task :)

Please respond below if you have any questions or would like more details on this short howto.