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

Linux command: swapon

Two ways to check if swap partition exists.

[Microsoft Outlook]: Set .pst and .ost files location with ForcePSTPath Registry Key

Set .pst and .ost files location with ForcePSTPath Registry Key The ForcePSTPath registry key is supported by Microsoft Outlook 2003 and later. In Microsoft Outlook 2003 and 2007, it applies to new profiles only. Microsoft Outlook 2013 and Outlook 2016 it applies to new accounts created in a profile. Microsoft Outlook 2013 saves .pst in   %userprofile%\Documents\Outlook Files folder by default. We can change that default setting by adding a new string registry key called ForcePSTPath and set the value to the folder that we want to save those files. Set Microsoft Outlook 2013 always save new .pst and .ost files to D:\Data\Mail folder OST file reached the maximum size The OST File Has Reached The Maximum Size

[PowerShell]: Powershell script uploading backup databases to ftp server

Author:  Enrique Puig Nouselles http://gallery.technet.microsoft.com/scriptcenter/80647f66-139c-40a4-bb7a-04a2d73d423c Nhu cầu - Học sử dụng Powershell và áp dụng vào thực tế - Server chạy MS SQL được backup mỗi ngày và lưu các file backup ở folder mặc định "C:/Program Files/Microsoft SQL Server/MSSQL11.MSSQLSERVER/MSSQL/Backup" - Upload các file database backup về một ftp server khác để lưu "offsite" # Begin script # Thanks to: Enrique Puig Nouselles http://gallery.technet.microsoft.com/scriptcenter/80647f66-139c-40a4-bb7a-04a2d73d423c # Khai báo folder chứa các file backup database, dưới đây là folder backup mặc định của MS SQL 2012 $Dir="C:/Program Files/Microsoft SQL Server/MSSQL11.MSSQLSERVER/MSSQL/Backup"   # ftp server $ftp = "ftp://IPAddres/subfolder/subsubfolder" $user = "usernamehere" $pass = "passwordhere" # DO NOT use $(Get-Date), use $d variable instead, otherwise SQL Agent gets error "The...