Netcat – The swiss army knife of networking
mylinuxbook.com
mylinuxbook.com
This made a lot of people very happy and it was really crazy to be on the phone with the other folks and have them rev up the fans in our lab via SNMP through this channel.
One of the coolest network utilities around. It's literally like a cat piped through the network. These are all great examples.
I like it (tar|nc) as a quick alternative when moving data to or from low performance devices such as Android phones. Rsync/SSH really burns a lot of power for encryption. Makes a full x GB Backup much faster to pipe it through netcat (or bashs /dev/tcp if available).
rsync -e "ssh -c blowfish"
However, I'm not sure if anybody uses this these days, since end-to-end time is probably dominated by bandwidth and not cpu these days.From the site: '"ncp" is a utility for copying files in a LAN. It has absolutely no security or integrity checking, no throttling, no features, except one: you don't have to type the coordinates of your peer.'
If you're interested in completely saturating all your resources for the maximum possible transfer speed, check out Tsunami: http://tsunami-udp.sourceforge.net/ -- It's a UDP protocol designed for raw throughput. Also no security or checking, but it does support throttling which is nice. I've tested and it actually does exceed netcat's rate by a few percent, but it's a little less reliable (client and server have to agree on a lot of things). Pretty cool to experiment with though :)
Way down at a low level, the network hardware/firmware knows how to send data 1:N. Using that is a single easy command away, but hardly anyone knows it.
http://kylecordes.com/2008/multicast-your-db-backups-with-ud...
I wouldn't call 'socat' a swiss army knife. More like a tool shed. But it is very handy at times.
Also +1 for socat as a netcat replacement, having SSL there when needed is really helpful. I use it a lot for testing when developing network applications, replacing one end point with a fixed set of responses or even typing stuff in interactively etc.
Switching to nginx does not help at all in most cases. I really like nginx but Apache gets a lot of unfounded hate.
This app has many long-running connections and a write-heavy workload, your mileage may vary.
I miss this dearly on Unix.
for fun, find the original hobbit nc source code and read the comments. the complaints in there about writing a portable utility and dealing with platforms' weirdness and brokenness.
rlwrap nc ....But obviously the article was written from the perspective of "Fun commands available on Linux". I'm all for giving proper credit where it is due, but it's asking a little too much to expect that every newbie tutorial is going to inflict a full software genealogy on the poor reader...
cat disk.img > nc
nc > /dev/sda
Since we had an entire lab to clone to, we combined dd, netcat, and tee to just daisy chain the data out. It worked _magically_.
EDIT: the number of responses to this article happily highlighting the lack of security in netcat just terrifies me.
EDIT2: Ah, I see what you were saying (and scapy is an awfully cool library). It was just a convenient place for me to highlight was I didn't think was highlighted enough in the article: nc can do neat things, but not much that can't be accomplished better with other tools - its big advantage is that it's almost always present, even if ssh/scp, rsync, netstat, wget/curl, etc are not. Like using cat + sed as a text editor :)
Socat allows you to use raw interfaces, or fifos, SSL, proxies, serial ports,... as one or both end points. E.g. you can forward arbitrary tcp connections (tcp relay;) but also connect stdin/stdout if a program to a serial port... just very, very, very versatile.
[Edit] I was using nc 127.0.0.1 so I'm not sure if netcat can't communicate with lo. Also tried SSHing into a Linux box I own, now I get "Connection refused" on the client side (OS X).
[Edit Again] UDP works fine!
Server: nc -ul -p <Port>
Client: nc -u <IP> <Port>