Search code examples
bashshelludpipv4

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


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?


Solution

  • 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