Friday, August 16, 2013

NETSTAT COMMAND FOR QUICK NETWORK RELATED INFORMATION


Netstat is a command which displays detailed information about system's mode of communication in a network. This 
command has advantage of displaying very  detailed information about network including network connections , 
protocol-specific networking statics, and overall network which is helpful in troubleshooting network related issues.



Nestat command when used with -a flag displays the state of all sockets used by system processes.

[root@cbitss ~]# netstat -a  | more 
Active Internet connections (servers and established) 
Proto Recv-Q Send-Q Local Address               Foreign Address  State      
tcp        0      0 *:rquotad                   *:*                         LISTEN      
tcp        0      0 *:38924                     *:*                         LISTEN      
tcp        0      0 *:59853                     *:*                         LISTEN      
tcp        0      0 *:sunrpc                    *:*                         LISTEN      
tcp        0      0 *:37589                     *:*                         LISTEN      

In the above example netstat command is piped with more pagination to display result page by page.
All tcp ports can be listed as follows:


User can also find the Kernel interface table which is similar to ifconfig command by using -ie flag with netstat as follows:

[root@dhcppc15 ~]# netstat -ie 

The sample output of above command is as follows:
Kernel Interface table 
eth0      Link encap:Ethernet  HWaddr 00:E0:E8:66:44:11  
          UP BROADCAST MULTICAST  MTU:1500  Metric:1 
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0 
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b) 
          Interrupt:20 Base address:0xc000 

eth1      Link encap:Ethernet  HWaddr 00:1D:7D:80:18:1B  
          inet addr:192.168.1.17  Bcast:192.168.1.255  Mask:255.255.255.0 
          inet6 addr: fe80::21d:7dff:fe80:181b/64 Scope:Link 
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1 
          RX packets:34628 errors:0 dropped:0 overruns:0 frame:0 
          TX packets:26093 errors:0 dropped:0 overruns:0 carrier:0 
          collisions:0 txqueuelen:1000 
          RX bytes:37288056 (35.5 MiB)  TX bytes:2928416 (2.7 MiB) 

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0 
          inet6 addr: ::1/128 Scope:Host 
          UP LOOPBACK RUNNING  MTU:16436  Metric:1 
          RX packets:16 errors:0 dropped:0 overruns:0 frame:0 
          TX packets:16 errors:0 dropped:0 overruns:0 carrier:0 
          collisions:0 txqueuelen:0 
          RX bytes:960 (960.0 b)  TX bytes:960 (960.0 b)
 
http://cbitss.in/
 

0 comments:

Post a Comment