1. DHCPが利用されている場合に、IP Aliasが構成できない!?
オンプレミス環境ではDHCPをあまり使ってこなかったので、気にしたことがなかったのだが、Windows ServerでDHCPが構成されている場合、IP Aliasを使って2つ目以降のIPアドレスをデフォルト設定では付与できない。
実際、AWSのdocsなどにも、以下のような説明がある。
https://docs.aws.amazon.com/ja_jp/AWSEC2/latest/WindowsGuide/config-windows-multiple-ip.html
Windows インスタンスが複数の IP アドレスを使用するには、インスタンスが DHCP サーバーではなく、静的 IP アドレス指定を使用するように設定する必要があります。
上記のドキュメントの通り、IPアドレスをDHCPではなくマニュアルで構成すればIP Aliasを構成できるのだが、WindowsではマニュアルでIPアドレスを構成すると、DNSまでマニュアルで指定する必要がある。IBM Cloudにおいては、VPEやPrivate DNSを利用する際に、Public Resolver(161.26.0.10/161.26.0.11)からPrivate Resolver(161.26.0.7/161.26.0.8)への変更や、Custom Resolverを利用した際のResolver IPアドレスへのDNS変更がDHCPで自動更新されないため、できたらIPアドレスをマニュアルで設定したくないというジレンマがある。
本稿では、Windows Server (DHCP構成)と併用してIP Alias/複数のIPアドレスを構成する方法の動作確認ができたので、ここではIBM CloudのVPC環境上のWindows Server 2022で確認してみた。
2. 本当にIP Aliasを構成できないのか、UIで確認してみる(失敗)。
& $env:SystemRoot\system32\control.exe ncpa.cpl
- Propertiesを選択
- Internet Protocol Version 4(TCP/IPv4)を選択して
Properties
を選択。 - DHCPが構成されている。
Advanced...
を選択。 -
Add
ボタンが押せない。
3. 本当にIP Aliasを構成できないのか、CLIで確認してみる(失敗)。
PS C:\Users\Administrator.WIN-SERVER111> ipconfig /all
Windows IP Configuration
Host Name . . . . . . . . . . . . : win-server111
Primary Dns Suffix . . . . . . . :
Node Type . . . . . . . . . . . . : Hybrid
IP Routing Enabled. . . . . . . . : No
WINS Proxy Enabled. . . . . . . . : No
Ethernet adapter Ethernet Instance 0:
Connection-specific DNS Suffix . :
Description . . . . . . . . . . . : Red Hat VirtIO Ethernet Adapter
Physical Address. . . . . . . . . : 02-00-03-3A-DF-FB
DHCP Enabled. . . . . . . . . . . : Yes
Autoconfiguration Enabled . . . . : Yes
Link-local IPv6 Address . . . . . : fe80::7f79:de57:2998:d9d1%4(Preferred)
IPv4 Address. . . . . . . . . . . : 172.18.0.12(Preferred)
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Lease Obtained. . . . . . . . . . : Thursday, May 30, 2024 1:52:17 AM
Lease Expires . . . . . . . . . . : Thursday, May 30, 2024 2:24:48 AM
Default Gateway . . . . . . . . . : 172.18.0.1
DHCP Server . . . . . . . . . . . : 172.18.0.1
DHCPv6 IAID . . . . . . . . . . . : 100794371
DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-2D-EA-20-4D-02-00-03-3A-DF-FB
DNS Servers . . . . . . . . . . . : 161.26.0.7
161.26.0.8
NetBIOS over Tcpip. . . . . . . . : Disabled
PS C:\Users\Administrator.WIN-SERVER111> netsh interface ipv4 show interfaces
Idx Met MTU State Name
--- ---------- ---------- ------------ ---------------------------
1 75 4294967295 connected Loopback Pseudo-Interface 1
4 15 1500 connected Ethernet Instance 0
PS C:\Users\Administrator.WIN-SERVER111> netsh interface ipv4 show interface "Ethernet Instance 0"
Interface Ethernet Instance 0 Parameters
----------------------------------------------
IfLuid : ethernet_32769
IfIndex : 4
State : connected
Metric : 15
Link MTU : 1500 bytes
Reachable Time : 27000 ms
Base Reachable Time : 30000 ms
Retransmission Interval : 1000 ms
DAD Transmits : 3
Site Prefix Length : 64
Site Id : 1
Forwarding : disabled
Advertising : disabled
Neighbor Discovery : enabled
Neighbor Unreachability Detection : enabled
Router Discovery : dhcp
Managed Address Configuration : enabled
Other Stateful Configuration : enabled
Weak Host Sends : disabled
Weak Host Receives : disabled
Use Automatic Metric : enabled
Ignore Default Routes : disabled
Advertised Router Lifetime : 1800 seconds
Advertise Default Route : disabled
Current Hop Limit : 0
Force ARPND Wake up patterns : disabled
Directed MAC Wake up patterns : disabled
ECN capability : application
RA Based DNS Config (RFC 6106) : disabled
DHCP/Static IP coexistence : disabled
ここで、netsh interface ipv4 add
を試してみる。
PS C:\Users\Administrator.WIN-SERVER111> netsh interface ipv4 add address "Ethernet Instance 0" 172.18.0.14 255.255.255.0 172.18.0.1
仕方がないので、VNC接続でどういう状況になったのかをUIから確認してみたところ、DHCP構成が無効にされて、単に先ほどのIPアドレスが手動で構成されただけであった(つまりDHCP構成と併用できていない)。
4. DHCP構成のままIP Aliasを構成する方法(成功)
以下に紹介されていた。要は、インターフェース設定にて、dhcpstaticipcoexistence=enabled
を指定すれば良い。
- https://superuser.com/questions/679134/add-a-static-ip-alias-to-a-dhcp-interface-on-windows-8-and-above/1250941
- https://solidoak.tech/2023/09/04/windows%E3%81%A7dhcp%E8%A8%AD%E5%AE%9A%E3%81%97%E3%81%A6%E3%81%84%E3%82%8B%E3%82%A4%E3%83%B3%E3%82%BF%E3%83%BC%E3%83%95%E3%82%A7%E3%83%BC%E3%82%B9%E3%81%AB%E3%82%BB%E3%82%AB%E3%83%B3%E3%83%80%E3%83%AA/
PS C:\Users\Administrator.WIN-SERVER111> netsh interface ipv4 set interface interface="Ethernet Instance 0" dhcpstaticipcoexistence=enabled
Ok.
PS C:\Users\Administrator.WIN-SERVER111> netsh interface ipv4 show interface "Ethernet Instance 0"
Interface Ethernet Instance 0 Parameters
----------------------------------------------
IfLuid : ethernet_32769
IfIndex : 4
State : connected
Metric : 15
Link MTU : 1500 bytes
Reachable Time : 27000 ms
Base Reachable Time : 30000 ms
Retransmission Interval : 1000 ms
DAD Transmits : 3
Site Prefix Length : 64
Site Id : 1
Forwarding : disabled
Advertising : disabled
Neighbor Discovery : enabled
Neighbor Unreachability Detection : enabled
Router Discovery : dhcp
Managed Address Configuration : enabled
Other Stateful Configuration : enabled
Weak Host Sends : disabled
Weak Host Receives : disabled
Use Automatic Metric : enabled
Ignore Default Routes : disabled
Advertised Router Lifetime : 1800 seconds
Advertise Default Route : disabled
Current Hop Limit : 0
Force ARPND Wake up patterns : disabled
Directed MAC Wake up patterns : disabled
ECN capability : application
RA Based DNS Config (RFC 6106) : disabled
DHCP/Static IP coexistence : enabled
ここで、先ほどのCLIの例と同様に、IP Aliasを構成する。
PS C:\Users\Administrator.WIN-SERVER111> netsh interface ipv4 add address "Ethernet Instance 0" 172.18.0.14 255.255.255.0 172.18.0.1
PS C:\Users\Administrator.WIN-SERVER111> ipconfig /all
Windows IP Configuration
Host Name . . . . . . . . . . . . : win-server111
Primary Dns Suffix . . . . . . . :
Node Type . . . . . . . . . . . . : Hybrid
IP Routing Enabled. . . . . . . . : No
WINS Proxy Enabled. . . . . . . . : No
Ethernet adapter Ethernet Instance 0:
Connection-specific DNS Suffix . :
Description . . . . . . . . . . . : Red Hat VirtIO Ethernet Adapter
Physical Address. . . . . . . . . : 02-00-03-3A-DF-FB
DHCP Enabled. . . . . . . . . . . : Yes
Autoconfiguration Enabled . . . . : Yes
Link-local IPv6 Address . . . . . : fe80::7f79:de57:2998:d9d1%4(Preferred)
IPv4 Address. . . . . . . . . . . : 172.18.0.12(Preferred)
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Lease Obtained. . . . . . . . . . : Thursday, May 30, 2024 2:40:35 AM
Lease Expires . . . . . . . . . . : Thursday, May 30, 2024 2:50:35 AM
IPv4 Address. . . . . . . . . . . : 172.18.0.14(Preferred)
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 172.18.0.1
DHCP Server . . . . . . . . . . . : 172.18.0.1
DHCPv6 IAID . . . . . . . . . . . : 100794371
DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-2D-EA-20-4D-02-00-03-3A-DF-FB
DNS Servers . . . . . . . . . . . : 161.26.0.7
161.26.0.8
NetBIOS over Tcpip. . . . . . . . : Disabled
PS C:\Users\Administrator.WIN-SERVER111> Get-NetIPAddress
IPAddress : fe80::7f79:de57:2998:d9d1%4
InterfaceIndex : 4
InterfaceAlias : Ethernet Instance 0
AddressFamily : IPv6
Type : Unicast
PrefixLength : 64
PrefixOrigin : WellKnown
SuffixOrigin : Link
AddressState : Preferred
ValidLifetime : Infinite ([TimeSpan]::MaxValue)
PreferredLifetime : Infinite ([TimeSpan]::MaxValue)
SkipAsSource : False
PolicyStore : ActiveStore
IPAddress : ::1
InterfaceIndex : 1
InterfaceAlias : Loopback Pseudo-Interface 1
AddressFamily : IPv6
Type : Unicast
PrefixLength : 128
PrefixOrigin : WellKnown
SuffixOrigin : WellKnown
AddressState : Preferred
ValidLifetime : Infinite ([TimeSpan]::MaxValue)
PreferredLifetime : Infinite ([TimeSpan]::MaxValue)
SkipAsSource : False
PolicyStore : ActiveStore
IPAddress : 172.18.0.14
InterfaceIndex : 4
InterfaceAlias : Ethernet Instance 0
AddressFamily : IPv4
Type : Unicast
PrefixLength : 24
PrefixOrigin : Manual
SuffixOrigin : Manual
AddressState : Preferred
ValidLifetime : Infinite ([TimeSpan]::MaxValue)
PreferredLifetime : Infinite ([TimeSpan]::MaxValue)
SkipAsSource : False
PolicyStore : ActiveStore
IPAddress : 172.18.0.12
InterfaceIndex : 4
InterfaceAlias : Ethernet Instance 0
AddressFamily : IPv4
Type : Unicast
PrefixLength : 24
PrefixOrigin : Dhcp
SuffixOrigin : Dhcp
AddressState : Preferred
ValidLifetime : 00:02:52
PreferredLifetime : 00:02:52
SkipAsSource : False
PolicyStore : ActiveStore
IPAddress : 127.0.0.1
InterfaceIndex : 1
InterfaceAlias : Loopback Pseudo-Interface 1
AddressFamily : IPv4
Type : Unicast
PrefixLength : 8
PrefixOrigin : WellKnown
SuffixOrigin : WellKnown
AddressState : Preferred
ValidLifetime : Infinite ([TimeSpan]::MaxValue)
PreferredLifetime : Infinite ([TimeSpan]::MaxValue)
SkipAsSource : False
PolicyStore : ActiveStore
なお、UIからは確認できないので注意が必要である。