Table of Contents
As an administrator, there can be many situations when you need to find out that which ports are open on a remote server. We know that when we deploy an application on the network it needs an IP address and the port. This port is then solely used only for one application. Nowadays, running applications behind the firewall is a common practice and sometimes there are situations where we need to check the connectivity to an IPAddress + port from a different machine or outside the local network.
In this article, we will look into the explanation of two different tools through which we can check open ports on remote machine.
Network mapper (nmap)
Nmap is an open-source tool for mac, Linux, UNIX, and windows. It is used for network discovery and security auditing. Nmap scans the network by using specially designed IP packets, it sends these packets to the target host and then analyzes the responses. It provides many useful information, you can use this tool in the following use-cases:
- To get open ports on remote hosts
- For security auditing of firewalls and remote hosts
- Network Vulnerability Detection
- To get remote Host information like operating system,packet filters, service uptime etc
The syntax of nmap command is mentioned in the below code section. For more information regarding options use the manpage
nmap <options> <host_name/network>
nmap Command to check open ports
In the below-mentioned example we will use the nmap command to test the open ports on google.com. First command can be used to check the specific ports and the second command will tell us all the open ports.
nmap -p 80,3000 google.com or nmap google.com
Output of the command
foofunc@ubuntu:~$ nmap -p 80,3000 google.com Starting Nmap 7.80 ( https://nmap.org ) at 2021-10-03 10:18 CEST Nmap scan report for google.com (142.250.185.174) Host is up (0.030s latency). Other addresses for google.com (not scanned): 2a00:1450:4001:811::200e rDNS record for 142.250.185.174: fra16s51-in-f14.1e100.net PORT STATE SERVICE 80/tcp open http 3000/tcp filtered ppp Nmap done: 1 IP address (1 host up) scanned in 1.34 seconds foofunc@ubuntu:~$ foofunc@ubuntu:~$ nmap google.com Starting Nmap 7.80 ( https://nmap.org ) at 2021-10-03 10:19 CEST Nmap scan report for google.com (142.250.185.174) Host is up (0.033s latency). Other addresses for google.com (not scanned): 2a00:1450:4001:811::200e rDNS record for 142.250.185.174: fra16s51-in-f14.1e100.net Not shown: 998 filtered ports PORT STATE SERVICE 80/tcp open http 443/tcp open https Nmap done: 1 IP address (1 host up) scanned in 4.39 seconds foofunc@ubuntu:~$
Telnet
Telnet package allows users to test connectivity to a remote server. Telnet is one of the simplest ways to check connectivity on certain ports. Telnet based on a client-server protocol and data exchanged over TCP connections. Telnet is also available for Mac, Linux, and Windows. It also provides command mode, where it prints a telnet prompt (“telnet> “) and also provide remote access of the machine.
Syntax of Telnet command is mentioned below. For more information regarding options refer the manpage.
telnet <options>
Telnet command to check openports
To check open ports on a remote system we will use the following commands.
telnet google.com 80
Output of the above command
foofunc@ubuntu:~$ telnet google.com 443 Trying 2a00:1450:4001:811::200e... Connected to google.com. Escape character is '^]'. Connection closed by foreign host. foofunc@ubuntu:~$
Also, keep in mind if port is not open on a remote server you will see the below mentioned out put for long time and you might need to send stop the process signal by ctrl+c
foofunc@ubuntu:~$ telnet google.com 3000 Trying 2a00:1450:4001:811::200e... ^C foofunc@ubuntu:~$
Summary
In this article, we discussed how we can check open ports in the remote server through telnet and nmap. Also, there are multiple tools to accomplish a similar thing. Few other tools are nping, netcat etc.
Don’t hesitate to comment if you have any inputs or questions regarding the article.
Thank you for writing this post. I like the subject too.