Re:Netcat – The swiss army knife of networking
by dleimbach on Tuesday April 02, 2013 @11:24PM
(#5484033)
I connected an SNMP monitoring system using two socats and an ssh tunnel. One socat to forward UDP over TCP to the locally encrypted port, and another to take it off on the other side and forward it to a local SNMP listener. It was a for a control system we were building that could monitor temperatures and control fan speeds in a computer cooling system. We ran it across several states in the US, and it was just to get an early demo of how the system would work before hardware was more locally available and the damned thing worked...
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.
Re:Netcat – The swiss army knife of networking
by smtddr on Tuesday April 02, 2013 @10:41AM
(#5479539)
seriously, I was introduced to socat about 5 months ago... blew my mind. netcat is good and I still use it to quickly send custom GET requests, but socat is like a swiss-army knife containing many swiss-army knives. It even forwards unix-domain sockets and doesn't necessarily need root permissions like iptables.
Re:Netcat – The swiss army knife of networking
by DrPhish on Tuesday April 02, 2013 @12:30PM
(#5480315)
Agreed. If netcat is the swiss-army knife of network tools, socat is the complete utility belt. I discovered socat because netcat simply wouldn't bend in all the ways I needed it to. There is NOTHING ad-hoc network related that I haven't been able to perform with socat.
Re:Netcat – The swiss army knife of networking
by calinet6 on Tuesday April 02, 2013 @10:31AM
(#5479464)
No better way to get the absolute maximum possible use of your pipe with the absolute minimum amount of security! Netcat has saved my butt when that 12GB package absolutely, positively has to be there within the next minute.
One of the coolest network utilities around. It's literally like a cat piped through the network. These are all great examples.
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.'
Re:Netcat – The swiss army knife of networking
by calinet6 on Tuesday April 02, 2013 @01:22PM
(#5480711)
Sweet :) I wasn't doing it over lan though, totally different subnets here. It's easy to quickly open the port I want to use for netcat on a remote machine and copy files quickly that way.
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 :)
Re:Netcat – The swiss army knife of networking
by kylecordes on Tuesday April 02, 2013 @09:31PM
(#5483591)
As an alternative to all of the above, consider UDPCast. It's point is that it can multicast; but it is also great for point-to-point copies. I adds its own reliability layer, so don't be scared of UDP in the name. It can rate limit, if you want. I've used it to great effect to shuffle a lot of GB to a bunch of servers at the time.
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.
Re:Netcat – The swiss army knife of networking
by cnvogel on Tuesday April 02, 2013 @11:11AM
(#5479737)
/me too/
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).
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.
Re:Netcat – The swiss army knife of networking
by jimktrains2 on Tuesday April 02, 2013 @03:29PM
(#5481584)
I really don't see how Apache vs Nginx will give you that much performance increase. The majority of the processing time for a request is in the backend (rendering, compiling, db calls, &c). Improved caching would give much better performance gains than just switching a server without any other improvements.
Re:Netcat – The swiss army knife of networking
by thomaslutz on Tuesday April 02, 2013 @03:39PM
(#5481628)
Compare memory usage; also Apache has problems with many concurrent connections and low hard limits as default, which nginx handles much better. Varnish of course would also be a valid improvement.
Re:Netcat – The swiss army knife of networking
by djrobstep on Tuesday April 02, 2013 @06:51PM
(#5482762)
I used to think this too, but I recently switched a PHP app I run over to Nginx from Apache, nginx uses much less memory, and consequently the app can run on far less instances, it's been a huge win.
This app has many long-running connections and a write-heavy workload, your mileage may vary.
Re:Netcat – The swiss army knife of networking
by 4ad on Tuesday April 02, 2013 @06:11PM
(#5482501)
On Plan 9, where networked I/O is done through a file system, there is no need for netcat, you can use regular Plan 9 tools to do anything netcat does and more.
Re:Netcat – The swiss army knife of networking
by jnazario on Tuesday April 02, 2013 @11:41AM
(#5479969)
nc is ancient but flexible. want encryption? pipe in openssl's command line to encrypt a stream. i'm pleased to see it so widely deployed.
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.
Re:Netcat – The swiss army knife of networking
by runejuhl on Tuesday April 02, 2013 @01:37PM
(#5480811)
It should be noted that rlwrap works on all programs that use readline. I've used it when starting out with programming in SML and getting annoyed at the missing arrow-up command history.
Re:Netcat – The swiss army knife of networking
by sigil on Tuesday April 02, 2013 @03:53PM
(#5481713)
Actually, rlwrap works well with all line-reading programs that DON'T use the readline library, and not so well with some that do. Like the python debugger. :(
Re:Netcat – The swiss army knife of networking
by ajross on Tuesday April 02, 2013 @12:23PM
(#5480251)
Actually the netcat shipped on most/all common Linux distributions (though IIRC, frustratingly not Cygwin which has a more limited one without the SOCKS features) is the one from OpenBSD.
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...
Re:Netcat – The swiss army knife of networking
by 3am on Tuesday April 02, 2013 @11:05AM
(#5479690)
In the situations where nc is useful then scapy is probably not an option. Nc, dd, and a few others are almost always present and great when you are in a real bind... something went wrong in a network install in pxelinux, and you want to copy off dumps or config files, or copy on a missing file. Otherwise, there are better ways to do most of the things mentioned in the article, most involving scp.
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 :)
Re:Netcat – The swiss army knife of networking
by fduran on Tuesday April 02, 2013 @11:18AM
(#5479783)
I know they are different tools, I meant if you like to play with ncat, tcpdump etc and/or you're learning netsec you may want to play with scapy. Directed to the very few readers that may know about nc and not scapy :-)
Re:Netcat – The swiss army knife of networking
by chm on Tuesday April 02, 2013 @10:56AM
(#5479621)
It seems there are better alternatives to netcat, i.e. socat and ncat. Why should I choose either? I'd like to learn how to use such a tool, but I'm not a CS major.
Re:Netcat – The swiss army knife of networking
by cnvogel on Tuesday April 02, 2013 @11:06AM
(#5479699)
For the simple task of moving bytes through a tcp connection (what the article is about) netcat will be fine.
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.
Re:Netcat – The swiss army knife of networking
by zyberkiddy on Tuesday April 02, 2013 @12:16PM
(#5480193)
Few months earlier, when I was learning shell programming, I created a simple file transfer script using netcat (nc) and zenity (for little GUI).. Can be used to transfer files inside LAN.. It was actually made to use inside our college lab for my non technical friends..
Re:Netcat – The swiss army knife of networking
by ancarda on Wednesday April 03, 2013 @01:21AM
(#5484387)
I can't seem to get the chat example to work on OS X. Does anyone know if it's limited to working on Linux?
[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).
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.
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 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).
I wouldn't call 'socat' a swiss army knife. More like a tool shed. But it is very handy at times.
http://ngrep.sourceforge.net/
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.
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.
http://www.dest-unreach.org/socat/doc/socat.html
https://github.com/zyberkiddy/netcat-file-transfer
[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!