Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is listening on port with Netcat not working

I am running the following command on Ubuntu:

nc -l -p 5004 -v  >> /home/anders/Dropbox/netcatFiles/test

which includes a command to make it listen at 5004.

I am sending a RTP-stream to port 5004 using VLC. When I am observing the loopback-interface in Wireshark I notice ICMP-packets with the message 'Destination unreachable'.

Opening another VLC and telling it to play the incoming data at port 5004, it all works, and the stream is played.

What should I do in order to get Netcat to listen at port 5004?

like image 524
Anders Branderud Avatar asked Jul 01 '12 22:07

Anders Branderud


People also ask

How do you specify a port to listen on Netcat?

On one machine, you can tell netcat to listen to a specific port for connections. We can do this by providing the -l parameter and choosing a port: netcat -l 4444.

How do I know if Netcat is working?

Install Netcat/NcatLinux and macOS users can quickly check if a port is open in the terminal with pre-installed Nc (and Netcat on Linux). Windows users will need to install Netcat's successor, Ncat, made by the Nmap project. Both are good for seeing if a specific port is open on a local network, VPN, or server.

What is the command to start Netcat in listen mode?

The command nc –l will put Netcat into server or listening mode, and nc by itself will run Netcat in client mode.

How do I get my UDP port to listen?

Listen for UDP on specific host and port using netcat nc is the command alias for netcat. u Use UDP. That is, listen for UDP on give port, by default it listens for TCP unless we give this option. Port You must specify the port on which nc should listen on.


2 Answers

I think you need to add the " -u " parameter to make it listen on UDP.

By default, netcat works in TCP mode, but RTP protocol is UDP based.

"The Transmission Control Protocol (TCP), although standardized for RTP use,[5] is not normally used in RTP application because TCP favors reliability over timeliness. Instead the majority of the RTP implementations are built on the User Datagram Protocol (UDP)"

http://en.wikipedia.org/wiki/Real-time_Transport_Protocol

like image 172
LSerni Avatar answered Sep 22 '22 12:09

LSerni


don't use -p (man nc (1))

-p source_port Specifies the source port nc should use, subject to privilege restrictions and availability. It is an error to use this option in con‐ junction with the -l option.

so just specify

nc -l 5004 -v  >> /home/anders/Dropbox/netcatFiles/test
like image 38
Harald Brinkhof Avatar answered Sep 22 '22 12:09

Harald Brinkhof