Как посмотреть порты на windows server 2016

How to check open/listening ports in Windows Server-based operating systems.

Right-click on the start menu and click ‘Windows PowerShell (admin), in the new PowerShell window that has just opened up type: netstat -an this will show you all open ports and which IP they are listening on:

PS C:\Users\Administrator> netstat -an

Active Connections

  Proto  Local Address          Foreign Address        State
  TCP    0.0.0.0:135            0.0.0.0:0              LISTENING
  TCP    0.0.0.0:445            0.0.0.0:0              LISTENING
  TCP    0.0.0.0:2179           0.0.0.0:0              LISTENING
  TCP    0.0.0.0:3389           0.0.0.0:0              LISTENING
  TCP    0.0.0.0:5985           0.0.0.0:0              LISTENING
  TCP    0.0.0.0:47001          0.0.0.0:0              LISTENING
  TCP    0.0.0.0:49664          0.0.0.0:0              LISTENING
  TCP    0.0.0.0:49665          0.0.0.0:0              LISTENING
  TCP    0.0.0.0:49666          0.0.0.0:0              LISTENING
  TCP    0.0.0.0:49667          0.0.0.0:0              LISTENING
  TCP    0.0.0.0:49668          0.0.0.0:0              LISTENING
  TCP    0.0.0.0:49669          0.0.0.0:0              LISTENING
  TCP    0.0.0.0:49670          0.0.0.0:0              LISTENING
  TCP    22.156.188.131:139     0.0.0.0:0              LISTENING
  TCP    22.156.188.131:3389    174.143.175.2:42252    ESTABLISHED
  TCP    22.156.188.131:3389    182.169.114.207:64454  ESTABLISHED
  TCP    22.156.188.131:3389    191.220.163.122:57588  ESTABLISHED
  TCP    22.156.188.131:3389    191.220.163.131:31525  ESTABLISHED
  TCP    22.156.188.131:3389    191.220.163.151:23613  ESTABLISHED

As we can see above for example port 123 is listening on IP 22.156.188.131 we can also see that a connection to port 3389 (WIndowd RDP) is currently established from IPS 174.143.175.2, 182.169.114.204, and, 191.220.163.131.

If you are expecting to be able to connect to a specific service that you know runs on a specific port and you can see it when listing the open/established ports as above yet it fails to connect there is a very good chance that you have not opened that port up in the Windows Firewall if however, you do not see that the port is listening for connections then there is a good chance that the service itself is not correctly configured so you need to look at that before the firewall.

If the output is just to much on a busy server for example you can narrow this down to specific ports, Linux users will have probably noticed by now that grep is not available in Windows PowerShell, never fear though as ‘Select-String’ does the same job, for the most part, the example below will show you how to check specific ports in the following example port 3389.

PS C:\Users\Administrator> netstat -an | Select-String 3389

  TCP    0.0.0.0:3389           0.0.0.0:0              LISTENING
  TCP    22.156.188.131:3389    182.169.114.207:64454  ESTABLISHED

As an extra tip, if you are concerned that the client software you are using might be the thing preventing connection and the server side listening connection is on TCP you can also use telnet to test the connection

telnet 20.30.40.50 3389

If the connection to the port is ok you will see:

Trying 20.30.40.50...
Connected to 20.30.40.50.
Escape character is '^]'.

That means the connection has been established to the remote server so you can start troubleshooting the client software if it is not connecting, if however, nothing happens and eventually it just times out then a connection to the port on the server cannot be established at all so you need to investigate the server-side software and network

Add a sub network interface or additional IP address in Windows ServerConnecting to Linux server over SSH from Windows

Статья обновлена: 10 сентября 2021
ID: 101

Чтобы посмотреть список открытых портов:

  1. Откройте командную строку. Инструкция в статье.
  2. Выполните команду:

netstat -a

  1. Нажмите Enter на клавиатуре.

Переход к просмотру списка открытых портов

Вы получите список открытых портов в Windows.

Спасибо за ваш отзыв, вы помогаете нам становиться лучше!

Спасибо за ваш отзыв, вы помогаете нам становиться лучше!

Несмотря на то, что в Windows есть множество инструментов для диагностики проблем в TCP/IP сетях (ping, telnet, pathping и т.д.), не все они позволяют в удобном виде проверить состояние или выполнить сканирование открытых сетевых портов на удаленном сервере. Утилита Portqry.exe является удобным инструментом проверки доступности TCP/UDP портов на удаленном сервере при диагностике проблем, связанных с функционированием различных сервисов, а также наличием файерволов и межсетевых экранов в TCP/IP сетях. Чаще всего утилита Portqry используется как более функциональная замена telnet, и в отличии от telnet, позволяет также проверять открытые UDP порты.

Содержание:

  • Используем PortQry для сканирования открытых UDP и TCP портов
  • Расширенный статус сетевых служб в PortQry
  • Графический интерфейс для Portqry

Используем PortQry для сканирования открытых UDP и TCP портов

Первая версия Portqry для Windows Server 2003 некорректно работает с более новыми ОС (Windows Server 2008 и выше), поэтому в дальнейшем была выпущена вторая версия утилиты PortQryV2. Именно эту версию и стоит использовать сегодня(скачать утилиту PortQryV2 можно по ссылке).

В Windows 10 вы можете установить portqry через менеджер пакетов Chokolatey:

choco install portqry

Скачайте и распакуйте архив PortQryV2.exe. Запустите командную строку и перейдите в каталог с утилитой, например:

cd c:\tools\PortQryV2

каталог portqry_v2

Чтобы проверить доступность DNS сервера с клиента, необходимо проверить открыты ли на нем 53 порты TCP и UDP. Формат команды проверки доступности портов на удаленном сервере следующий:

PortQry -n server [-p protocol] [-e || -r || -o endpoint(s)]

-n – имя или IP адрес сервера, доступ к которому нужно проверить
e – номер порта для проверки (от 1 до 65535)
r – диапазон портов для проверки (например, 1:80)

p – по какому протоколу выполняется проверка. Это может быть TCP, UDP или BOTH (по умолчанию используется TCP).

Примечание. В отличии от комадлета PowerShell Test-NetConnection, который может использоваться только для проверки доступности TCP портов, утилита PortQry поддерживает и TCP и UDP протоколы.

В нашем примере команда будет такой:

PortQry.exe –n 10.1.10.6 -p both -e 53

PortQry проверка доступности udp и tcp портовУтилита Portqry для каждого указанного порта вернет один из трех статусов доступности:

  • Listening – означает, что указанный порт доступен (принимает соединения), ответ от него получен;
  • Not Listening – на целевой системе не запушен процесс (служба), который бы принимал подключения на указанном порту. Portqry получила ответ ICMP «Destination Unreachable — Port Unreachable» при проверке UDP порта, или TCP пакет с флагом Reset;
  • Filtered – утилита PortQry не получала ответа от указанного порта либо ответ был отфильтрован. Т.е. на целевой системе либо не слушается данный порт, либо доступ к нему ограничен файерволом или настройками системы. По умолчанию TCP порты опрашиваются 3 раза, а UDP – один.

В нашем примере, DNS сервер доступен с клиента и по TCP и по UDP.

TCP port 53 (domain service): LISTENING
UDP port 53 (domain service): LISTENING

С помощью атрибута o, можно указать последовательность портов, которых нужно просканировать:

portqry -n 10.1.10.6  -p tcp -o 21,110,143

Следующая команда выполнит сканирование диапазона “низких” TCP портов и вернет список доступных портов, которые принимают подключения (утилита работает в режиме сканера открытых портов):

portqry -n 10.1.10.6  -r 1:1024 | find ": LISTENING"

Можно сохранить результаты сканирования открытых портов в текстовый файл:

portqry -n 10.1.10.6 -p tcp -r 20:500 -l logfile.txt

В утилите portqry есть интерактивный режим:

portqry –i

Теперь в приглашении PortQry Interactive Mode можете указать имя удаленного компьютера и порт.

node srv-lic
set port=80

Чтобы выполнить проверить порт на указанном сервере нажмите q и Enter.

portqry интерактивный режим сканирования в командной строке

С помощью аргументов –wport и -wpid можно выполнить мониторинг состояния указанного порта (wport), или всех портов, связанных с указанным процессом (wpid) на локальном хосте.

Например, следующая команда в течении 10 минут будет выполнять проверку доступности указанного локального порта (например, RDP порта 3389), и если его статус изменится, уведомит администратора об этом (подробный лог будет доступен в файле LogFile.txt). Чтобы остановить мониторинг, нажмите
Ctrl-C
:

portqry -wport 3389 -wt 600 –l LogFile.txt -y -v

Можно получить информацию об открытых портах и активных TCP/UDP соединениях на локальном компьютере:

portqry.exe -local

Расширенный статус сетевых служб в PortQry

В утилите PortQry имеется встроенная поддержка некоторых сетевых служб. Это LDAP, Remote Procedure Calls (RPC), почтовые протоколы (SMTP, POP3 и IMAP4), SNMP, FTP/ TFTP, NetBIOS Name Service, L2TP и другие. Кроме проверки доступности этих стандартных портов этих служб, утилита выполняет специфические для конкретного протокола запросы для получения статуса сервиса.

Например, с помощью следующего запроса мы не только проверим доступность службы RPC endpoint mapper (TCP/135), но и получим список имен зарегистрированных в системе конечных точек RPC (в том числе их имя, UUID, адрес к которому они привязаны и приложение, с которым они связаны).

portqry -n 10.1.10.6  -p tcp -e 135

TCP port 135 (epmap service): LISTENING
Using ephemeral source port
Querying Endpoint Mapper Database...
Server's response:
UUID: d95afe72-a6d5-4259-822e-2c84da1ddb0d
ncacn_ip_tcp:10.1.10.6 [49152]
 UUID: 897e215f-93f3-4376-9c9c-fd2277495c27 Frs2 Service
ncacn_ip_tcp:10.1.10.6 [5722]
UUID: 6b5bd21e-528c-422c-af8c-a4079be4fe48 Remote Fw APIs
ncacn_ip_tcp:10.1.10.6 [63006]
UUID: 12345678-1234-abcd-ef22-0123456789ab IPSec Policy agent endpoint
ncacn_ip_tcp:10.1.10.6 [63006]
UUID: 367abb81-9844-35f1-ad32-91f038001003
ncacn_ip_tcp:10.1.10.6 [63002]
UUID: 50abc2a3-574d-40b3-1d66-ee4fd5fba076
ncacn_ip_tcp:10.1.10.6 [56020]
……..
UUID: 3c4428c5-f0ab-448b-bda1-6ce01eb0a6d5 DHCP Client LRPC Endpoint
ncacn_ip_tcp:10.1.10.6 [49153]
Total endpoints found: 61
==== End of RPC Endpoint Mapper query response ====
portqry.exe -n 10.1.10.6  -e 135 -p TCP exits with return code 0x00000000.

Или вы можете проверить доступность и ответ от службы SQL Server Browser на сервере Microsoft SQL Server:

PortQry.exe -n msk-sql1 -e 1434 -p UDP

UDP port 1434 (ms-sql-m service): LISTENING or FILTERED
Sending SQL Server query to UDP port 1434...
Server's response:
ServerName MSK-SQL01
InstanceName MSSQLSERVER
IsClustered No
Version 15.0.2000.5

tcp 53200
ServerName MSK-SQL01
InstanceName BANKDB
IsClustered No
Version 15.0.2000.5
tcp 1433
==== End of SQL Server query response ====
UDP port 1434 is LISTENING

Как вы видите, утилита portqry показала не только доступность UDP порта, но и версию SQL сервера и имена запущенных на сервере SQL экземпляров и их TCP порты (один инстанс BANKDB живет на порту по умолчанию tcp 1433, второй MSSQLSERVER использует фиксированный порт из RPC диапазона 53200 — см. статью о настройке портов в SQL Server).

portqry проверка портов и экземпляров sql server

Можно опросить SNMP порт на устройстве, указав название community:
portqry -n host2 -cn !secure! -e 161 -p udp

При проверке 25 порта на SMTP сервере можно получить баннер приветствия сервера:

portqry -n domain.mail.ru  -p tcp -e 25

Графический интерфейс для Portqry

Первоначально утилита Portqry была исключительно консольным инструментом. Для удобства пользователей, которые не дружат с командной строкой, Microsoft разработала простой графический интерфейс для утилиты portqry – PortQueryUI. Скачать PortQueryUI можно с сайта загрузок Microsoft http://download.microsoft.com/download/3/f/4/3f4c6a54-65f0-4164-bdec-a3411ba24d3a/PortQryUI.exe

PortQueryUI по сути представляет собой графическую надстройку над portqry для формирования командной строки, и возврата результата в графическое окно.

Кроме того, в PortQueryUI заложено несколько заранее предопределенных наборов запросов для проверки доступности популярных служб Microsoft:

  • Domain and trusts (проверка служб на контроллере домена Active Directory)
  • IP Sec
  • Networking
  • SQL Server
  • Web Server
  • Exchange Server
  • Net Meeting

Думаю, особых комментариев к интерфейсу PortQueryUI давать не нужно. Все должно быть понятно из скриншота ниже. Укажите DNS имя или IP адрес сервера, выберите один из предустановленных сервисов (Query predefined service), или укажите номера портов для проверки вручную (Manually input query ports) и нажмите кнопку Query.

PortQueryUI - графический интерфейс

Возможные коды ответа в PortQueryUI (выделен на скриншоте):

  • 0 (0x00000000)– означает, что соединении успешно установлено и порт доступен;
  • 1 (0x00000001) – указанный порт недоступен или отфильтрован;
  • 2 (0x00000002 – это нормальный код возврата при проверке UDP подключения, т.к. не возвращается ACK ответ.

If you’re checking from the outside, not from the server itself, and you don’t want to bother installing telnet (as it doesn’t come with the last versions of Windows) or any other software, then you have native PowerShell:

Test-NetConnection -Port 800 -ComputerName 192.168.0.1 -InformationLevel Detailed

(Unfortunately this only works with PowerShell 4.0 or newer. To check your PowerShell version, type $PSVersionTable.)

PS: Note, these days there are some claims on the twittersphere that hint that this answer could be improved by mentioning «Test-Connection» from PowerShell Core, or the shortcut «tnc». See https://twitter.com/david_obrien/status/1214082339203993600 and help me edit this answer to improve it please!


(If you have a PSVersion < 4.0, you’re out of luck. Check this table:

Enter image description here

Even though you can upgrade your version of PowerShell by installing the Windows Management Framework 4.0, it didn’t do the trick for me, Test-NetConnection cmdlet is still not available).

All recent versions of Windows include the Windows Firewall utility. A firewall includes options for opening and closing ports, as well as allowing and disabling specific programs and services.

Computer resources can be protected from unauthorized access by firewalls on networks and servers. Incoming or even outgoing traffic is checked for by the firewall systems and in accordance with the rules configured, decisions are made about them.

Windows Firewall cannot access the port if it isn’t explicitly allowed. TCP/IP ports are reserved for applications whenever they want to access the network, which means anyone else cannot use them.

TryRDP
Advertisement

Also Read: How to Change RDP Port in Windows Server?

In Windows Server 2008/2012 R2/2016 and Windows Server 2019, there are three ways to open ports.

  • MMC
  • The command line (netsh)
  • PowerShell commands (For 2012R2 and 2016 only)

So, you can open ports on Windows Server by following the instructions in the following article. 

Open Ports via MMC

  • Here first of all you have to log in using an admin account.
  • Then you have to click on:

Start > Administrative Tools > Windows Firewall with Advanced Security

  • Now you have to click on the Inbound Rules on the left of the MMC.

  • Then click on the New Rule on the Right of the MMC.

  • Now here you will get five steps to open a port and accept incoming connections:-
  1. Rule Type
  2. Protocol and Ports
  3. Action
  4. Profile
  5. Name
  • Suppose for example the servers with Parallels RAS Publishing Agents will need to open TCP port 20002.
  • Now under the Rule Type section, you have to select “Port” and then click on the “Next” button.

  • Then under the Protocol and Ports section, you have to select the “TCP” as the type of protocol.
  • After that, you have to type “20002” in the “Specific local ports” input field.

  • Next, you have to head to the Action section in which you have to select “Allow the Connection and then you have to click on the “Next” button.

  • Now under the Profile section, you have to select all three options and click on the “Next” button.  

(NOTE: Here at this point if you wish to limit the connection to a  particular profile then you can simply select the profiles that are appropriate to your setup.)

  • After that, now you have to enter a “Name” for this rule under the Name section, and then click on the “Finish” button when you are done.

  • That’s it, now you are done.

Open Ports through command line (netsh)

  • First of all, using an administrator account you have to login to the server.
  • Then you have to open and run the Command Prompt as Administrator.
  • For the Publishing Agents role on the servers, open the TCP port 20002 with the following command.

  • That’s it, now you are done.

Open Ports through PowerShell commands

  • First of all, using an admin account you have to Log in.
  • Then you have to run the Windows PowerShell as Administrator.
  • You need to open the TCP port 20002 on the publishing agents server using the following command.

  • That’s it, now you are done.

Once all is done, now immediately after creating this rule, the firewall rule will allow traffic to (or from) your server. While if you want to open a port for both sending and receiving, you need to repeat the process as an Outbound rule.

Ports play a very important role in any computer system. In computer networks, ports are used to connect computers and other devices to one another. When you open a port, you are allowing specific types of information to go in and out of your computer. 

For example, if you want to host a website, you need to open port 80 to allow web traffic to go in and out. This blog is all about how to open ports on a Windows server and we hope that you liked it.

FAQs

What is a firewall and how does it work?

A firewall is a security system that is used to protect computer resources from unauthorized access. It checks incoming and outgoing traffic on a network or server, and according to the configured rules, decides whether to allow or block traffic.

How do I open ports on Windows Server?

There are three ways to open ports on Windows Server 2008/2012 R2/2016 and Windows Server 2019: using MMC, command line (netsh), or PowerShell commands. To open a port using MMC, you need to log in as an admin, click on Start > Administrative Tools > Windows Firewall with Advanced Security, click on Inbound Rules, then click on New Rule, and follow the five steps to open a port and accept incoming connections.

What is a TCP/IP port and why do applications need them?

TCP/IP ports are reserved for applications when they want to access the network, which means that no one else can use them. Ports are used to connect computers and other devices to one another. When you open a port, you are allowing specific types of information to go in and out of your computer.

What is the difference between Inbound and Outbound rules when opening a port?

Inbound rules control traffic coming into the server, while outbound rules control traffic going out of the server. If you want to open a port for both sending and receiving, you need to repeat the process as an outbound rule.

Why is it important to open ports on a Windows server?

Opening ports on a Windows server is important because it allows specific types of information to go in and out of your computer. For example, if you want to host a website, you need to open port 80 to allow web traffic to go in and out. By opening ports, you can ensure that the applications and services you want to use can communicate properly.

  • Как посмотреть последние открытые файлы на компьютере windows 10
  • Как посмотреть потоки процесса в windows
  • Как посмотреть последние открытые файлы на компе windows 10
  • Как посмотреть почему перезагрузился компьютер windows 10
  • Как посмотреть последние открытые приложения на компьютере windows 10