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?
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.
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.
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.
Use the -v
or -vv
for verbose logging, that will tell you client IP and port.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With