Home AIX UNIX / Linux: 10 Netstat Command Examples

UNIX / Linux: 10 Netstat Command Examples

0
388

Netstat is a command line utility that can be used to list out all the network (socket) connections on a system.

Let us review 10 practical unix netstat command examples.

Back

1. List All Ports (both listening and non listening ports)

List all ports using netstat -a
[root@yum ~]# netstat -a | more
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State      
tcp        0      0 0.0.0.0:ssh             0.0.0.0:*               LISTEN     
tcp        0      0 localhost:smtp          0.0.0.0:*               LISTEN     
tcp        0      0 yum.c.kubernetes-:50122 metadata.google.in:http ESTABLISHED
tcp        0      0 yum.c.kubernetes-:50124 metadata.google.in:http ESTABLISHED
                            
Active UNIX domain sockets (servers and established)
Proto RefCnt Flags       Type       State         I-Node   Path
unix  2      [ ACC ]     STREAM     LISTENING     14601    /var/run/NetworkManager/private-dhcp
unix  2      [ ]         DGRAM                    6738     /run/systemd/notify
List all tcp ports using netstat -at
[root@yum ~]# netstat -at
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State      
tcp        0      0 0.0.0.0:ssh             0.0.0.0:*               LISTEN     
tcp        0      0 localhost:smtp          0.0.0.0:*               LISTEN     
tcp        0      0 yum.c.kubernetes-:50128 metadata.google.in:http ESTABLISHED
tcp        0      0 yum.c.kubernetes-:50130 metadata.google.in:http ESTABLISHED
tcp        0      0 yum.c.kubernetes-:50124 metadata.google.in:http ESTABLISHED
List all udp ports using netstat -au
[root@yum ~]# netstat -au
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State      
udp        0      0 0.0.0.0:bootpc          0.0.0.0:*                          
udp        0      0 0.0.0.0:59548           0.0.0.0:*                          
udp        0      0 localhost:323           0.0.0.0:*                          
udp6       0      0 [::]:40312              [::]:*                             
udp6       0      0 localhost:323           [::]:*
Back

NO COMMENTS

LEAVE A REPLY

Please enter your comment!
Please enter your name here