When it comes to checking if a network port is opened or closed on a remote computer, there’s no easier way than to use Telnet. Ports left open for no reason are a security risk that malicious programs and viruses can exploit. At the same time, if legitimate software communicates through a specific port, having that port closed will make the program throw errors and malfunction.
Как проверить доступен ли порт сервера? Или внешний веб-сервис? Приведены несколько способов для использования на Windows-системах.
В процессе разворачивания и эксплуатации информационных систем часто требуется проверка доступности порта того или иного ресурса. Это может быть сервер приложений 1С, к которому не удается подключиться пользователю. Или же это внешний веб-ресурс, к которому происходит обращение. Или что-то еще.
Для проверки доступности самого сервера обычно используется команда ping. Но, в силу того, что данная утилита работает с ICMP-пакетами, для конкретного порта проверить доступ таким образом невозможно. Кроме того, на ресурсе в целях безопасности может быть заблокирован ответ на ICMP-пакеты, соответственно, результат доступности нельзя считать однозначным, если ресурс “не пингуется”.
Как проверить доступен ли порт?
Первое, что приходит на ум – использовать “старый добрый” telnet.
Для примера проверять будем доступность менеджера кластера:
Получили в ответ “кракозябру” – значит доступ есть
Загвоздка в том, что в большинстве современных Windows-систем telnet-клиент не установлен по-умолчанию, и требуется доустанавливать этот компонент. Что не всегда возможно, т.к. компьютер может быть и не своим и/или нет соответствующих прав.
Способ без инсталляции программ.
Хотелось бы иметь какой-то инструмент, не требующий установки, портабельный, чтобы можно было его просто скопировать и пользоваться, а при необходимости, легко удалить после использования.
В качестве такого инструмента удобно использовать утилиту psping от Sysinternals.
Еще один портабельный инструмент, позволяющий решить задачу:
Встроенный инструментарий.
Однако есть возможность обойтись и совсем без сторонних утилит. В Windows есть встроенный инструмент, позволяющий выполнить такую проверку.
В ответе нас интересует последняя строка – TcpTestSucceeded: True. В данном случае – доступ есть.
Также, в ответе может содержаться еще значение PingSucceeded – это “обычный” ping по ICMP.
У командлета есть очень удобный для запоминания и быстрого ввода альяс tnc, а также ключ позволяющий ограничить вывод только результатом.
Разумеется, запускать командлет необходимо в окне PowerShell, а не “командной строки”.
Хотя, из командной строки тоже можно, вызвав PowerShell:
Следует заметить, что командлет доступен в версиях PowerShell от 4.0 и выше, т.е. начиная с Windows Server 2012 R2 и Windows 8.1
Заключение
Заметка не предполагает исчерпывающего списка и анализа всех возможных способов. Приведены три варианта, которые можно было бы охарактеризовать как “традиционный”, “портабельный” и “встроенный”. Каждый из них имеет свою область применения, в зависимости от системы, на которой необходимо выполнить проверку.
Полагаю, опытные администраторы смогут добавить еще несколько способов. Каким способом пользуетесь Вы и почему?
How to enable Telnet client on Windows Server 2012, 2016
For example, to verify connection to 192.168.0.10 on port 25, issue the command:
telnet 192.168.0.10 25
If the connection succeeds, a blank screen will appear, meaning that the computer port is open.
A failed connection will be accompanied by an error message. Such a signal can indicate either a closed port or that the indicated remote server is not listening on the provided port.
When to use Telnet or SSH?
There are two primary cases when using a Telnet connection over SSH is recommended.
- When operating on trusted networks (e.g., LANs) that are disconnected from the internet.
- When operating with a remote host that doesn’t support SSH.
In all other cases, it’s best to use SSH since it provides high security for internet-connected devices.
In addition, SSH enables more functionality options than Telnet. (e.g., secure file transfer, port forwarding)
Unix-подобные операционные системы
вероятно, чаще всего здесь можно встретить bsd- и gnu-реализации: netkit-telnet и inetutils-telnet. для указанной диагностики разница между ними несущественна.
прервать неудачную попытку можно с помощью ctrl+c
пример удачного подключения к тому же серверу на порт 22:
последняя строчка здесь — это уже информация от программы, слушающей 22 порт на опрашиваемом сервере.
в котором можно ввести команду q (или полностью — quit) и нажать клавишу enter.
How to enable Telnet client on Windows 7, 8
Действия практически идентичны варианту для unix-подобных ОС. В Windows имеется встроенный telnet-клиент, но он может быть отключен. Чтобы его включить нужно выполнить шаги, описанные на сайте Microsoft.
Когда всё готово, запустить telnet-клиент можно так:
Пуск – Выполнить – telnet – ОК
В открывшемся консольном окне будут видны следующие строки:
Чтобы попытаться открыть тот или иной адрес и порт нужно написать букву o, а затем адрес и порт. Например:
How to enable a Telnet connection on a server?
The Telnet client is built into Windows 11, but to use it on Windows Server 2022, you’d need to enable it as it’s disabled by default.
- Open “Server Manager” from the Start menu
- In the “Add Roles and Features Wizard”, select “Next” on the “Before you begin” line
- Click “Next” on the “Select server roles” line
- Select “Install” on the “Confirmation installation selections” line
- Close the “Add Roles and Features Wizard”
The Telnet protocol can be enabled in several ways. Below, we will explore all available options so that you can choose the most efficient one for you.
Enabling Telnet client in Microsoft Windows operating systems
As we’ve mentioned, Telnet is disabled by default in Windows settings, so you need to turn it on before you can do anything. Enabling it will help you run the required diagnostics and check if a port is open. If you try to use Telnet without turning it on first, you’ll receive a message like this:
In order to turn Telnet on, you need to use the command line or the graphical interface of your computer.
Enabling Telnet client through Command Prompt
Dism /Online /Enable-feature /FeatureName:TelnetClient
After you’ve put this in, Telnet will be ready to use to check your ports.
Install-WindowsFeature -name Telnet-Client
Example
Testing open ports with Telnet
How to Check if a Port is Open on Mac
When a computer port is open, a blank screen will show up, meaning that the connection has been successful. An unsuccessful connection will be accompanied by an error message.
Acting on the results obtained from the Telnet test
If you want to check for closed ports on your router, enter your router management console. Open a web browser and enter the IP address or name of the router, for example, “192.168.0.10”. If the page does not open, try replacing “http” with “https” at the beginning of the address.
If you need to make resources in the internal network accessible from the outside, enter “External access”/” Port forwarding” section. Consult the router manufacturer’s documentation for detailed instructions.
How to enable Telnet client on Windows Server 2008
Telnet is a primordial being in the tech universe. And as such, it is still being used in specific scenarios. Telnet is easy to operate, requires no high-tech knowledge, and doesn’t overload your network. (in most cases)
Related Acronis resources
Read further on what ports are used in Acronis software and how to open them:
https://kb.acronis.com/brandmauer – A summary page about the network ports used in Acronis software
What are the 3 modes of Telnet protocol?
The Telnet protocol generally has three modes of operation. In all of them, your keyboard produces outgoing data via the Telnet command structure, travels via a Telnet TCP connection, and arrives at a virtual or physical terminal to satisfy a terminal-computer connection.
Telnet command section
Defined Telnet commands consist of:
WILL – 251 – Offer or accept to enable
WON’T – 252 – Accept of Offer to disable
DO – 253 – Request or Approve to enable operation
DON’T – 254 – Disapprove enable or Request to disable
SE – 240 – End of subnegotiation parameters
NOP – 241 – No operation
DM – 242- The Telnet command “data mark” indicates and locates a Telnet Synch sequence within the data stream. (critical to be accompanied by a Transmission Control Protocol (TCP) urgent notification)
BRK – 243 – Break command. It indicates that the “attention” or “break” key was hit
IP – 244 – Suspends, interrupts, or aborts the Network Virtual Terminal connection corresponding to the specific process
AO – 245 – Aborts output – allows for the process to complete but doesn’t send data
AYT – 246 – This stands for “Are you there?” – it requests to send back visible evidence that the AYT was received from the Network Virtual Terminal (NVT)
EC – 247 – Erase character command – the receiver of the command should delete the last undeleted preceding
EL – 248 – Erase line command – delete characters from the stream back to – but not including – the previous Carriage Return Line Feed (CRLF)
GA – 249 – The Telnet Go Ahead command – used primarily to inform the other end that it can start to transmit data
IAC – 255 – The “Interpret-as-command” character
Telnet protocol command options
Several Telnet option specifications are available to negotiate between the Telnet client and server. This can be done by using commands at any stage as long as the connection persists. Below is a list of the most important command options.
Actual code assignments
3 suppress go ahead
6 timing mark
24 terminal type
31 window size
32 terminal speed
33 remote flow control
36 environment variables
Options undergo a negotiation process to present the client and server with a common view of the potential extra capabilities affecting the interchange and the operation of applications.
Both ends of a Telnet dialogue can either enable or disable options locally or remotely.
What is SSH? What is its port?
SSH stands for “Secure Shell” or “Secure Socket Shell”. It’s a secure protocol that enables encrypted communication between two computers.
As SSH enables encrypted communication between the two machines, it is suitable for unsecured networks.
SSH is primarily used to establish a virtual terminal connection and log onto a remote machine to perform operations or transfer data. The default port for the SSH client connection is 22. You can change the default by entering a port number between 1024 and 32,767.
What is Telnet used for?
The Telnet protocol is as old-school as it gets in the tech world. It was developed in 1969, so it doesn’t pack the robust security features of today’s network protocols.
However, you can use Telnet to execute various other tasks. When properly connected, you can edit files, run programs, or check your email with it.
In addition, some servers enable remote Telnet connections to access public data. For starters, you can check the weather forecast via the Weather Underground service, active since 1995 and still running. (because, let’s face it, TV forecasts can get boring)
Moreover, Telnet lets you play chess at the Free Internet Chess Server and really merge with the spirit of old digital masters.
To play chess there, use the command:
Now, for the hardcore Star Wars fans – you can watch Star Wars Episode 4 in the default ASCII mode. Or at least the part of the movie that’s finished and available for “streaming”.
o towel.blinkenlights.nl 23
How does SSH work?
To establish remote terminal access via Secure Shell, you’d need an SSH client on your computer to connect to the SSH server.
The SSH client, once enabled, invokes the connection setup process to process communication secured by strong symmetric encryption.
Telnet and SSH are both network protocols used to manage a remote computer system.
But what makes them different? Let’s explore that below step-by-step.
Telnet requires a server app installed on the remote computer (the one you want to manage) and a client app installed on the local machine.
Telnet uses the TCP port protocol and port 23 to establish a connection with remote computers. The created system acts as a Telnet server and is available to receive commands. Said commands are sent via the Network Virtual Terminal (NVT) format. Then, they are received and interpreted by the Telnet server and sent to the corresponding application.
SSH ensures a secure connection to the server via port 22. It generates a session after the client verifies the server via key-based authentication. The generated session is sent to both the client and the server, and all traffic is encrypted for the current session.
Lastly, the server verifies the client via a generated SSH key pair. After successful client authentication, it establishes an encrypted connection, and the two systems can exchange data securely.
Telnet doesn’t provide any security features or protocols when transmitting data. The network protocol is highly vulnerable to cyber threats unless used on private, trusted, preferably offline, networks.
Thanks to the key pairs used for authentication, SSH is extremely difficult to penetrate and read the transferred data. This makes it a way more secure protocol than Telnet, even for unsecured networks.
Telnet sends data as plain text via the NVT format.
SSH sends data via an encrypted format through a secure channel.
Telnet employs no authentication mechanism.
SSH relies on public key encryption.
Both Telnet and SSH are available on Windows, Mac OS, and Linux. (with some exceptions for Telnet in newer Mac OS versions)
Telnet connection bandwidth usage is low.
SSH connection bandwidth usage is high.
What is Telnet?
The name “Telnet” is short for “Teletype Network Protocol”.
In a nutshell, Telnet is a computer protocol that was built for interacting with remote computers. It enables terminal-to-terminal communication and can be used for a variety of purposes.
The word “Telnet” also refers to the command-line utility “telnet”, available under Windows OS and Unix-like systems, including Mac, Linux, and others. We will use the term “Telnet” mainly in the context of the telnet client software.