Netstat is one of the most used commands by   system admins to checks the network and protocols  related to his machine. you can also list out all your UDP or TCP  connections (Sockets),

Lets give Some Examples of netstat . you can also  type netstat –help or man netstat to  see more options about the netstat usage.

 

What  are the netstat top 10 commands  ?

1- List all Connections  netstat -a

The command  shows all   connection from all protocols and sockets.  but this  command  still now  filtered, you see too  much  connection

screenshot_20161027_202322

 

2-Show    TCP/UDP  connection   

2-1-Show  all  TCP connections : 

screenshot_20161027_202821

2-2-Show all UDP Connections 

screenshot_20161027_202844

As  you see  above netstat  is trying  to get  DNS lookup (Hostnames) of remote  servers, disabling  this option speeding up the  answer of  netstat . lets give this example   of  tcp   connection  netstat  -atn   (a= all   t= tcp   n =  numeric  ( dont resolve names) 

screenshot_20161027_203923

3-List  out  all  Listening connections ( Daemons)

in this command  you see all ports open  to receive connection from  other  machines

Like sshd  or  httpd  or samba or DNS  …

netstat  -atp  ( all – tcp- listening )   you can also replace tcp t with udp  u . or  use them both with tcpudp  (tp)

screenshot_20161027_211824

4-Find PID  and USER  behind  every connection

This is very important to get  the Processes ID and the software ( program  behind)

screenshot_20161027_220449

 if you want to see the Process + the user behind.  use the bellow command  .  please  note  the  Process ID should only run under  root  user.

The e option  is  for  extended  information  (   user and  Inode)

screenshot_20161027_221840

The  option ne in netstat  is  showing UID  user instead  of username 

screenshot_20161027_222202

5-Show netstat output continuously

you   also  use  grep  after  to make some filters 

6-Show statistics 

This  command will show all related  network statics  like total  packets  per protocol

The command  is  netstat  -s

screenshot_20161027_223012

7-Ethernet   interfaces 

you  can use this  command  to   see you Ethernet  Cards   and you IP /network configuration  like ip   broadcast  mask , this command if  good  alternative for ifconfig  command 

screenshot_20161027_223600

8-Display Routing and  gateway 

The Kernel Ip routing Tables will displayed , you can see now your gateway in ur second Column

screenshot_20161027_224012

9-Display  Multicasting  Table 

This Command will Display multicast group membership information for IPv4 and IPv6.

screenshot_20161027_224353

10- All Unix   Listening  Ports 

All  Linux  Listening Ports  displayed  with  netstat -lx

screenshot_20161027_225256

 

Netstat  is one of  the  most used linux command  by admins  to check  their  networks activities . and  there is many  other Netstat   Linux  commands  to Specify   and filer  other  things .

Please  let us know if you  know any specified  commands or you have  some issues  to get   information from your network

Spread the love

LEAVE A REPLY

Please enter your comment!
Please enter your name here