我刚刚在服务器上安装了Windows Server 2008,我可以通过远程桌面进行连接,但无法ping通。 我是否需要在防火墙上打开特殊端口才能ping通服务器?
默认情况下,Windows 2008不响应ping。 启用:
pipe理工具
高级安全Windows防火墙
入站规则
文件和打印机共享(回显请求 – ICMPv4-IN)
启用规则
您现在应该能够从局域网ping您的服务器。
在命令行中通过Windows防火墙启用ping,如下所示:
netsh firewall set icmpsetting 8
显然,在Windows Server 2008 R2和更新的版本中,这已经发生了变化:
netsh advfirewall firewall add rule name="ICMP Allow incoming V4 echo request" protocol=icmpv4:8,any dir=in action=allow
那是…呃…相当一口。
在PowerShell中,您可以使用:
# allow-icmp.ps1 # Sets up windows firewall to allow inbound ICMP - using PowerShell # Thomas Lee - [email protected] #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
您将需要允许ICMP数据包通过。 Ping不使用TCP,所以没有端口可以打开。
解决这个问题的另一种方法
netsh advfirewall firewall add rule name="ICMP Allow incoming V4 echo request" protocol=icmpv4:8,any dir=in action=allow
注意使用正确的引号。 一些网站用引起语法错误的类似符号代替引号。 请在此处input链接描述
在pipe理PowerShell中运行这两个,它在所有networking(公共/私人/域)上启用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