netcat UDP broadcast

Issues related to configuring your network
Post Reply
elluk
Posts: 6
Joined: 2008/01/18 20:16:10

netcat UDP broadcast

Post by elluk » 2008/01/31 12:59:26

Hello,

I'm trying to broadcast a files contents to a UDP broadcast address using netcat (nc)

cat filename|nc -u 192.168.1.255 4444

netcat just exits with errorlevel 1

I have been able to do this on the windows port of netcat!

Does anyone know why this is not working?

Or an alternative method I could use to send a file to broadcast address?

Thanks,

E

MMN-o
Posts: 1
Joined: 2013/12/05 12:03:08

Re: netcat UDP broadcast

Post by MMN-o » 2013/12/05 12:09:56

Since I found this thread while doing internet searches but no answer was posted, I'll let you know that this seems to be a long-standing bug in netcat (at least GNU netcat):

http://sourceforge.net/p/netcat/bugs/8/
Created: 2003-08-28

Network broadcast addresses do not work,

for UDP you need to set SO_BROADCAST option on sockets.
This is also a bug in original netcat.
Fortunately there is another software which can do this, although the commandline isn't quite as intuitive. socat handles all kinds of network (and unix socket) traffic. To do what you want to do in socat, try:

echo "UDP broadcast" | socat - UDP4-DATAGRAM:192.168.0.255:11001,so-broadcast

which pipes "UDP broadcast" from echo (followed by \n) to socat, which has STDIN as input ("-"). Then outputs to UDP4-DATAGRAM on the broadcast address (192.168.0.255) with the "so-broadcast" flag. There are a bunch of other parameters you can tag along, but this works (and I can receive it using netcat on another computer with: nc -u -l 192.168.0.255)

User avatar
Super Jamie
Posts: 310
Joined: 2014/01/10 23:44:51

Re: netcat UDP broadcast

Post by Super Jamie » 2014/01/11 01:00:11

The US Navy's Multicast Dissemination Protocol is probably what you're looking for:

http://www.nrl.navy.mil/itd/ncs/products/mdp

Post Reply