繁体   English   中英

windows防火墙开放端口

[英]windows firewall open port

我正在尝试在我自己的远程服务器上托管一个网站(在 Windows server2012 上运行,我使用 Apache 作为我的 Web 服务器,但端口 80 正被另一个程序(也需要运行)使用,所以我将 Apache 配置为在端口 8888 上运行。

我假设我必须在 Windows 防火墙中制定新规则才能打开端口 8888,但我不知道该怎么做。

我试过按照这篇文章http://www.rackspace.com/knowledge_center/article/managing-the-windows-server-2012-firewall ,将端口 8888 替换为 80 并允许而不是阻止。 我还尝试在端口 8888 上为 TCP 设置端口规则(如下所示防火墙阻止/解除阻止端口),但这些似乎都不起作用,打开端口检查工具仍将端口 8888 显示为关闭。

谁能告诉我我做错了什么? 欢呼,乔恩·阿尔纳

也许您并不真正知道,但在 Windows Server 2012 和 Windows 8 操作系统中,有一个名为“New-NetFirewallRule”的新 cmdlet。 此 cmdlet 提供了多种添加新防火墙规则的方法。

打开 PowerShell 术语并输入以下内容:

    New-NetFirewallRule -DisplayName "Allow Port 80" -Direction Inbound -LocalPort 80 -Protocol TCP -Action Allow

希望有帮助!

这是通过动态提供所有选项(即入站/出站、允许/拒绝、规则名称等)来打开防火墙端口的另一种方法。


$rulename = Read-Host -Prompt "Enter rule name: "
$portNumber = Read-Host -Prompt "Enter Port Number: "
$protchoice = $Host.UI.PromptForChoice('Protocol Type','Enter Protocol (TCP/UDP): ',('&TCP','&UDP'),0)
if($protchoice -eq 0)
    {
        $protchoice02 = 'TCP'
        $dirChoice = $Host.UI.PromptForChoice('Traffic Flow','Enter Traffic Flow direction (inbound/outbound): ',('&inbound','&outbound'),0)
        if($dirChoice -eq 0)
        {
         $dirChoices = 'Inbound'
         $allowdenyChoice = $Host.UI.PromptForChoice('Traffic Allowance','Allow/Deny Traffic (allow/deny): ',('&allow','&deny'),0)
         if($allowdenyChoice -eq '0')
         { 
          $allowdenyChoices = 'Allow'
          New-NetFirewallRule -DisplayName $rulename -Direction $dirChoices -LocalPort $portNumber -Protocol $protchoice02 -Action $allowdenyChoices
         }
         else
         {
         $allowdenyChoices = 'Deny'
         New-NetFirewallRule -DisplayName $rulename -Direction $dirChoices  -LocalPort $portNumber -Protocol $protchoice02 -Action $allowdenyChoices
         }
        }
        else
        {
          $dirChoices = 'Outbound'
          $allowdenyChoice = $Host.UI.PromptForChoice('Traffic Allowance','Allow/Deny Traffic (allow/deny): ',('&allow','&deny'),0)
          if($allowdenyChoice -eq '0')
          { 
           $allowdenyChoices = 'Allow'
           New-NetFirewallRule -DisplayName $rulename -Direction $dirChoices -LocalPort $portNumber -Protocol $protchoice02 -Action $allowdenyChoices
          }
          else
          {
           $allowdenyChoices = 'Deny'
           New-NetFirewallRule -DisplayName $rulename -Direction $dirChoices  -LocalPort $portNumber -Protocol $protchoice02 -Action $allowdenyChoices
          }
         }
       }
else
    { 
        $protchoice02 = 'UDP'
        $dirChoice = $Host.UI.PromptForChoice('Traffic Flow','Enter Traffic Flow direction (inbound/outbound): ',('&inbound','&outbound'),0)
        if($dirChoice -eq 0)
        {
         $dirChoices = 'Inbound'
         $allowdenyChoice = $Host.UI.PromptForChoice('Traffic Allowance','Allow/Deny Traffic (allow/deny): ',('&allow','&deny'),0)
         if($allowdenyChoice -eq '0')
         { 
          $allowdenyChoices = 'Allow'
          New-NetFirewallRule -DisplayName $rulename -Direction $dirChoices -LocalPort $portNumber -Protocol $protchoice02 -Action $allowdenyChoices
         }
         else
         {
          $allowdenyChoices = 'Deny'
          New-NetFirewallRule -DisplayName $rulename -Direction $dirChoices -LocalPort $portNumber -Protocol $protchoice02 -Action $allowdenyChoices
         }
        }
        else
        {
          $dirChoices = 'Outbound'
          $allowdenyChoice = $Host.UI.PromptForChoice('Traffic Allowance','Allow/Deny Traffic (allow/deny): ',('&allow','&deny'),0)
          if($allowdenyChoice -eq '0')
          { 
           $allowdenyChoices = 'Allow'
           New-NetFirewallRule -DisplayName $rulename -Direction $dirChoices -LocalPort $portNumber -Protocol $protchoice02 -Action $allowdenyChoices
          }
          else
          {
           $allowedenyChoices = 'Deny'
           New-NetFirewallRule -DisplayName $rulename -Direction $dirChoices -LocalPort $portNumber -Protocol $protchoice02 -Action $allowdenyChoices
          }
         }
       }  

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM