Purchase Linux CDs / DVDs / Flash Drives at OSDisc.com

Welcome to Our Community

While Linux.org has been around for a while, we recently changed management and had to purge most of the content (including users). If you signed up before April 23rd, 2017 please sign up again. Thanks!

  1. Follow us on twitter - we shoot all of our new original content out as well as random messages. https://twitter.com/linuxdotorg
    Dismiss Notice

How to test open UDP ports

Discussion in 'Linux Server' started by Rob, Jun 8, 2018.

  1. Rob

    Rob Administrator
    Staff Member

    Oct 27, 2011
    Likes Received:
    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:
    [email protected]:~# nc -u 80
    Receiving machine:
    [[email protected] ~]# 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..">[email protected]@.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.

    (Log in to hide this advertisement)

    #1 Rob, Jun 8, 2018
    Last edited: Jun 11, 2018
    Dimitris and atanere like this.

Share This Page