Question

How to receive UDP packets via a python socket in ubuntu running on digitalocean?

I’m using a simple python socket that listens on IP 0.0.0.0 via port 65333 for incoming UDP packets. To test if the script with the socket worked, two consoles were opened in the droplet and one console ran the python script with the socket and the other console send an UDP packet to the droplets official IPv4 address via netcat to port 65333.

Under these circumstances the socket receives the packet correctly, but it does not work if netcat is used with the same parameters on my laptop or another computer.

The firewall accepts all UDP packets so the packets should not be dropped.

Pinging the server is also possible from the external environment.

When I run nmap in the console on the cloud for UDP I get:

PORT STATE SERVICE

65333/udp open|filtered unknown

But when I do it on my local machine I get:

PORT STATE SERVICE

65333/udp closed unknown

So it seems like the port is both open and closed at the same time which is not possible. How do I proceed with troubleshooting from here?

Subscribe
Share

Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Accepted Answer

So I tried disabling all firewalls and checking everything once more and I still didn’t receive the UDP packets when sending from my external computer. So out of desperation, I tried out the packet sender software and when I send UDP traffic with that, I receive the traffic. So I think the problem lies with my netcat installation. Next time I will try multiple different means of communication. :D Anyway, it might have been the port was also an issue, so thanks a lot for your help Bobby. ^_^

Hello,

I could suggest trying out with a different port as port 65333 is a dynamic port, or also called private port.

The range of the dynamic ports is from 49152 to 65535. So I could suggest choosing a port lower than 49152.

This could explain why you can access the port via the Droplet itself locally, but it doesn’t work over the public network.

Let me know how it goes!

Best,

Bobby