【问题标题】:windows firewall open portwindows防火墙开放端口
【发布时间】:2015-11-11 18:13:45
【问题描述】:

我正在尝试在我自己的远程服务器上托管一个网站(在 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 设置端口规则(如此处所示 Firewall blocking/unblocking a port ),但这些似乎都不起作用,并且打开端口检查工具仍将端口 8888 显示为关闭。

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

【问题讨论】:

    标签: apache port windows-server-2012-r2 windows-firewall


    【解决方案1】:

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

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

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

    希望对您有所帮助!

    【讨论】:

      【解决方案2】:

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

      
      $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
                }
               }
             }  
      
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-06-17
        • 2015-01-02
        • 1970-01-01
        • 2016-06-06
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多