Article

Table of Contents
Try Vultr Today with

$50 Free on Us!

Want to contribute?

You could earn up to $300 by adding new articles!

Configure Windows with Multiple IP Addresses via PowerShell

Last Updated: Thu, Jun 18, 2020
Networking System Admin Windows Guides

Introduction

A basic network configuration at Vultr consists of a single IPv4 address, configured by DHCP. If you have advanced networking requirements, Vultr supports multiple public IPs and up to five private networks. You need to manually configure these advanced scenarios. Refer to the networking configuration page in the customer portal for your exact configuration. This example demonstrates three public IPv4 addresses, two private IPv4 networks, and two public IPv6 addresses.

This tutorial applies to:

  • Windows Server 2019
  • Windows Server 2016
  • Windows Server 2012 R2

1. Locate IP Info

Open the server information page in the customer portal. Make a note of the IP information. This tutorial uses the values shown below.

IPv4 Info

MultipleIP

IPv6 Info

MultipleIP

Click the network configuration link to locate the IPv4 DNS server information. This tutorial uses DNS servers:

  • IPv4 DNS: 192.0.2.200
  • IPv6 DNS: 2001:db8:1000::1

A secondary IPv6 address of 2001:db8:1000::200 will also be added to the public adapter.

2. Gather Information from Windows

  1. Connect to the server via RDP.
  2. Open an administrative PowerShell. (Start > Right-click on PowerShell > Run as Administrator)
  3. Look up the Adapter info.

    PS> Get-NetAdapter | Format-List -Property Name, ifIndex
    

    The report displays:

    Name                 : Ethernet
    ifIndex              : 1
    
    Name                 : Ethernet 2
    ifIndex              : 2
    
    Name                 : Ethernet 3
    ifIndex              : 3
    

    The interface Name corresponds to the adapter name in the Network and Sharing Center. The ifIndex is also known as InterfaceIndex in PowerShell. The ifIndex for your adapters will be different. For simplicity, this tutorial uses:

    • ifIndex 1: The public adapter
    • ifIndex 2: The first private adapter
    • ifIndex 3: The second private adapter
  4. Verify the current status of the public adapter.

    PS > Get-NetIPAddress -InterfaceIndex 1
    

    Verify IPAddress matches the Main IP shown on the server information page, and PrefixOrigin is "Dhcp" to confirm "InterfaceIndex 1" is the public adapter.

    IPAddress         : 192.0.2.101
    InterfaceIndex    : 1
    InterfaceAlias    : Ethernet
    AddressFamily     : IPv4
    Type              : Unicast
    PrefixLength      : 23
    PrefixOrigin      : Dhcp
    SuffixOrigin      : Dhcp
    

3. Make IP Changes

Making IP changes via RDP is not advised because the network will drop while changes are made. However, the web console does not allow copy-paste of the PowerShell commands below. For convenience, make a copy of the commands in Notepad on the server via RDP, then continue on the web console.

  1. Copy the following information into Notepad on the server while connected via RDP. Save the Notepad file to the desktop.
  2. Leave Notepad and your administrative PowerShell open.
  3. Disconnect your RDP session without logging out.
  4. Connect to the server via the web console. Notepad and PowerShell should still be open. You can copy-paste commands from Notepad to PowerShell, and the web console will remain connected when the network disconnects.
  5. Turn off DHCP on the public interface.

    PS> Set-NetIPInterface -InterfaceIndex 1 -Dhcp Disabled
    
  6. Set the static IP address on the public interface.

    PS> New-NetIPAddress –InterfaceIndex 1 –IPAddress 192.0.2.101 –PrefixLength 23 -DefaultGateway 192.0.2.1 -AddressFamily IPv4
    

    The parameters explained:

    • –InterfaceIndex 1: The public interface
    • –IPAddress 192.0.2.101: The first public IP address
    • -PrefixLength 23: The prefix for Netmask 255.255.254.0
    • -DefaultGateway 192.0.2.1: The gateway
    • -AddressFamily IPv4: This is an IPv4 configuration.
  7. Set a second static IP address on the public interface. A -PrefixLength of 32 sets the Netmask to 255.255.255.255.

    PS> New-NetIPAddress –InterfaceIndex 1 –IPAddress 192.0.2.102 –PrefixLength 32 -AddressFamily IPv4
    
  8. An example of a third static IP address on the public interface:

    PS> New-NetIPAddress –InterfaceIndex 1 –IPAddress 192.0.2.103 –PrefixLength 32 -AddressFamily IPv4
    
  9. The public interface receives an IPv6 address via DHCP. Turn off IPv6 randomized privacy addressing:

    PS> Set-NetIPv6Protocol -RandomizeIdentifiers Disabled
    PS> Set-NetIPv6Protocol -UseTemporaryAddresses Disabled
    
  10. Add a second IPv6 address to the public interface.

    PS> New-NetIPAddress –InterfaceIndex 1 –IPAddress 2001:db8:1000::200 –PrefixLength 64 -AddressFamily IPv6
    
  11. Set the IPv4 and IPv6 DNS on the public interface. You may add multiple IPv4 and IPv6 DNS servers if desired.

    PS> Set-DnsClientServerAddress -InterfaceIndex 1 -ServerAddresses ("192.0.2.200","2001:db8:1000::1")
    
  12. Add an IP address to the first private network, InterfaceIndex 2. A -PrefixLength of 20 sets the Netmask to 255.255.240.0.

    PS> New-NetIPAddress –InterfaceIndex 2 –IPAddress 10.1.1.100 –PrefixLength 20 -AddressFamily IPv4
    
  13. Add an IP address to InterfaceIndex 3, the second private network.

    PS> New-NetIPAddress –InterfaceIndex 3 –IPAddress 10.2.2.200 –PrefixLength 20 -AddressFamily IPv4
    
  14. Set the MTU to 1450 bytes on both private network interfaces.

    PS> Set-NetIPInterface –InterfaceIndex 2 -NlMtuBytes 1450
    PS> Set-NetIPInterface –InterfaceIndex 3 -NlMtuBytes 1450
    

4. Verification

Verify the DNS servers are correct.

PS> Get-DnsClientServerAddress -InterfaceIndex 1 

InterfaceAlias               Interface Address ServerAddresses
                             Index     Family
--------------               --------- ------- ---------------
Ethernet                             1 IPv4    {192.0.2.200}
Ethernet                             1 IPv6    {2001:db8:1000::1}

Verify the public gateway.

PS> Get-NetRoute -DestinationPrefix "0.0.0.0/0" | Format-List -Property ifIndex, DestinationPrefix, NextHop

ifIndex           : 1
DestinationPrefix : 0.0.0.0/0
NextHop           : 45.77.150.1

Verify the IPv4 info for all adapters.

PS> Get-NetIPAddress -InterfaceIndex 1 -AddressFamily IPv4
PS> Get-NetIPAddress -InterfaceIndex 2 -AddressFamily IPv4
PS> Get-NetIPAddress -InterfaceIndex 3 -AddressFamily IPv4

Verify the IPv6 info for the public adapter.

PS> Get-NetIPAddress -InterfaceIndex 1 -AddressFamily IPv6

Verify the MTU setting. The public interface will be 1500, the two private adapters will be 1450.

PS> Get-NetIPInterface –InterfaceIndex 1 
PS> Get-NetIPInterface –InterfaceIndex 2 
PS> Get-NetIPInterface –InterfaceIndex 3 

Conclusion

Windows networking is fully configurable from the command-line. After completing these steps in PowerShell, these values will be visible in the GUI network dialogs.

Want to contribute?

You could earn up to $300 by adding new articles