IT Training Modules - Classroom Tasks

IT Training Module1 Homepage
Home | How To | IP Addresses and Subnets | Command Line Tools | Checking for Open Ports | Services and Firewalls | Server / Client Setup | Install and Configure DHCP | DNS Service | Error Logs / Network Analysis |

Checking for Open Ports.

In this NETSTAT exercise we have two commands to look at. The first lists active ports along with the name of the process that’s using them. Most of the time, that command be all you need to identify open ports although, sometimes, the process name won’t help you identify what app or service actually has a port tied up. For those times, you’ll need to list active ports along with their process identifier numbers and then look those processes up in Task Manager.

First, you’ll need to open the Command Prompt in administrator mode. Hit Start, and then type “command” into the search box. When you see “Command Prompt” appear in the results, right-click it and choose “Run as administrator.”you can also pin the prompt to the taskbar for later use. To open as administrator right click to select “Run as administrator.”

Use the netstat command to display port information.

1.   Open a command prompt. Click start and type “cmd”.

2.   Type the following netstat command “netstat /?” to show help. Help can be found for all commands in this way.

3.   Use netstat -a to look at the ports on your computer.

NOTE: If 0.0.0.0 is shown as the local address then the port is open on all NIC’s attached to your machine. 127.0.0.0 is only open for lookback. We will cover loopback in the next section.

TCP    192.168.0.2:52798      40.67.251.132:https    ESTABLISHED

The example above shows that port 52798 is in use and where the destination is located.

IPv6 Addresses are also shown. They will correspond with IPv4 ports.

View Port Used Along with Process Names

At the Command Prompt, type the following text and then hit Enter: netstat -ab

After you hit Enter, the results may take a minute or two to fully display, so be patient.

4.   If you’d like to make things a little easier, you can also pipe the results of the command to a text file. You could then just search the text file for the port number you’re after.

Enter: netstat -ab > C:\training\Netstat-output.txt

Check out the file output to the C: Training folder.

5.   If the name of the process for the port number you’re looking up makes it difficult to tell what the related app is, you can try a version of the command that shows process identifiers (PIDs) rather than names. 

  netstat -aon 

The column at the far right lists PIDs, so just find the one that’s bound to the port that you’re trying to troubleshoot.

6.   Next, open up Task Manager by right-clicking any open space on your taskbar and choosing “Task Manager

7.   Click on More details in the lower right area of the Task Manager and then select the “Details” tab.

8.   Sort the list of process by the “PID” column and find the PID associated with the port you’re investigating.

9.  You might be able to tell more about what app or service has the port tied up by looking at the Services tab and check the “Description” column.

Use PowerShell to test connection to ports

Powershell Test-NetConnection can also be used to test if a port is open.

Test-NetConnection -ComputerName ams-dc1 -Port 21 -InformationLevel "Detailed"

Use Telnet to test connection to ports

Telnet is a computer protocol that was built for interacting with remote computers. Telnet utility allows users to test connectivity to remote machines and issue commands through the use of a keyboard. Though most users opt to work with graphical interfaces, Telnet is one of the simplest ways to check connectivity on certain ports.

Windows 10 (Client Computer AMS-CL1)

Telnet is disabled by default in Window’s settings, so you need to turn it on before you can do anything. If you want to use the Telnet application included with Microsoft Windows 10.

You first need to enable the program following the instructions below:

1.   If you want to enable Telnet via the command line (cmd), open the Command Prompt with elevated privileges (“as Administrator”) and run the following command:

Dism /Online /Enable-feature /FeatureName:TelnetClient

Windows Server (AMS-DC1)

You first need to enable the program following the instructions below:

1.   If you want to enable Telnet via the command line (cmd), open the Command Prompt with elevated privileges (“as Administrator”) and run the following command:

Dism /Online /Enable-feature /FeatureName:TelnetClient

2.   You can use the following PowerShell command to achieve the same result:

Install-WindowsFeature -name Telnet-Client

Install Telnet from Control Panel Windows 10 / 11

1.   Open “Control Panel“.
2.   Open “Programs“.
3.   Select the “Turn Windows features on or off” option. Slide down to find Telnet Client.

4.   Check the “Telnet Client” box.
5.   Click “OK“. A box will appear that says “Windows features” and “Searching for required files“.

When complete, the Telnet client should be installed in Windows.

Install Telnet on Windows Server 2022.

If using a server for the telnet exercise, follow the instructions below. You can of course use the CMD and Powershell methods.

1.   Open Server Manager
2.   Select “Add roles and features” from the number 2 link.
3.   Click next until you reach the Features screen.
4.   From Features select Telnet Client. Click Next.

5.   Complete the installation.

How to test open/closed ports using telnet.

When it comes to checking if a network port is opened or closed on a remote computer, Telnet is a good choice of tool to use. Ports that are left open for no reason are a security risk that can be exploited by malicious programs and viruses. At the same time, if legitimate software communicates through a selected port, having that port closed will make the program throw errors and malfunction.

One of the most efficient ways is to use the network protocol Telnet. Telnet allows the user to test individual ports and see whether they are open or not.

You can use either Command Prompt or PowerShell.

You can check if a port is open on a device by issuing the telnet command. If it is open, you will see a blank screen after issuing the command:

1.   telnet [domainname or IP address] [port]

 [domainname or IP] is the domain name or IP address of the server to which you are trying to connect

 [port] is the port number on which the server is listening

2.   For example, if I wanted to test whether the device 192.168.0.10 had it’s webserver (port 80) running:

telnet [IP  Address of your DC] 80 ex. (telnet 192.168.0.1 80).

Do you see an Port Open?

Telnet has opened a socket to the web service on port 80. It is now ready for text commands. Therefore, the port is open.

NOTE: A failed connection will be accompanied by an error message. It can indicate either a closed port or the fact that the indicated remote server is not listening on the provided port. We will not send text commands to a web service.

3.   Press the backspace button on your keyboard. You will see some HTML reply from the web service on port 80. Command Prompt shows HTML info.  PowerShell will not show this.
4.   Next we will look at an unused port to see what a Closed Port looks like. Type telnet [IP  Address of your DC] 7610.

NOTE: After some time a socket could be opened so no connection is available.

5.   Connecting telnet to a service with text interface

NOTE: By connecting to a service with a text interface you can prove connection and interact with the service.

6.   Type telnet [IP  Address of your DC] 21

NOTE: Port 21 is used for FTP. FTP provides a service which can support a telnet command line interface. In this case telnet has made a connection to the service which is now ready to accept text commands from the command prompt. If you know any command line commands for FTP try them out.

7.   SMTP test port 25 (Add exercise details) 

8.   You may also like to try out other telnet clients. PuTTY is a great free one.

You can use PuTTY with some connections related to SSL and other secure connections. If you have some time, download a copy to your client.

Research the following.

What is a protocol?
What is the TCP Protocol?

Discuss TCP/IP and other protocols with the group.

HINT: PROTOCOL - COMPUTING
A set of rules governing the exchange or transmission of data between devices. Find out more using the browser of your choice.

Footer