Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When redirecting to /dev/udp, how do you force a packet with newlines to be a single packet?

Tags:

bash

shell

udp

ipv4

The simplest example is the following:

echo -e "\n\n\n" > /dev/udp/192.168.45.45/9875

Looking at this with tcpdump, it's actually sending 4 packets. If I needed to send a single packet consisting of hex (payload) 0a0a0a, is that possible using the /dev/udp device?

like image 285
John O Avatar asked Nov 21 '25 11:11

John O


2 Answers

I tried this and it appears to send just a single packet of four (=trailing newline included) characters:

echo -e "\n\n\n" >/tmp/foo
cat /tmp/foo > /dev/udp/10.211.55.9/42000

The problem appears to be in echo instead of /dev/udp.

Hope this helps. Hannu

like image 167
Hannu Avatar answered Nov 24 '25 03:11

Hannu


You can eliminate the final \n with -n option:

echo -n -e "\n\n\n" > /dev/udp/192.168.45.45/9875
like image 20
Angelo Macchia Avatar answered Nov 24 '25 04:11

Angelo Macchia



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!