Monday, February 10, 2020

How to Check Port Status and How to Check Whether port is listening or not on the server?

How check port status and port is listening or not on the server?

There are several methods to verify particular port is opened on the server or not.

There are several methods to verify particular port listening or not in the server

Purpose of this blog is to

1. How to verify the port is opened on the server or not?
2. How to verify the particular port is listening or not?

***** Using nmap command we can check the port status

Check the port 22 status on the server whether it has opened or not:

[mramadur@CT-mnn-01 ~]$ nmap -p 22 -Pn ex01db01
Starting Nmap 5.51 ( http://nmap.org ) at 2016-03-17 06:38 GMT
mass_dns: warning: Unable to determine any DNS servers. Reverse DNS is disabled. Try using --system-dns or specify valid servers with --dns-servers
Nmap scan report for ex01db01 (192.168.1.10)
Host is up (0.21s latency).
rDNS record for 192.168.1.10: ex01db01.prod.mnn.net
PORT   STATE SERVICE
22/tcp open  ssh ------------------- which means post is opened 
Nmap done: 1 IP address (1 host up) scanned in 0.25 seconds


[oracle@ CT-mnn-01 bin]$ nmap -p 22 -Pn ex01db02
Starting Nmap 5.51 ( http://nmap.org ) at 2016-03-17 06:02 GMT
mass_dns: warning: Unable to determine any DNS servers. Reverse DNS is disabled. Try using --system-dns or specify vali                                                 d servers with --dns-servers
Nmap scan report for dal-ep01dbadm01.prod.nmm.com (192.168.1.11)
Host is up.
PORT   STATE    SERVICE
22/tcp filtered ssh ------------------- which means post is not opened
Nmap done: 1 IP address (1 host up) scanned in 2.07 seconds


***** Using telnet command we can check the port status

[infa@ETLD01 Scripts]$ telnet 192.168.1.100 22
Trying 10.24.6.26...
Connected to 192.168.1.100. ------- Which means port 22 is opened
Escape character is '^]'.
SSH-2.0-OpenSSH_7.4
^C
[infa@ETLD01 Scripts]

[infa@ETLD01 Scripts]$ telnet 192.168.1.100 25
Trying 10.24.6.26...
telnet: connect to address 192.168.1.100: Connection refused ------- Which means port 22 is not opened
[infa@ETLD01 Scripts]$


***** Check particular port is listening or not using netstat 

Port 8015 is not listening

[root@s616455s233 ~]# netstat -an | grep LISTEN | grep 8015
[root@s616455s233 ~]# netstat -anp |grep 8015


Port 7741 is not listening

[root@s616455s233 ~]# netstat -an | grep LISTEN | grep 7741
[root@s616455s233 ~]# netstat -anp |grep 7741

Port 7777 is not listening

[root@s616455s233 ~]# netstat -an | grep LISTEN | grep 7777
tcp        0      0 0.0.0.0:7777            0.0.0.0:*               LISTEN      24179/httpd.worker
tcp        0      0 127.0.0.1:9428          127.0.0.1:7777          TIME_WAIT   -
tcp        0      0 127.0.0.1:9370          127.0.0.1:7777          TIME_WAIT   -
tcp        0      0 127.0.0.1:9312          127.0.0.1:7777          TIME_WAIT   -
[root@s616455s233 ~]# netstat -anp |grep 7777
tcp        0      0 0.0.0.0:7777            0.0.0.0:*               LISTEN      24179/httpd.worker
tcp        0      0 127.0.0.1:9428          127.0.0.1:7777          TIME_WAIT   -
tcp        0      0 127.0.0.1:9370          127.0.0.1:7777          TIME_WAIT   -
tcp        0      0 127.0.0.1:9312          127.0.0.1:7777          TIME_WAIT   -

Regards,
Mallik

No comments:

Post a Comment

Query taking more time?  1. DML Query (Insert, Update,) Cause: locks / deadlocks  Fix/Solution: kill / Ask user to do commit/rollback   2. S...