Check if remote port is listening using telnet

If you are using Windows , you can enable telnet client by referring Enable telnet in Windows 10

telnet remotehost port

For example,below command check if bing.com has port 443 port listening

root@ubuntu:~# telnet bing.com 443
Trying 13.107.21.200...
Connected to bing.com.
Escape character is '^]'.
^CConnection closed by foreign host.
root@ubuntu:~#

Check if remote port is listening using nc

root@ubuntu:~# nc -zv bing.com 443
Connection to bing.com 443 port [tcp/https] succeeded!
root@ubuntu:~#
  • -z : Report connection status only
  • -v : Set verbosity level ( can be used multiple times)

To avoid long time waiting , option -w can be used to specify the connect timeout

Below command set the connection timeout to 3 seconds.

root@ubuntu:~# nc -zv -w 3 bing.com 444
nc: connect to bing.com port 444 (tcp) timed out: Operation now in progress
nc: connect to bing.com port 444 (tcp) timed out: Operation now in progress
nc: connect to bing.com port 444 (tcp) failed: Network is unreachable
root@ubuntu:~# 

Check if remote port is listening using nmap

Below command checks if bing.com has port 80 listening

root@ubuntu:~# nmap -p 80 bing.com
Starting Nmap 7.91 ( https://nmap.org ) at 2021-08-03 01:04 PDT
Nmap scan report for bing.com (13.107.21.200)
Host is up (0.0070s latency).

PORT   STATE SERVICE
80/tcp open  http

Nmap done: 1 IP address (1 host up) scanned in 10.42 seconds
root@ubuntu:~#

Scan multiple ports on remote system using nmap

root@ubuntu:/home/j# nmap -p 80-85  bing.com
Starting Nmap 7.91 ( https://nmap.org ) at 2021-08-03 01:12 PDT
Nmap scan report for bing.com (204.79.197.200)
Host is up (0.0077s latency).
Other addresses for bing.com (not scanned): 13.107.21.200 2620:1ec:c11::200
rDNS record for 204.79.197.200: a-0001.a-msedge.net

PORT   STATE    SERVICE
80/tcp open     http
81/tcp filtered hosts2-ns
82/tcp filtered xfer
83/tcp filtered mit-ml-dev
84/tcp filtered ctf
85/tcp filtered mit-ml-dev

Nmap done: 1 IP address (1 host up) scanned in 1.43 seconds
root@ubuntu:/home/j#

nmap scan all port towards target system(1-65535) , maybe slow

nmap -p- hostname

nmap scan most common ports

nmap -F hostname