В этом руководстве рассмотрим, как включить правило, чтобы сервер стал отвечать на ping используя графический интерфейс Windows Server 2019, а также включим разрешающее правило через PowerShell и netsh.
Обычно просто отключают Windows Firewall полностью, однако это не рекомендуется делать в производственной среде, так как брандмауэр Windows хорошо справляется с обеспечением базового уровня защиты системы. Разрешим только конкретное правило, необходимое для успешного выполнения команды ping.
Разрешить проверку связи через брандмауэр Windows
Сначала нам нужно открыть брандмауэр Windows, это можно сделать несколькими способами. Один из методов — просто нажать клавишу Windows, чтобы открыть меню «Start«, а затем начать вводить слово Firewall. Как показано ниже, брандмауэр Windows с расширенной безопасностью должен отображаться, выберите этот пункт.
Еще один быстрый способ: в PowerShell можно просто ввести «firewall» и нажать Enter. Откроется базовый интерфейс брандмауэра, а затем нажать кнопку «Advanced settings» в левой части. Откроется тот же интерфейс, что и через меню «Start«.
Следующий способ открыть Firewall — ввести в CMD такой текст: «firewall.cpl«
В Брандмауэре в расширенном режиме перейдите в Inboud Rules (Правила для входящих подключений).
В перечне правил в Inboud Rules, найдите «File and Printer Sharing (Echo Request — ICMPv4-In)» и активируйте его.
Еще один вариант. Активируем разрешающее правило командлетом Powershell
Set-NetFirewallRule -DisplayName "File and Printer Sharing (Echo Request - ICMPv4-In)" -enabled True
Полную справку со всеми параметрами можно получить, набрав команду в PowerShell
help New-NetFirewallRule
Вариант создания правила через netsh
netsh advfirewall firewall add rule name="ICMP Allow incoming V4 echo request" protocol=icmpv4:8,any dir=in action=allow
Примечание: Включение правила позволит получать ответы только на IPv4 запросы, если нужно получать ответы по IPv6, нужно разблокировать правило такое же правило, только с Echo Request — ICMPv6-In, перечисленное ниже. К тому же имеется несколько профилей: доменный, публичный, частный. Ненужные профили можно отключить в правиле, во вкладке Advanced.
После разблокировки правила сервер должен начать отвечать на запросы ping. С хоста виртуализации или другого пк в локальной сети протестируем ping’ом Windows Server 2019 по адресу 192.168.1.11 перед включением правила, а затем снова после его включения. Ниже видно, что время ожидания первых запросов истекло, так как входящие запросы ICMP были отключены по умолчанию в Windows Server 2019. После включения правила ICMP запросы ping успешно выполняются, что подтверждает ожидаемую работу.
Пример проверки связи:
Скачать видео.
Резюме
Стандартное правило брандмауэра — блокировать ICMP запросы, в итоге сервер не отвечает на ping. Включив это правило брандмауэра, мы включили команду ping в Windows Server 2019, которая поможет нам устранить неполадки в сети.
В Windows Server 2016, 2019 и 2022 ICMP или Ping отключены по умолчанию, делает систему более безопасной, но иногда это приносит с собой некие сложности в мониторинге.
Поскольку команда ping говорит/показывает, что удаленный компьютер подключен к сети, то это полезная команда для системных администраторов.
Если Вам для каких-то своих целей или же для мониторинга необходимо включить ICMP пакеты, или же ping, то можно воспользоваться ниже приведенной инструкцией.
Его можно включить вручную без использования групповых политик.
Если ICMP пакеты на вашем компьютере не включены, вы получите сообщение об истечении времени ожидания.
Как включить Ping в брандмауэре Windows
Чтобы включить проверку связи в брандмауэре, выполните следующие действия:
Откройте брандмауэр, нажав Win+R и напишите команду firewall.cpl.
В открывшемся окне нажмите Advanced Settings на правой панели.
Выберите Inbound Rules на левой панели и на правой панели New Rule.
Выберите File and Printer Sharing в разделе PredefinedRules. И нажмите Next.
Выберите следующие два правила:
- Общий доступ к файлам и принтерам (Echo Request – ICMPv6-In )
- Общий доступ к файлам и принтерам (Echo Request – ICMPv4-In )
И нажмите Next.
Выберите пункт Allow the connection. Нажмите Finish .
Как включить ICMP (Ping) с командной строки или PowerShell
Для этого откройте командную строку, нажав Win+R и напишите команду cmd.
Разрешить пинг IPv4 с командной строки:
netsh advfirewall firewall add rule name="ICMP Allow Ping V4" protocol="icmpv4:8,any" dir=in action=allow
Разрешить ping IPv4 с помощью PowerShell:
New-NetFirewallRule -DisplayName "ICMP Allow Ping V4" -Direction Inbound -Protocol ICMPv4 -IcmpType 8 -RemoteAddress <localsubnet> -Action Allow
Если после тестирования и настроек необходимо отключить ICMP пакеты, то так же можем воспользоваться командной строкой для этого.
Заблокировать ping IPv4 с командной строки:
netsh advfirewall firewall add rule name="ICMP Allow Ping V4" protocol="icmpv4:8,any" dir=in action=block
Заблокировать ping IPv4 с помощью PowerShell:
New-NetFirewallRule -DisplayName "ICMP Allow Ping V4" -Direction Inbound -Protocol ICMPv4 -IcmpType 8 -RemoteAddress <localsubnet> -Action Block
Также предлагаем рассмотреть другие полезные статьи:
- Как подключиться к серверу по FTP, SFTP и SCP
- Как установить и настроить FTP-сервер IIS на Windows Server 2019
- Как подключиться к Docker контейнеру по sFTP
Posted by
on December 21, 2018
By default in Windows Server 2019 the Windows Firewall is configured to drop all inbound ICMP traffic. This includes echo requests which are used by the ping command, which can make network troubleshooting difficult.
In this guide we will cover how to allow ping through Windows Firewall in Windows Server 2019.
A common response is usually to simply disable Windows Firewall entirely, however this is not recommended as the Windows Firewall does a good job at providing a basic level of system protection. We will only be allowing the specific rules required to allow ping to succeed.
Allow ping through Windows Firewall
- First we need to open Windows Firewall, this can be done a few ways. My favourite method is to simply hit the Windows key to open start, then start typing firewall. As shown below Windows Firewall with Advanced Security should show, click this.
Alternatively you can simply type ‘firewall’ and press enter in PowerShell to open the basic firewall interface, then click “Advanced settings” on the left hand side – this will open the same interface listed in the start menu.
- From the Windows Firewall with Advanced Security window that opens up, select Inbound Rules from the menu on the left.
- From the rules listed under Inbound Rules, select “File and printer Sharing (Echo Request – ICMPv4-In)” and enable the rule.
Note that this will only allow IPv4 requests in, if you need IPv6 then you will want to enable the “File and Printer Sharing (Echo Request – ICMPv6-In)” rule, listed just below.
- Once enabled the server should now respond to ping requests. From my desktop I begun to ping my Windows Server 2019 virtual machine at 192.168.75.133 before enabling the rule, and then again after enabling it. You can see below that the first requests timed out, as inbound ICMP requests were disabled by default in Windows Server 2019. After enabling the ICMP rule, the ping requests succeed, confirming that this is working as expected.
Summary
By Default Windows Firewall prevents ICMP echo requests, this results in the server not responding to ping. By enabling this firewall rule we have enabled ping in Windows Server 2019, which can help us with network troubleshooting.
To send an Internet Control Message Protocol echo request message to another TCP/IP device to confirm IP-level connectivity, enable Ping for Windows Server 2019. Along with the round-trip time, receipt of the relevant echo reply message is shown. The most used TCP/IP command for analysing connectivity, reachability, and name resolution is ping. The ICMP and ping traffic is blocked by the default installation of Windows Server 2019. Microsoft does this to protect users. However, in order to use a dedicated server, your server must accept ICMP traffic from specific hosts. To establish a cloud connection with an external host.You can monitor and resolve network issues for your host by enabling ping. This article explains how to make ping available on Windows Server 2019.We can shut off the entire Firewall in order to enable Ping. This is not advised, though, as Windows Firewall does a superb job at offering fundamental system security. Just the rules necessary for the ping to work should be allowed.
On Windows Server 2019, enable the ICMP rule to allow ping replies (GUI)
- Firstly Activate your Windows Server 2019 DS account. The Windows Firewall must then be opened. There are numerous ways to accomplish this, but we’ll use a straightforward search by entering “firewall” in the start menu. Launch it.
- Select Inbound Rules in the Windows Firewall and search for “File and printer Sharing (Echo Request – ICMPv4-In)” To enable the rule, right-click on it.
NOTE: that if you need IPv6, you must enable the “File and Printer Sharing (Echo Request – ICMPv6-In)” rule, which is specified directly below. This rule only permits IPv4 requests to enter.
- The server will reply to ping requests when enabled. Prior to and after activating the rule, I began pinging my Windows Server 2019 virtual machine at 147.124.215.128. Because incoming ICMP requests are disabled by default in Windows Server 2019, you can see from the screenshots below that the initial few requests timed out. The ping request is successful after the ICMP rule is enabled, indicating that everything is functioning as it should.
Enable Ping With PowerShell Command
To make an exception for the rules, launch” Powershell “As An Administrator” and execute the provided command.
Rule for ICMPv4:
Using the command line, add a firewall rule with the name “ICMP Allow inbound V4 echo request” and the protocol “icmpv4:8,any”
ICMPV6 rule:
Using the command line, add a firewall rule with the name “ICMP Allow Incoming V6 Echo Request” and the protocol “icmpv6:8,any”. action=allow dir
Using a PowerShell command, disable Ping
Rule for ICMPv4:
icmpv4:8,any,in,block #netsh advfirewall firewall add rule name=”ICMP Allow incoming V4 echo request”
ICMPV6 rule:
icmpv4:8,any,in,block #netsh advfirewall firewall add rule name=”ICMP Allow incoming V4 echo request”
The network security policy in your environment will determine whether to enable or disable Ping since it is a helpful tool for troubleshooting and identifying the existence of network devices. This post offered straightforward instructions for turning on and off the Ping reply using the GUI and PowerShell.
Read Our Next Articles Introducing Windows Server For Our Buisness
Enabling Ping
will make network troubleshooting easier which allows all inbound ICMP traffics and this also includes the echo requests by using this common command.
Requests will expire as shown in the image below before Ping
is enabled.
This guide outlines the basic steps to enable and disable Ping from the Windows firewall on the Windows server.
Step A — Opening Windows firewall
-
To open the Windows firewall, just click on the Windows key to open
start
and searchfirewall
, and then click on theWindows Defender Firewall with Advanced Security
which is shown in the below image. -
From the menu on the left, select the
Inbound Rules
specified in the image below.
Step B — Enabling OR Disabling the rule
-
Select
File and Printer Sharing (Echo Request – ICMPv4-In)
from the rules listed underInbound Rules
and enable the rule as shown in the below image.
-
Select
File and Printer Sharing (Echo Request – ICMPv6-In)
from the rules listed underInbound Rules
and enable the rule as shown in the below image.
Once the ping
is enabled, the server should now respond to ping requests for both IPv4 and IPv6. That is shown in the below image.
To Disable for IPv4
-
Select
File and Printer Sharing (Echo Request – ICMPv4-In)
from the rules listed under Inbound Rules and disable the rule as shown in the below image.
To Disable for IPv6
-
Select
File and Printer Sharing (Echo Request – ICMPv6-In)
from the rules listed under Inbound Rules and disable the rule as shown in the below image.Once the ping is disabled, the server should now respond to ping requests for both IPv4 and IPv6. That is shown in the below image.
Related Tutorials
-
Installing telnet on Linux and Windows Cloud Servers
-
How to check if TCP / UDP port is open on Linux & Windows Cloud Servers
-
Basic Firewall Information and Rule Setting
-
Setting up Windows Firewall on Windows Cloud Servers 2019
-
Firewall Configuration using Iptables on Ubuntu 14.04
-
How to enable & disable Ping (ICMP Echo Requests) from IPTables on Linux Cloud Servers
-
How to Enable & Disable Ping (ICMP Echo Requests) in Windows Server 2022 Firewall
Other Information
- How to choose a data center when deploying LayerStack Cloud Servers