On CBS.com: U2 helps out during NYC snowstorm

Learn the many uses of netcat

Tags: Linux, PRODUCTIVITY, NETWORKING, UNIX, OPEN SOURCE, Vincent Danen, NetCat, remote machine, local machine, Linux Tips Newsletter

  • Save
  • Print
  • Recommend
  • 14

Takeaway: The netcat tool allows admins to read and write TCP or UDP data across the network. It also helps with network debugging and testing. Learn more about netcat.

Delivered each Tuesday, TechRepublic's free Linux NetNote provides tips, articles, and other resources to help you hone your Linux skills. Automatically sign up today!

Often referred to as the "Swiss Army Knife of networking," netcat is a tool that administrators can use to read and write TCP or UDP data across the network. In addition, it's extremely useful for network debugging and testing.

Netcat offers several interesting uses. For example, you can make it listen to a particular port and run a program. To do so, use the following:

$ netcat -v -l -p 10111 -e "/bin/cat /etc/motd"

This tells netcat to listen to port 10111. When there's a connection, it tells netcat to execute "/bin/cat /etc/motd," which essentially displays the contents of /etc/motd and exits.

You can also set up netcat on a machine to listen for incoming connections and run it on a remote machine to connect to the local machine and serve up a bash shell. For example, on a local machine with an IP address of 192.168.5.10, you would use the following:

$ netcat -v -l -p 10111

On the remote machine, you would use:

$ netcat 192.168.5.10 10111 -e /bin/bash

This tells the netcat instance on the remote machine to connect to the netcat instance listening on 192.168.5.10 and serve up a bash shell from the remote machine, which will then be available on the local machine. Using the netcat instance on 192.168.5.10, you can execute shell commands on the remote host.

To perform some Web debugging, you could use something like the following:

$ netcat www.website.com 80

Then, enter typical HTTP commands to get the unaltered output (e.g., "GET / HTTP 1.0").

As you can see, netcat is both an extremely versatile and very powerful utility. You can download this useful tool, based on the original netcat program, from the GNU Netcat Project Web site.

  • Save
  • Print
  • Recommend
  • 14

Print/View all Posts Comments on this article

Unlcear instructions WarS | 05/25/05
That's more a fault with Unix style instructions stress junkie | 05/25/05

What do you think?

White Papers, Webcasts, and Downloads

Article Categories

Security
Security Solutions, IT Locksmith
Networking and Communications
E-mail Administration NetNote, Cisco Routers and Switches
CIO and IT Management
Project Management, CIO Issues, Strategies that Scale
Desktops, Laptops & OS
Windows 2000 Professional, Microsoft Word, Microsoft Excel, Microsoft Access, Windows XP,
Data Management
Oracle, SQL Server
Servers
Windows NT, Linux NetNote, Windows Server 2003
Career Development
Geek Trivia
Software/Web Development
Web Development Zone, Visual Basic, .NET

Popular IT Dojo Videos

advertisement
Click Here