Skip to main content

Who is connecting to linux server

netstat -tn

-n: Display numeric only

-t: Display TCP connections only



Who is connected to my linux host - netstat -tn
Who is connecting to linux host: netstat -tn

netstat is not installed on CentOS/RHEL minimal installation by default.

[tuyendq@001 ~]$ which netstat
/usr/bin/which: no netstat in (/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/tuyendq/.local/bin:/home/tuyendq/bin)

Which package does netstat belong to?

[tuyendq@001 ~]$ yum search netstat
Loaded plugins: fastestmirror
Determining fastest mirrors
 * base: mirror.hostduplex.com
 * epel: mirrors.develooper.com
 * extras: repos.lax.quadranet.com
 * updates: mirror.hostduplex.com
zabbix-non-supported                                                                                                4/4
=================================================== Matched: netstat ===================================================
bwm-ng.x86_64 : Bandwidth Monitor NG
dstat.noarch : Versatile resource statistics tool
net-snmp.x86_64 : A collection of SNMP protocol tools and libraries
net-tools.x86_64 : Basic networking tools
python2-psutil.x86_64 : A process and system utilities module for Python
python34-psutil.x86_64 : A process and system utilities module for Python
python36-psutil.x86_64 : A process and system utilities module for Python
unhide.x86_64 : Tool to find hidden processes and TCP/UDP ports from rootkits

Install net-tools package in order to use netstat

[tuyendq@001 ~]$ sudo yum install -y net-tools
[sudo] password for tuyendq:
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirror.scalabledns.com
 * epel: mirrors.develooper.com
 * extras: mirror.scalabledns.com
 * updates: mirrors.usc.edu
Resolving Dependencies
--> Running transaction check
---> Package net-tools.x86_64 0:2.0-0.24.20131004git.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

========================================================================================================================
 Package                   Arch                   Version                                    Repository            Size
========================================================================================================================
Installing:
 net-tools                 x86_64                 2.0-0.24.20131004git.el7                   base                 306 k

Transaction Summary
========================================================================================================================
Install  1 Package

Total download size: 306 k
Installed size: 918 k
Downloading packages:
net-tools-2.0-0.24.20131004git.el7.x86_64.rpm                                                    | 306 kB  00:00:01
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : net-tools-2.0-0.24.20131004git.el7.x86_64                                                            1/1
  Verifying  : net-tools-2.0-0.24.20131004git.el7.x86_64                                                            1/1

Installed:
  net-tools.x86_64 0:2.0-0.24.20131004git.el7

Complete!

Check netstat version

[tuyendq@001 ~]$ netstat --version
net-tools 2.10-alpha
Fred Baumgarten, Alan Cox, Bernd Eckenfels, Phil Blundell, Tuan Hoang, Brian Micek and others
+NEW_ADDRT +RTF_IRTT +RTF_REJECT +FW_MASQUERADE +I18N +SELINUX
AF: (inet) +UNIX +INET +INET6 +IPX +AX25 +NETROM +X25 +ATALK +ECONET +ROSE -BLUETOOTH
HW:  +ETHER +ARC +SLIP +PPP +TUNNEL -TR +AX25 +NETROM +X25 +FR +ROSE +ASH +SIT +FDDI +HIPPI +HDLC/LAPB +EUI64
[tuyendq@001 ~]$

Check open ports with netstat, ss, lsof

netstat -tupln | grep LISTEN
sudo ss -tupln | grep LISTEN
sudo lsof -i -P -n | grep LISTEN

Popular posts from this blog

How to charge your device from USB Port

First of all, check BIOS Settings of your laptop or desktop Dell Look for USB PowerShare BIOS Settings: USB PowerShare Lenovo Look for Always On USB Charge in Off Mode BIOS Settings: Enable Always On USB Charge in Off Mode

Youtube: Notes

Coursera: Notes

Learn Without Limits - Build skills with courses, certificates, and degrees online from world-class universities and companies.