UNIX-Linux Netstat Command Examples
UNIX-Linux Netstat Command Examples
Netstat command displays various network related information such as network connections, routing tables, interface statistics, masquerade connections, multicast memberships etc., In this article, let us review 10 practical unix netstat command examples.
*:*
0 *:bootpc
*:*
Proto RefCnt Flags Path unix 2 [ ACC ] /tmp/.X11-unix/X0 unix 2 [ ACC ] /var/run/acpid.socket
Type
State
I-Node
STREAM
LISTENING
6135
STREAM
LISTENING
5140
*:*
0 localhost:ipp
*:*
0 *:smtp
*:*
0 localhost:ipp
[::]:*
Active Internet connections (servers and established) Proto Recv-Q Send-Q Local Address Address State udp udp udp 0 0 0 0 *:bootpc 0 *:49119 0 *:mdns Foreign
*:*
0 localhost:ipp
[::]:*
0 *:49119
*:*
Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Address State tcp LISTEN tcp LISTEN tcp6 LISTEN 0 0 localhost:30037 Foreign
*:*
0 *:smtp
*:*
0 localhost:ipp
[::]:*
*:* *:*
Proto RefCnt Flags Path unix 2 [ ACC ] private/maildrop unix 2 [ ACC ] public/cleanup unix 2 [ ACC ] private/ifmail unix 2 [ ACC ] private/bsmtp
Type
State
I-Node
STREAM
LISTENING
6294
STREAM
LISTENING
6203
STREAM
LISTENING
6302
STREAM
LISTENING
6306
11635 requests sent out Icmp: 0 ICMP messages received 0 input ICMP message failed. Tcp: 582 active connections openings 2 failed connection attempts 25 connection resets received Udp: 1183 packets received 4 packets to unknown port received. .....
Show statistics for TCP (or) UDP ports using netstat -st (or) -su
# netstat -st
# netstat -su
This also speeds up the output, as netstat is not performing any look-up.
# netstat -an
If you dont want only any one of those three items ( ports, or hosts, or users ) to be resolved, use following commands.
# netsat -a --numeric-ports
# netsat -a --numeric-hosts
# netsat -a --numeric-users
tcp 1 1 ramesh-laptop.loc:52564 101.11.169.230:www CLOSING tcp 0 0 ramesh-laptop.loc:43758 server-101101-43-2:www ESTABLISHED tcp 1 1 ramesh-laptop.loc:42367 101.101.34.101:www CLOSING ^C
Kernel IP routing table Destination Gateway MSS Window irtt Iface 192.168.1.0 0 0 link-local 0 0 default 0 0 * 0 eth2 * 0 eth2 192.168.1.1 0 eth2 Genmask Flags
255.255.255.0
255.255.0.0
0.0.0.0
UG
Note: Use netstat -rn to display routes in numeric format without resolving for host-names.
26196
0 0
26883
0 0
Display extended information on the interfaces (similar to ifconfig) using netstat -ie:
# netstat -ie
Kernel Interface table eth0 Link encap:Ethernet HWaddr 00:10:40:11:11:11 MTU:1500 Metric:1
UP BROADCAST MULTICAST
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)
Memory:f6ae0000-f6b00000