Linux netstat Alternative

boson 6c968c4174 v1.4: - hide multiple socket listing on reused Ports (SO_REUSEPORT) 1 year ago
README.md 6c968c4174 v1.4: - hide multiple socket listing on reused Ports (SO_REUSEPORT) 1 year ago
sinetstat 6c968c4174 v1.4: - hide multiple socket listing on reused Ports (SO_REUSEPORT) 1 year ago

README.md

sinetstat

An alternative to the standard Linux netstat which shows you all network sockets including hidden IPv4 in IPv6 mapped.

Improvements to the original netstat command:

  • explore IPv4 in IPv6 listening sockets (IPv4-mapped IPv6 addresses)
  • shows real command and arguments
  • shows the UID of the command
  • hide multiple entries on reused (SO_REUSEPORT) ports

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.

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

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 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.