NETWORK VIEW

The netstat utility reveals how your Linux box interacts with the local network. With a few Perl modules, you can develop a tool that displays the data dynamically, exactly the way top does.

When you want to know which ports are currently being used, you call netstat. This practical Linux utility can be run in several modes, which the user controls through command-line options. For example, the -s option produces network traffic statistics, and -put displays the ports of all applications that are currently communicating over TCP. Both outputs are useful, but what is really interesting is the chronological progression of events rather than a snapshot at a given moment.

The top utility serves as a model for this kind of dynamic output, displaying and continually updating the CPU load, memory usage, and other basic data of currently running processes. Thanks to CPAN, creating a dynamic terminal application like this from the static output from top is not really difficult.

Buy this article as PDF

Express-Checkout as PDF

Price $2.95(incl. VAT)

Buy Linux Magazine

Related content

To check on the health of a Linux system, administrators can turn to vmstat, iostat, netstat, and ifstat. Or, you can just use the versatile dstat, which combines the features of several tools in a single package.

Without Network Address Translation (NAT) on many LANs, the IPv4 Internet address space would have been exhausted years ago. Still, it’s probably a good idea to check what comes through your NAT connections.