Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Broadcasting a message using nc (netcat)

Tags:

I'm trying to send a broadcast message using netcat.

I have firewalls open and sending a regular message like this works for me:

  host: nc -l 192.168.1.121 12101   client: echo "hello" | nc 192.168.1.121 12100 

But I can't get something like this to work.

  host: nc -lu 0.0.0.0 12101   client: echo "hello" | nc -u 255.255.255.255 12100 

Am I using the right flags? Note, the host is on Mac and the client on Linux. Can you give me an example that works for broadcasting a message?

Thanks!

like image 758
Edwin Evans Avatar asked Nov 08 '12 17:11

Edwin Evans


People also ask

How do I send data in nc?

Sending Files through Netcat This works by setting the Netcat to listen on a specific port (using the -l option) on the receiving host and then establishing a regular TCP connection from the other host and sending the file over it.

How does nc command work?

The Netcat ( nc ) command is a command-line utility for reading and writing data between two computer networks. The communication happens using either TCP or UDP. The command differs depending on the system ( netcat , nc , ncat , and others).

What is the use of nc command in Linux?

Netcat (or nc in short) is a simple yet powerful networking command-line tool used for performing any operation in Linux related to TCP, UDP, or UNIX-domain sockets.


1 Answers

The GNU version of netcat might be broken. (I can't get to work under 0.7.1 anyway.) See http://sourceforge.net/p/netcat/bugs/8/

I've gotten socat to work. Code below does UDP broadcast to port 24000.

socat - UDP-DATAGRAM:255.255.255.255:24000,broadcast 

(In socat-world "-" means "stdin".)

like image 118
Robert Calhoun Avatar answered Sep 18 '22 21:09

Robert Calhoun