Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting IP address and Port from UDP Packet

I have a server set-up with netcat:

nc -l 4444 -u

And a client:

nc 127.0.0.1 4444 -u

I am using localhost because they are both on my computer, but if the client moves to another computer, is there a way for netcat to tell me the ip address and port number of the client?

like image 817
Jbad26 Avatar asked Jul 25 '12 16:07

Jbad26


People also ask

Does UDP have source IP?

Yes, the source IP of the packet is passed to the transport layer and the transport layer decodes the source port from the UDP header. A UNIX sockets application would us use recvfrom() to receive arriving datagrams and get the source IP and port in the src_addr structure.

Does UDP have a source port?

UDP header packet structure The fields in a UDP header are: Source port – The port of the device sending the data. This field can be set to zero if the destination computer doesn't need to reply to the sender. Destination port – The port of the device receiving the data.

Can you ping using UDP?

The goal of UDP ping is to detect if there is an active host on the target interface (IP address). To do so, UDP ping sends an IP packet carrying a UDP packet. Once the packet is sent, UDP ping listens to all incoming ICMP messages.


1 Answers

Use the -v or -vv for verbose logging, that will tell you client IP and port.

like image 78
Nikolai Fetissov Avatar answered Oct 24 '22 04:10

Nikolai Fetissov