Linux netstat Alternative

Peter Siegrist cb6b016436 v1.4.2: TIME_WAIT and CLOSE_WAIT removed from listen and established question. 2 лет назад
README.md e723e7e136 v1.4.1 2 лет назад
sinetstat cb6b016436 v1.4.2: TIME_WAIT and CLOSE_WAIT removed from listen and established question. 2 лет назад

README.md

sinetstat

.

An alternative to the standard Linux netstat or ss command.
It can display all TCP/UDP network sockets including (hidden) IPv4-mapped addresses.

Improvements to the original netstat command:
- explore IPv4 in IPv6 listening/established sockets (IPv4-mapped IPv6 addresses)
- prints full output of command including its arguments
- shows UID and PID of the command
- shorten output by hiding repeated entries on reused (SO_REUSEPORT) ports

For a full featured output the script needs root-privileges.
.

This is a Python 2.x/3.x script.
Maybe the shebang line needs to be adjusted, depending on the Python installation of your system.

Direct Download: wget https://git.zweiernet.ch/sigi/sinetstat/raw/master/sinetstat

Then simply try:

# sinetstat -h
usage: sinetstat [-h] [-l] [-e] [-s] [-r] [-w] [-W] [-t] [-u] [-4] [-6]

netstat utility V1.4
2017-2022 by sigi <https://wiki.zweiernet.ch/wiki/sinetstat>

optional arguments:
  -h, --help  show this help message and exit
  -l          Only listening sockets
  -e          Only established sockets
  -s          Show all sockets on reused ports
  -r          Resolve IP-Addresses
  -w          Wide (show cmd)
  -W          Wider (show cmd with arguments)
  -t          Only TCP
  -u          Only UDP
  -4          Only IPv4
  -6          Only IPv6

.

A sample output:

Proto   Local Address             Remote Address            State        UID       PID     Program
-----   -------------             --------------            -----        ---       ---     -------
TCP4    0.0.0.0: 587              0.0.0.0: 0                LISTEN       root      22667   /usr/lib/postfix/master
TCP4    192.168.1.10: 53          0.0.0.0: 0                LISTEN       bind      2991    /usr/sbin/named
TCP4    0.0.0.0: 25               0.0.0.0: 0                LISTEN       root      19763   smtpd
TCP4    192.168.1.10: 993         0.0.0.0: 0                LISTEN       root      22714   /usr/sbin/dovecot
TCP4    0.0.0.0: 995              0.0.0.0: 0                LISTEN       root      22714   /usr/sbin/dovecot
TCP4in6 0.0.0.0: 80               ::: 0                     LISTEN       root      1200    /usr/sbin/apache2
TCP4in6 0.0.0.0: 443              ::: 0                     LISTEN       root      1200    /usr/sbin/apache2
TCP6    ::1: 10025                ::: 0                     LISTEN       root      22667   /usr/lib/postfix/master
TCP6    ::: 587                   ::: 0                     LISTEN       root      22667   /usr/lib/postfix/master
TCP6    ::: 80                    ::: 0                     LISTEN       root      1200    /usr/sbin/apache2
TCP6    ::: 53                    ::: 0                     LISTEN       bind      2991    /usr/sbin/named
TCP6    ::: 25                    ::: 0                     LISTEN       root      19763   smtpd
TCP6    ::: 443                   ::: 0                     LISTEN       root      1200    /usr/sbin/apache2
TCP6    ::: 995                   ::: 0                     LISTEN       root      22714   /usr/sbin/dovecot


(c) 2016-2022 by Siegrist(SystemLoesungen)
Website: https://wiki.zweiernet.ch/wiki/Sinetstat

This program is free software under the terms of the GNU General Public License.

The program is based on a python netstat script that was written by da667 available on https://github.com/da667/netstat who had it adapted from Ricardo Pascal, available on http://voorloopnul.com/blog/a-python-netstat-in-less-than-100-lines-of-code.