0

I have changed the firmware on my router, unanme -a yields:

Linux RT-AC86U-8458 4.1.27 #2 SMP PREEMPT Fri Aug 6 18:32:35 EDT 2021 aarch64 ASUSWRT-Merlin

I have logged in to ssh to this router, and I am trying to figure out how I can send a UDP packet from this host to a different host on my network.

Here's what I've tried (all failing):

echo -n "hello world" | /dev/udp/serverip/15243
# /dev/udp/ doesnt exist

# or

echo -n "hello world" | nc -4u -w0 serverip 15243
# fails with 4 being an invalid option

# or

echo -n "hello world" | nc -u -c serverip 15243
# fails with u being an invalid option

How can I send a UDP packet from this host?

5
  • Do you have access to the netcat utility? (Mostly, nc will do the trick.)
    – Edward
    Oct 1, 2021 at 18:55
  • 1
    If your router is using BusyBox, then it likely has a different version of nc. What is the output of nc --help? I think for UDP your command would look like: echo -n "hello world" | nc -u -w 1 serverip 15243 Oct 1, 2021 at 19:03
  • 3
    Based on the source the nc (netcat) version is from BusyBox and does not support UDP. But it looks like socat might be available, which is far more featured and should support UDP. Oct 1, 2021 at 19:08
  • @SteffenUllrich how did you extract this information from the source? I just never know what to look for in a situation like this...
    – birgersp
    Oct 3, 2021 at 10:10
  • @birgersp: I've just looked up ASUSWRT-Merlin (given in your output) and there is a link to the source code on github. And there is also the source for nc.c and there is socat in src/router. Oct 3, 2021 at 18:15

1 Answer 1

1

A brief browsing session into ASUSWRT-Merlin git repository tells me ASUSWRT-Merlin uses Busybox version 1.25.1 to to implement nc.

The current upstream version of BusyBox is 1.34.1 as of this writing.

More specifically, it appears ASUSWRT-Merlin uses an old version of BusyBox configured without the ENABLE_NC_110_COMPAT option, which would add UDP support and a few other things to its nc command:

CONFIG_NC=y
# CONFIG_NC_SERVER is not set
CONFIG_NC_EXTRA=y
# CONFIG_NC_110_COMPAT is not set

By changing just the last line in the snippet above to CONFIG_NC_110_COMPAT=y and rebuilding either just the BusyBox component or the entire ASUSWRT-Merlin firmware, you would get the functionality you want.

But as Steffen Ullrich commented, ASUSWRT-Merlin also includes socat. Try:

echo -n "hello world" | socat - UDP:serverip:15243

socat has multiple modes for using UDP. If using just UDP: does not work for you, you could try UDP-DATAGRAM: or UDP-SENDTO: instead, for example.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .