Windows-Server-2008

Windows Server 2008:當 NIC 有多個地址時指定預設 IP 地址

  • April 13, 2015

我有一個 Windows 伺服器,它有大約 10 個靜態綁定的 IP 地址。問題是我不知道如何指定預設 IP 地址。

有時,當我為 NIC 分配新地址時,預設 IP 地址會隨著在 NIC 上的高級 IP 配置中輸入的最後一個 IP 而更改。這會導致傳出公共 IP 也發生變化(因為我使用 NAT)。

即使此問題目前出現在 Windows Server 2008 上。

當一個網卡綁定了多個 IP 地址時,如何設置它的預設 IP 地址?

我的問題有更多解釋。

替代文字 http://www.nmediasolutions.com/_images/probleme/ip.png

這是輸出ipconfig

DHCP Enabled. . . . . . . . . . . : No
Autoconfiguration Enabled . . . . : Yes
IPv4 Address. . . . . . . . . . . : 192.168.99.49(Preferred)
Subnet Mask . . . . . . . . . . . : 255.255.255.0
IPv4 Address. . . . . . . . . . . : 192.168.99.51(Preferred)
Subnet Mask . . . . . . . . . . . : 255.255.255.0
IPv4 Address. . . . . . . . . . . : 192.168.99.52(Preferred)
Subnet Mask . . . . . . . . . . . : 255.255.255.0
IPv4 Address. . . . . . . . . . . : 192.168.99.53(Preferred)
Subnet Mask . . . . . . . . . . . : 255.255.255.0
IPv4 Address. . . . . . . . . . . : 192.168.99.54(Preferred)
Subnet Mask . . . . . . . . . . . : 255.255.255.0
IPv4 Address. . . . . . . . . . . : 192.168.99.55(Preferred)
Subnet Mask . . . . . . . . . . . : 255.255.255.0
IPv4 Address. . . . . . . . . . . : 192.168.99.56(Preferred)
Subnet Mask . . . . . . . . . . . : 255.255.255.0
IPv4 Address. . . . . . . . . . . : 192.168.99.57(Preferred)
Subnet Mask . . . . . . . . . . . : 255.255.255.0
IPv4 Address. . . . . . . . . . . : 192.168.99.58(Preferred)
Subnet Mask . . . . . . . . . . . : 255.255.255.0
IPv4 Address. . . . . . . . . . . : 192.168.99.59(Preferred)
Subnet Mask . . . . . . . . . . . : 255.255.255.0
IPv4 Address. . . . . . . . . . . : 192.168.99.60(Preferred)
Subnet Mask . . . . . . . . . . . : 255.255.255.0
IPv4 Address. . . . . . . . . . . : 192.168.99.61(Preferred)
Subnet Mask . . . . . . . . . . . : 255.255.255.0
IPv4 Address. . . . . . . . . . . : 192.168.99.62(Preferred)
Subnet Mask . . . . . . . . . . . : 255.255.255.0
IPv4 Address. . . . . . . . . . . : 192.168.99.64(Preferred)
Subnet Mask . . . . . . . . . . . : 255.255.255.0
IPv4 Address. . . . . . . . . . . : 192.168.99.65(Preferred)
Subnet Mask . . . . . . . . . . . : 255.255.255.0
IPv4 Address. . . . . . . . . . . : 192.168.99.66(Preferred)
Subnet Mask . . . . . . . . . . . : 255.255.255.0
IPv4 Address. . . . . . . . . . . : 192.168.99.67(Preferred)
Subnet Mask . . . . . . . . . . . : 255.255.255.0
IPv4 Address. . . . . . . . . . . : 192.168.99.68(Preferred)
Subnet Mask . . . . . . . . . . . : 255.255.255.0
IPv4 Address. . . . . . . . . . . : 192.168.99.70(Preferred)
Subnet Mask . . . . . . . . . . . : 255.255.255.0
IPv4 Address. . . . . . . . . . . : 192.168.99.71(Preferred)
Subnet Mask . . . . . . . . . . . : 255.255.255.0
IPv4 Address. . . . . . . . . . . : 192.168.99.100(Preferred)
Subnet Mask . . . . . . . . . . . : 255.255.255.0
IPv4 Address. . . . . . . . . . . : 192.168.99.108(Preferred)
Subnet Mask . . . . . . . . . . . : 255.255.255.0
IPv4 Address. . . . . . . . . . . : 192.168.99.109(Preferred)
Subnet Mask . . . . . . . . . . . : 255.255.255.0
IPv4 Address. . . . . . . . . . . : 192.168.99.112(Preferred)
Subnet Mask . . . . . . . . . . . : 255.255.255.0
IPv4 Address. . . . . . . . . . . : 192.168.99.63(Duplicate)
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 192.168.99.1

如果我這樣做pathping,就會有答案,第一個是 99.49,如果我的預設 IP 地址是 99.100

Tracing route to www.l.google.com [72.14.204.99]
over a maximum of 30 hops:
 0  Machine [192.168.99.49]

機器上有路由表:

Network Destination        Netmask          Gateway       Interface  Metric
             0.0.0.0          0.0.0.0     192.168.99.1    192.168.99.49    261
          10.10.10.0    255.255.255.0         On-link       10.10.10.10    261
         10.10.10.10  255.255.255.255         On-link       10.10.10.10    261
        10.10.10.255  255.255.255.255         On-link       10.10.10.10    261
        192.168.99.0    255.255.255.0         On-link     192.168.99.49    261
       192.168.99.49  255.255.255.255         On-link     192.168.99.49    261
       192.168.99.51  255.255.255.255         On-link     192.168.99.49    261
       192.168.99.52  255.255.255.255         On-link     192.168.99.49    261
       192.168.99.53  255.255.255.255         On-link     192.168.99.49    261
       192.168.99.54  255.255.255.255         On-link     192.168.99.49    261
       192.168.99.55  255.255.255.255         On-link     192.168.99.49    261
       192.168.99.56  255.255.255.255         On-link     192.168.99.49    261
       192.168.99.57  255.255.255.255         On-link     192.168.99.49    261
       192.168.99.58  255.255.255.255         On-link     192.168.99.49    261
       192.168.99.59  255.255.255.255         On-link     192.168.99.49    261
       192.168.99.60  255.255.255.255         On-link     192.168.99.49    261
       192.168.99.61  255.255.255.255         On-link     192.168.99.49    261
       192.168.99.62  255.255.255.255         On-link     192.168.99.49    261
       192.168.99.64  255.255.255.255         On-link     192.168.99.49    261
       192.168.99.65  255.255.255.255         On-link     192.168.99.49    261
       192.168.99.66  255.255.255.255         On-link     192.168.99.49    261
       192.168.99.67  255.255.255.255         On-link     192.168.99.49    261
       192.168.99.68  255.255.255.255         On-link     192.168.99.49    261
       192.168.99.70  255.255.255.255         On-link     192.168.99.49    261
       192.168.99.71  255.255.255.255         On-link     192.168.99.49    261
      192.168.99.100  255.255.255.255         On-link     192.168.99.49    261
      192.168.99.108  255.255.255.255         On-link     192.168.99.49    261
      192.168.99.109  255.255.255.255         On-link     192.168.99.49    261
      192.168.99.112  255.255.255.255         On-link     192.168.99.49    261
      192.168.99.255  255.255.255.255         On-link     192.168.99.49    261
           224.0.0.0        240.0.0.0         On-link     192.168.99.49    261
           224.0.0.0        240.0.0.0         On-link       10.10.10.10    261
     255.255.255.255  255.255.255.255         On-link     192.168.99.49    261
     255.255.255.255  255.255.255.255         On-link       10.10.10.10    261

我認為我的路線應該是這樣的:

Network Destination        Netmask          Gateway       Interface  Metric
             0.0.0.0          0.0.0.0     192.168.99.1    **192.168.99.100**    261
          10.10.10.0    255.255.255.0         On-link       10.10.10.10    261
         10.10.10.10  255.255.255.255         On-link       10.10.10.10    261
        10.10.10.255  255.255.255.255         On-link       10.10.10.10    261
        192.168.99.0    255.255.255.0         On-link     192.168.99.100    261
       192.168.99.49  255.255.255.255         On-link     192.168.99.100    261
       192.168.99.51  255.255.255.255         On-link     192.168.99.100    261
       192.168.99.52  255.255.255.255         On-link     192.168.99.100    261
       192.168.99.53  255.255.255.255         On-link     192.168.99.100    261
       192.168.99.54  255.255.255.255         On-link     192.168.99.100    261
       192.168.99.55  255.255.255.255         On-link     192.168.99.100    261
       192.168.99.56  255.255.255.255         On-link     192.168.99.100    261
       192.168.99.57  255.255.255.255         On-link     192.168.99.100    261
       192.168.99.58  255.255.255.255         On-link     192.168.99.100    261
       192.168.99.59  255.255.255.255         On-link     192.168.99.100    261
       192.168.99.60  255.255.255.255         On-link     192.168.99.100    261
       192.168.99.61  255.255.255.255         On-link     192.168.99.100    261
       192.168.99.62  255.255.255.255         On-link     192.168.99.100    261
       192.168.99.64  255.255.255.255         On-link     192.168.99.100    261
       192.168.99.65  255.255.255.255         On-link     192.168.99.100    261
       192.168.99.66  255.255.255.255         On-link     192.168.99.100    261
       192.168.99.67  255.255.255.255         On-link     192.168.99.100    261
       192.168.99.68  255.255.255.255         On-link     192.168.99.100    261
       192.168.99.70  255.255.255.255         On-link     192.168.99.100    261
       192.168.99.71  255.255.255.255         On-link     192.168.99.100    261
      192.168.99.100  255.255.255.255         On-link     192.168.99.100    261
      192.168.99.108  255.255.255.255         On-link     192.168.99.100    261
      192.168.99.109  255.255.255.255         On-link     192.168.99.100    261
      192.168.99.112  255.255.255.255         On-link     192.168.99.100    261
      192.168.99.255  255.255.255.255         On-link     192.168.99.100    261
           224.0.0.0        240.0.0.0         On-link     192.168.99.100    261
           224.0.0.0        240.0.0.0         On-link       10.10.10.10    261
     255.255.255.255  255.255.255.255         On-link     192.168.99.100    261
     255.255.255.255  255.255.255.255         On-link       10.10.10.10    261

如何確定圖像中使用的 IP 地址(假定為預設 IP 地址)將被我的伺服器用作預設地址?

使用 Server 2008 Service Pack 2(不是 R2)或 Vista SP2和 MS 修補程序 KB975808有一個解決方案,雖然有點笨拙。您將刪除所有您不希望作為源的地址,然後在命令行使用重新添加每個地址

Netsh int ipv4 add address <Interface Name> <ip address> skipassource=true

此修復程序啟用“作為源跳過”標誌。

如需深入了解不同 Windows 版本如何選擇源 IP,請參閱此TechNet 部落格文章

網路介面沒有“預設 IP”之類的東西;相反,您的系統路由表定義了與其他設備通信時應使用的邏輯介面。

聽起來您想做的是配置預設路由。這將導致這台機器發起的所有對話都是從特定 IP 進行的。

使用 route add 添加預設網關

引用自:https://serverfault.com/questions/119840