Pular para o conteúdo principal

Using netstat

Using netstat: "
As promised (in my article “How do I find my network information in Linux?“) I am going to introduce you to the netstat command. This command is a very useful tool for discovering networking information such as routing tables, network connections, interface statistics, masquerade connections, and multicast memberships. But it’s not quite as simple to use as some of of the other “discovery” tools (such as ifconfig). With netstat you really do need to know what you’re looking for and how to find it. This article will help you to understand just that.


Installation?
Fortunately your distribution should come with the netstat command pre-installed. To check this, open up a terminal window (that’s where you will use netstat anyway) and issue the command which netsat. This command should return something like /bin/netstat. That will tell you that the tool is installed and where the executable is.
Usage
Because netstat offers such a variety of options, it might be best if I first list some of the more useful options.
a: Shows the state of all sockets and routing table entries.
c: Display information continuously.
d: Show the state of all interfaces that use DHCP.
e: Show extended information.
g: Show the multicast group membership information for both IPv4 and IPv6.
i: Display a table of all network inferfaces.
l: Limit statistics to a defined interface.
M: Show multicast routing tables.
n: Shows network addresses as numbers instead of the default symbols.
p: Show address resolution tables.
P: Limit statistics to a defined protocol.
r: Show all routing tables.
t: Show TCP connections.
u: Show UDP connections.
v: Use verbose mode for output.
So let’s take a look and see how these can be used together.
netstat
By itself (no options) this command prints out generic statistics of the host you are currently connected to.
netstat -an
This command will display all connections to the host, including source and destination addresses and ports, and displays them as numbers.
netstat -rn
This command will display the routing table for the host in numeric form.
netstat -r
This command will display your routing table for your host.
netstat -natp
This command will display active TCP connections in numerical form.
netstat -t –listening
This will show you all tcp ports you host is listening on.



Figure 1
netstat –statistics
This command will display various statistics for your host’s interfaces. Note that this command will display a LOT of statistics. A snippet of the output will look like that shown in Figure 1.
As you can see, this command will display quite a bit of information. On top of that you might need to pipe this command through the less command in order to see it more easily. That full command would look like netstat –statistics | less. Using it that way would allow you to use your arrow keys to scroll up and down through the ouput.
Final thoughts
Although not an exhaustive look at the netstat command, this will get you started and using this handy tool. Since there are so many switches and options to use with netstat, in order to cover them all, take a look at the netstat man page (issue the command man netstat) where you can see each and every switch explained.
"

Comentários

Postagens mais visitadas deste blog

Favigen, Favicon Generator

Favigen, Favicon Generator : " Favicons are small icons that help identify websites. They are used as a visual representation of a website both in the web browser and at many online services. The three most prominent locations of favicons are the browser’s address bar, the tabbar and the bookmarks folder. Many webmasters like to create custom favicons to add that custom identifier to their website. Favicons can be created in many image and icon editors, but also online. Favigen is a straightforward favicon generator that can turn an image into a favicon. All that it takes is to pick an image from the local hard drive first, select the dimensions of the favicon and click the submit button to make the service generate the favicon. Favigen supports several image formats, including jpg and png, and it does not seem to have size restrictions either. Available image dimensions range are 16×16, 32×32 and 64×64. The generated favicon is displayed directly on the page. A click on do...

A simple rsync script to back up your home directory

A simple rsync script to back up your home directory : " Backing up important data is obviously something we should all do. Unfortunately, it is not always easy to make it happen. We get lazy; we do not have the additional hardware for a backup server; it takes a long time and a lot of CDs to back up to optical media; we do not trust online backup services; backup schemes are difficult to set up and use — any of dozens of reasons can stand in our way. Still, we know we should be backing up our important data. Modern open source Unix-like operating systems offer a plethora of options for incredibly simple, effective backup schemes, however. If the problem is figuring out how to set one up, a simple rsync solution may be exactly what you need. The rsync utility is used to synchronize files between two systems. It does so by way of incremental copies, only copying from the source to the destination what has not already been copied there, saving time, network bandwidth, and syst...

Google Wave now open to the public: faster, Robots and Gadgets aplenty!

Google Wave now open to the public: faster, Robots and Gadgets aplenty! : " Filed under: Internet , Google If you somehow missed it, Google Wave is now a bonafide Labs project: rather than being an invite-only alpha, it's now a public beta test! If you don't already have an account, just head on over to Wave and use your regular Google login details. If you've not seen any of the Google Wave introductory videos , you should check them out -- they explain the whole thing a lot more succinctly than I ever could. Wave has also been enabled for Google Apps domains -- businesses could convert their internal communication to Waves today! Leading up to this public release there have a lot of changes. It's by no means finished, but Google Wave is now a lot faster . It's also more intuitive -- more useful -- and given the large number of Robots and Gadgets now reaching prime-time readiness, it feels like the mass adoption of Wave is imminent. Also, if you're an ol...