如何讓IIS只佔用指定IP

在 IIS 中的站台設定, 可以明確地指定單一站台的 IP及 PORT, 不過無論如何設定, 預設 IIS 就會在發起 SERVICE 時, 佔用 0.0.0.0 這個 IP (也就是全部的 IP), 若是希望 IIS 不要佔用這個 IP (也就是希望能和其他佔用 80 PORT 的 SERVICE, 如 APACHE 共同使用同一台主機的狀況下), 可以利用 Support Tools 內的 httpcfg 工具來進行操作, 詳細步驟如下:

1. Click Start, and then click Run.
2. Type cmd, and then click OK to open a command prompt.
3. Type the following, where xxx.xxx.x.x is the IP address you want to add:

httpcfg set iplisten -i xxx.xxx.x.x
When this succeeds, Httpcfg returns the following:
HttpSetServiceConfiguration completed with 0To view additional status codes, see the Httpcfg help.

4. After the IP address is added, use the following command to list it:

httpcfg query iplisten
Httpcfg returns the following:
IP :xxx.xxx.x.x

5. From the command prompt, stop the HTTP service and its dependent services. To do this, type the following string at the command prompt:

net stop http /y

6. From the command prompt, restart the HTTP service and it dependent services. To do this, type the following string at the command prompt:

net start w3svc
Note When you start w3svc, all services that were stopped when HTTP was stopped will start.

進行指定 IP 的操作後, 之後 IIS 就只會佔用指定的 IP, 而不會佔用全部的預設 IP 0.0.0.0 囉! 請參考微軟 KB 資料: http://support.microsoft.com/kb/813368

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *