hol*_*ira 25 windows monitoring windows-server-2008 firewall ping
我刚刚在服务器上安装了 Windows Server 2008,我能够通过远程桌面连接但无法 ping。我是否需要在防火墙上打开一个特殊端口才能 ping 服务器?
sh-*_*eta 34
默认情况下,Windows 2008 不响应 ping。启用:
管理工具
具有高级安全性的 Windows 防火墙
入境规则
文件和打印机共享(回显请求 - ICMPv4-IN)
启用规则
您现在应该能够从 LAN ping 您的服务器。
Jef*_*ood 12
在命令行中通过 Windows 防火墙启用 ping,如下所示:
netsh firewall set icmpsetting 8
Run Code Online (Sandbox Code Playgroud)
显然,这在 Windows Server 2008 R2 和更新版本中已更改为:
netsh advfirewall firewall add rule name="ICMP Allow incoming V4 echo request"
protocol=icmpv4:8,any dir=in action=allow
Run Code Online (Sandbox Code Playgroud)
那是......呃......相当一口。
在 powershell 中,您可以使用:
# allow-icmp.ps1
# Sets up windows firewall to allow inbound ICMP - using PowerShell
# Thomas Lee - tfl@psp.co.uk
#create firewall manager object
$FWM=new-object -com hnetcfg.fwmgr
# Get current profile
$pro=$fwm.LocalPolicy.CurrentProfile
# Check Profile
if ($pro.IcmpSettings.AllowInboundEchoRequest) {
"Echo Request already allowed"
} else {
$pro.icmpsettings.AllowInboundEchoRequest=$true
}
# Display ICMP Settings
"Windows Firewall - current ICMP Settings:"
"-----------------------------------------"
$pro.icmpsettings
Run Code Online (Sandbox Code Playgroud)
您将希望允许 ICMP 数据包通过。Ping 不使用 TCP,因此没有要打开的端口。
在 admin powershell 中运行这两个命令,它会在所有网络(公共/私有/域)上启用 ipv6 和 ipv4 入站 ping:
Set-NetFirewallRule -DisplayName "File and Printer Sharing (Echo Request - ICMPv4-In)" -enabled True
Set-NetFirewallRule -DisplayName "File and Printer Sharing (Echo Request - ICMPv6-In)" -enabled True
Run Code Online (Sandbox Code Playgroud)
它相当于这个https://serverfault.com/a/6049/147813