I'm using
echo "This is my data" > /dev/udp/192.168.0.92/7891
in a bash script to test udp communication with a device. The device then returns the message. I've seen via wireshark that my source port is always changing.
Anyway, I want to set the source port, can I do that?
Use netcat nc
and its -p
option to set the source port.
As said in the netcat man page
-p source_port
Specify the source port nc should use, subject to privilege restrictions and availability.
Then use it like this:
echo "This is my data" | nc -u -p 50000 192.168.0.92 7291
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