Testing port open windows

Test-NetConnection: проверка открытых/закрытых TCP портов из PowerShell

В PowerShell 4.0 (Windows 2012 R2, Windows 8.1 и выше) появился встроенный командлет для проверки сетевых соединений — Test-NetConnection. С помощью данного командлета вы можете проверить доступность удаленного сервера или сетевой службы на нем, блокировку TCP портов файерволами, проверить доступность по ICMP и маршрутизацию. По сути, командлет Test-NetConnection позволяет заменить сразу несколько привычных сетевых утилит: ping, traceroute, сканер TCP портов и т.д.

Основное преимущество командлета Test-NetConnection – он уже входит в состав всех современных версий Windows и вам не нужно устанавливать его отдельно. Командлет входит в состав модуля NetTCPIP (начиная с PoSh v4.0).

Значение 4 в столбце Major говорит о том, что на компьютере установлен PowerShell 4.0.

TCP Port Ping: Использование Test-NetConnection для проверки открытых портов и доступности серверов

Проверим, открыт ли порт TCP 25 (SMTP протокол) на почтовом сервере с помощью Test-NetConnection:

Test-NetConnection -ComputerName msk-msg01 -Port 25

В сокращенном виде аналогичная команда выглядит так:

TNC msk-mail1 -Port 25

Разберем результат команды:

Как вы видите, командлет выполняет разрешение имени сервера в IP адрес, выполняется проверка ответа ICMP (аналог ping) и доступность TCP порта. Указанный сервер доступен по ICMP ( PingSucceeded = True ) и 25 TCP порт также отвечает ( RemotePort=25, TcpTestSucceeded= True ).

У командлета есть специальный параметр –CommonTCPPort, позволяющий указать наименование известного сетевого протокола (HTTP, RDP, SMB, WINRM).

Например, чтобы проверить доступность веб-сервера, можно использовать команду:

Test-NetConnection -ComputerName winitpro.ru -CommonTCPPort HTTP

Test-NetConnection msk-rds1 –CommonTCPPort RDP

Можно вывести все параметры, которые возвращает командлет Test-NetConnection:

Test-NetConnection msk-man01 -port 445|Format-List *

Если нужна только информация по доступности TCP порта, в более лаконичном виде проверка может быть выполнена так:

TNC msk-mail1 -Port 25 -InformationLevel Quiet

Командлет вернул True, значит удаленный порт доступен.

(New-Object System.Net.Sockets.TcpClient).Connect(‘msk-msg01’, 25)

В Windows 10/ Windows Server 2016 вы можете использовать командлет Test-NetConnection для трассировки маршрута до удаленного сервера при помощи параметра TraceRoute (аналог tracert). С помощью параметра Hops можно ограничить максимальное количество хопов при проверке.

Test-NetConnection msk-man01 –TraceRoute

Командлет вернул сетевую задержку при доступе к серверу в милисекундах ( PingReplyDetails (RTT) : 41 ms ) и все IP адреса маршрутизаторов на пути до целевого сервера.

Test-NetConnection в скриптах мониторинга

Следующая команда позволить проверить доступность определенного порта на множестве серверов, список которых хранится в текстовом файле servers.txt. Нас интересуют сервера, где искомая служба не отвечает:

Аналогичным образом вы можете создать простейшую систему мониторинга, которая проверяет доступность серверов и выводит уведомление, если один из серверов недоступен.

Например, вы можете проверить доступность основных служб на всех контроллеров домена (список DC можно получить командлетом Get-ADDomainController). Проверим следующие службы на DC (в утилите PortQry есть аналогичное правило Domain and trusts):

  • RPC – TCP/135
  • LDAP – TCP/389
  • LDAP – TCP/3268
  • DNS – TCP/53
  • Kerberos – TCP/88
  • SMB – TCP/445

$Ports = «135»,»389″,»636″,»3268″,»53″,»88″,»445″,»3269″, «80», «443»
$AllDCs = Get-ADDomainController -Filter * | Select-Object Hostname,Ipv4address,isGlobalCatalog,Site,Forest,OperatingSystem
ForEach($DC in $AllDCs)
<
Foreach ($P in $Ports)<
$check=Test-NetConnection $DC -Port $P -WarningAction SilentlyContinue
If ($check.tcpTestSucceeded -eq $true)
«>
else
» -ForegroundColor Red>
>

Читайте также:  Команды параметры командной строки windows

Скрипт проверит указанные TCP порты на контроллерах домена, и, если один из портов недоступен, выделит его красным цветом (с небольшими доработками можно запустить данный PowerShell скрипт как службу Windows).

Сканер сети на PowerShell

Также вы можете реализовать простой сканер портов и IP подсетей для сканирования удаленных серверов или подсетей на открытые/закрытые TCP порты.

Просканируем диапазон IP адресов на открытый порт 3389:

foreach ($ip in 5..30)

Просканируем диапазон TCP портов от 1 до 1024 на указанном сервере:

Проверка порта

PortScaner.ru Port Checker — это бесплатный онлайн инструмент, чтобы найти открытые порты в вашей системе или на удаленном сервере. Этот инструмент позволяет сканировать открытые порты, которые могут оказаться дырами в безопасности и послужить лазейкой для хакеров. Вы также можете проверить, работает ли перенаправление портов на вашем роутере или нет.

Что такое проверка открытых портов?

Этот инструмент полезен для проверки порта в маршрутизаторе открыт он или закрыть. Это онлайн инструмент безопасности проверки порта открыт или заблокирован в вашей системе брандмауэром.

Какие порты бывают?

Порты являются виртуальными путями, по которым информация передается от компьютера к компьютеру. Всего есть 65536 портов на выбор..

Порты 0 до 1023 — Самые известные номера портов. Наиболее популярные службы работающие на портах: база данных MS SQL (1433), почтовые услуги POP3 (110), IMAP (143), SMTP (25), веб-сервисы HTML (80).

Порты от 1024 до 49151 — зарезервированные порты; это означает, что они могут быть зарезервированные для конкретных протоколов программного обеспечения.

Порты 49152 по 65536 — динамические или частные порты; это означает, что они могут быть использованы кем угодно.

Что такое проброс портов? (Port Forwarding)

Переадресация портов (Port Forwarding) имеется специальная функция на маршрутизаторе которая позволяет передачу пакетов данных извне (из Интернета) к устройствам или компьютерам в вашей локальной сети (LAN). По умолчанию все порты на маршрутизаторе закрыты, чтобы предотвратить взлом компьютеров вашей локальной сети. Но когда вы используете службу для подключения через порт на маршрутизаторе вам нужно открыть его. Например: Yahoo! Messenger вам необходимо чтобы один из следующих портов был открытым: 5061, 443, 80.

Test remote network port connection in Windows 10

In Windows 10, there is an ability to check the connection to a certain port on a remote machine. This is possible thanks to PowerShell. So, no third party tools are required and you can do it natively.

One of its cmdlets, Test-NetConnection, can be used to check the connection to a remote address and to a custom port specified by the user.

It has the following syntax:

Use it as follows.

Test remote network port connection in Windows 10

Replace the COMPUTER_NAME portion with the actual remote PC name or IP address. Specify the port you need to connect to instead of the PORT_NUMBER portion.

For example, let’s test the connection to the DNS port (53) of the public Google DNS server (8.8.8.8). The command will look as follows:

The output:The line TcpTestSucceeded: True indicates that the connection was successful and the port 53 is open.

If you try to connect to some random port, which is closed for incoming connections, the Test-NetConnection cmdlet will respond with the following information:

The output indicates that the connection has failed. The line TcpTestSucceeded has the value «False», but the cmdlet shows additional information that the target server is alive. It pinged the destination address and includes the results in the output. See the lines:

Читайте также:  Дисковое пространство windows 10 сколько нужно

For some servers, you may face the situation where PingSucceeded is False but TcpTestSucceeded is True. It just means that ICMP Ping is disabled on the target server but the destination port is open for incoming connections.

The cmdlet Test-NetConnection is one of the most useful PowerShell cmdlets. It saves your time and extends the built-in network diagnostics functionality in Windows 10.

The Test-NetConnection cmdlet is available in Windows 8.1 too.

Winaero greatly relies on your support. You can help the site keep bringing you interesting and useful content and software by using these options:

Share this post

About Sergey Tkachenko

Sergey Tkachenko is a software developer from Russia who started Winaero back in 2011. On this blog, Sergey is writing about everything connected to Microsoft, Windows and popular software. Follow him on Telegram, Twitter, and YouTube.

1 thought on “ Test remote network port connection in Windows 10 ”

what i do to open that port ? allready open it on my modem but still Port 30120 is closed on 109.131.175.13.

WARNING: TCP connect to (8.8.8.8 : 30120) failed
ComputerName : 8.8.8.8
RemoteAddress : 8.8.8.8
RemotePort : 30120
InterfaceAlias : Ethernet
SourceAddress : 192.168.1.11
PingSucceeded : True
PingReplyDetails (RTT) : 10 ms
TcpTestSucceeded : False

Test Open Port Forwarding for Your Router or Computer

Every web services must run on a port or else the service will be inaccessible. For example, when you visit a website, your web browser automatically connects to the web server using port 80 because that is the standard port registered in the IANA organization. It is also possible to configure a web server to run under a different port number such as 8080 and since the web browser connects to port 80 by default, you’ll need to instruct the web browser to visit the URL using the different port by adding the port 8080 at the end such as http://www.website.com:8080

Even if you are trying to host a temporary game server, connect to a CCTV, remotely access your router configurations, download media files using a BitTorrent client such as uTorrent, all of the actions mentioned above requires an open listening port for optimal usage and in some cases it won’t work at all if the port is closed.

Fortunately most modern routers already support UPnP whereby the router automatically opens and forwards the required port when it is triggered by the software, saving you the trouble of manually accessing your router settings to forward a port. The only problem is, how do you know whether the port forwarding either manually created by you or automatically through UPnP worked? Here we have 5 web services which you can use to test if the forwarded port is open or closed.

The open port check tool by YouGetSignal is a fast and easy to use port forwarding tester. Upon visiting the website, it detects your external IP address and automatically embeds it to the remote address box for your convenience. You can find a list of commonly used ports at the right hand side and clicking on it will instantly check the status of the selected port. You can also quickly scan all of the provided common ports by clicking on the “Scan All Common Ports” located at the end of the list.

Читайте также:  Сколько весит образ windows 10 64 bit для флешки

2. Ping.eu Port Check

Ping.eu is a well known site that offers free web based network testing tools such as a ping test, traceroute, DNS lookup, WHOIS, reverse lookup, proxy checker, bandwidth meter, network and network mask calculator, detect country by IP, unit convertor and finally a port checker. Using the port checker is as easy as either entering an IP address or hostname, followed by the port number and clicking the Go button. Your IP address is detected and shown at the top of the webpage. Clicking on it will transfer the IP to the appropriate box for your convenience.

Ping.eu offers a great alternative to YouGetSignal because both are able to provide results in real time on the page without actually refreshing the whole webpage.

3. WhatsMyIP Port Scanners

As mentioned earlier, a port scanner can also be used to test if a port is open or closed. The difference between a port scanner and a port checker is the port scanner is able to automatically scan a range of IP addresses whereas a port checker is commonly used to check a single port on a single IP address.

WhatsMyIP Port Scanners stands out by having 5 different categories to check on common server/game/application/P2P/Custom ports. An additional feature that is not normally found on other port checkers is the ability to select the connection time out. 3 options are available which is short (1 second), default (2 seconds), or long (10 seconds). For security purposes, WhatsMyIP Port Scanners only scans your IP address.

4. Network Port Scanner Tool

The Network Port Scanner Tool is a more advanced port checker if compared to the list mentioned above with two modes which is Normal and Advance. Basically the normal mode allows you to quickly scan a range of ports for an IP address while the Advance mode lets you choose the type of scan and ping with additional advanced options including detecting the operating system for the remote IP. The different scan modes especially the SYN Stealth is useful to scan a host with a firewall enabled.

Network Port Scanner Tool has accurately detected that I was running Microsoft Windows 7 Ultimate operating system during the test.

5. IPv6 Port Scanner

While most of the online port scanners or checkers will scan IPv4 addresses, here is one that scans connected hosts with an IPv6 global unicast address. 8 UDP ports are a must to scan while the 53 TCP ports can be excluded. You can also specify up to 4 custom TCP ports to be checked.

The scan results are displayed in real time using Javascript.

Additional Notes: The above online web services are only used to test if an external source can connect to you using the tested port. To test a local connection, you can either use a port scanning software or simply type “netstat -a” in command prompt.

As you can see at the image above, the IP 0.0.0.0 means that the port 8888 is being listened on all IP addresses such as the localhost 127.0.0.1, private(internal) and public(external) IP addresses.

Оцените статью