簡體   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