Skip to main content

Check for open ports in Windows


How to check which ports are open?

How to check the ports that a particular application is using?

Questions that will pop up when things go wrong, when an application does not work as expected.

When replication does not work, or access denied error occurs.

Or when an error occurs that states, a particular port is in use. Like, Port 80 is in use.

Of course the error, just gives an idea that a port is in use by another application or program but does not explicitly tells that which specific application or program is using the port.

This is where troubleshooting is necessary. An example below is given.

One scenario that I can think of is when setting up Active Directory replication; whether in the real world, or in a test lab environment.

Or even simply a port forwarding scenario on web hosting, CCTV installation or other setup,  if it doesn’t work would require troubleshooting or to check whether ports are open, ports are listening or not.

Netstat command in Windows is a good start to check or start troubleshooting and using Netstat 
parameters, will be able to check ports that are open and which application is using the port.

There is also one good tool provided by Sysinternals, called TCPView that provides comprehensive output on ports troubleshooting.

Nmap is also a good tool, which has been a familiar tool on the Linux world.

But Nmap got a package for Windows operating system also.

Typing “netstat /?” in Windows command prompt will show the available parameters for netstat.

Typing “netstat –ano”, (don’t include quotes when typing on the command prompt). This will show the protocol being used by the port and also the PID (process ID number) of the application that is using the port.

Task Manager can be sued to view the PID or process id number.

Or if you are using Windows 7 or above OS version, PowerShell can easily check the process ID or PID number.

Open PowerShell ISE and type get-process –id “PID” number that you want to query.

Example below shows that the “netstat” output has a PID number of 3836 and the connection is established using TCP protocol. Port being used is 49316 and 40003

C:\Windows\System32>netstat -ano
Active Connections
  Proto    Local Address              Foreign Address           
  TCP    192.168.1.8:49316      192.168.74.24:40003   

  State                          PID
  ESTABLISHED    3836

And the PID number can be viewed using PowerShell, to check which application is using the particular PID number.

Get-process -id "3836"

Example output:
Handles  NPM(K)    PM(K)      WS(K)    VM(M)      CPU(s)                                           
-------       ------          -----            -----             -----          ------             
   1289     147         189248     199684        549 1,    414.26   

 Id       ProcessName                     
  --       -----------   
  3836  Skype                                                                                                                        

Above example, is checking from inside the local network. But if your application goes outside the local network or need WAN connectivity. Then a different approach of checking the ports whether they are open or not.

And for WAN connectivity to open ports will involve configuring router, firewall or other setup and solely depends on the network infrastructure. You can search the web for “Port Forwarding Configuration”, but don’t open ports for the sake of opening ports without any reason or just for fun.

Make sure you know exactly what you are doing, open ports on your system are great, great opportunity for others to manipulate and abused your system.

Dyn website provide a very good tool to check open or closed ports:


To use this tool need to have a Dyn account.

Well, these are just network basic stuff and hope it helps someone.

The methods above can be used also, to check what  application or process is using the port.


  

Comments

Popular posts from this blog

Notepad++ convert multiple lines to a single line and vice versa

Notepad++ is an awesome text editing tool, it can accept regex to process the text data. If the data is in a “.csv” format or comma separated values which is basically just a text file that can either be opened using a text editor, excel or even word. Notepad++ can process the contents of the file using regex. Example if the data has multiple rows or lines, and what is needed is to convert the whole lines of data into a single line. Notepad++ can easily do it using regex. However, if the data is on a single line and it needs to be converted into multiple lines or rows then regex can also be used for this case. Here’s an example on how to convert multiple rows or lines into a single line. Example data: Multiple rows, just a sample data. Press Ctrl+H, and  on "Find what" type: [\r\n]+ and on "Replace with" type with: , (white space) --white space is needed if need to have a space in between the data. See image below, "Regular Expression" must be se

WMIC get computer name

WMIC get computer model, manufacturer, computer name and  username. WMIC is a command-line tool and that can generate information about computer model, its manufacturer, its username and other informations depending on the parameters provided. Why would you need a command line tool if there’s a GUI to check? If you have 20 or 100 computers, or even more. It’s quite a big task just checking the GUI to check the computer model and username. If you have remote computers, you need to delegate someone in the remote office or location to check. Or you can just write a batch file or script to automate the task. Here’s the code below on how get computer model, manufacturer and the username. Open an elevated command prompt and type:     wmic computersystem get "Model","Manufacturer", "Name", "UserName" Just copy and paste the code above, the word “computersystem” does not need to be change to a computer name. A

How to check office version from command line

The are quite a few ways to check office version it can be done via registry, PowerShell or VBScript and of course, good old command line can also do it. Checking Windows office version whether it is Office 2010, Office, 2013, Office 2016 or other version is quite important to check compatibility of documents; or just a part of software inventory. For PowerShell this simple snippet can check the office version: $ol = New-Object -ComObject Excel.Application $ol . Version The command line option will tell you where’s the path located; the result will also tell whether office is 32-bit, 64-bit and of course the version of the office as well. Here’s the command that will check the office version and which program directory the file is located which will tell whether it’s 32-bit or 64-bit. Command to search for Excel.exe: DIR C:\ /s excel.exe | find   /i "Directory of"  Above command assumes that program files is on  C: drive. Sample Outpu