Netcat is a computer networking service for reading from and writing network connections using TCP or UDP
Questions tagged [netcat]
293 questions
74
votes
4 answers
convert a hex string to binary and send with netcat
I have a binary file that I can send with netcat:
$ nc -l localhost 8181 < my.dat
The file contains this:
$ xxd my.dat
0000000: 0006 3030 3030 4e43 ..0000NC
What I really want to do is send the hex string directly. I've tried…
Chris Snow
- 4,046
- 4
- 23
- 30
64
votes
4 answers
How does netcat know if a UDP port is open?
So I can use this netcat command to check if a UDP port is open:
$ nc -vz -u 10.1.0.100 53
Connection to 10.1.0.100 53 port [udp/domain] succeeded!
Unlike TCP, UDP is connectionless (fire and forget). So at a high level does anyone know how netcat…
Patrick McMahon
- 790
- 1
- 5
- 9
52
votes
3 answers
What are the differences between ncat, nc and netcat?
I'm not sure about when to use nc, netcat or ncat.
If one is the deprecated version of another?
If one is only available on one distribution?
If it is the same command but with different names?
In fact I'm a bit confused. My question comes from…
Pozinux
- 1,305
- 5
- 16
- 27
49
votes
5 answers
/dev/tcp listen instead of nc listen
With a netcat listener like:
nc -l < ~/.bashrc
I can grab my .bashrc on a new machine (doesn't have nc or LDAP) with:
cat < /dev/tcp// > ~/.bashrc
My question is: Is there a way to mimic the capabilities of nc -l in my…
h3rrmiller
- 13,095
- 5
- 31
- 41
48
votes
2 answers
No route to host with nc but can ping
I'm trying to connect to port 25 with netcat from one virtual machine to another but It's telling me no route to host although i can ping. I do have my firewall default policy set to drop but I have an exception to accept traffic for port 25 on that…
Katz
- 1,021
- 5
- 19
- 36
43
votes
3 answers
Using netcat for port forwarding
I have a process that listens on an IP:port - in fact it is spark streaming which connects to a socket. The issue is that I wish to somehow create a server that connects to spark on one port and data is streamed into this server from another port.…
disruptive
- 531
- 1
- 5
- 5
24
votes
2 answers
Netcat - How to listen on a TCP port using IPv6 address?
I am using the newest version of netcat (v1.10-41.1) which does not seem to have an option for IPv6 addresses (as the -6 was in the older versions of nc).
If I type in nc -lvnp 2222 and check listening ports with netstat -punta, the server appears…
bashbin
- 431
- 1
- 4
- 10
22
votes
5 answers
netcat doesn't print response
I'm trying to send commands to a tcp port using netcat and pipe response
when I run netcat and type my command it prints response correctly but when I pass command from a pipe it sends the command correctly but doesn't print response
So, this…
Ariyan
- 2,056
- 3
- 27
- 36
20
votes
12 answers
netcat: send text to echo service, read reply then exit
I would like to use netcat to send a piece of text to the echo service on my server, get the reply then exit, so that I know the connection is still good. so far I've tried:
echo 'test' | netcat server 7
this way netcat would wait for more…
SparedWhisle
- 3,588
- 4
- 22
- 35
19
votes
1 answer
SSH speed greatly improved via ProxyCommand - but why?
The TL;DR version
Watch this ASCII cast or this video - then come up with any reasons why this is happening. The text description that follows provides more context.
Details of the setup
Machine 1 is an Arch Linux laptop, on which ssh is spawned,…
ttsiodras
- 2,301
- 1
- 21
- 26
18
votes
5 answers
netcat doesn't terminate when stdin closes
I'm trying to send a message through netcat. After sending the message, netcat must terminate.
I've tried the following:
cat tsmmessage.bin | nc -u localhost 4300
nc -u localhost 4300 < message.bin
The -q option states:
-q seconds
after EOF on…
Frank Kusters
- 323
- 1
- 2
- 9
17
votes
2 answers
Remote desktop over SSH reverse tunnel to replace TeamViewer
I want to open a remote desktop session from my laptop to desktop over my SSH (reverse) tunnel. That should be simple (or at least doable), right? Until now I've been using Team Viewer to log in to the remote desktop. I'd like to achieve similar…
MountainX
- 17,168
- 59
- 155
- 264
17
votes
5 answers
Simplest way to send files over network
What is the simplest and most versatile way to send files over the network to other computers? By that I mean computers that other people are using at the moment. I don't think SSH works if the computer has an active session open.
So far I am using…
TomTom
- 2,453
- 6
- 18
- 23
16
votes
1 answer
netcat in shell script giving invalid connection
I have a shell script that uses netcat to listen to localhost on port 1111 for web requests. Every time I try accessing localhost:1111/index.html for example I get:
invalid connection to [127.0.0.1] from localhost [127.0.0.1] 60038
the number at…
MinaHany
- 735
- 2
- 6
- 10
16
votes
3 answers
Using in/out named pipes for a TCP connection
I've been fiddling with getting this to work for a while now, so I suspect some sort of fundamental misunderstanding about how pipes work is the root cause of my troubles.
My goal is to initiate a TCP connection to some remote host via netcat and…
noffle
- 1,140
- 1
- 10
- 18