Computer >> Computer tutorials >  >> System >> Windows Server

Assign Multiple IP Addresses (Aliases) to a Single NIC

In some cases an administrator needs to configure multiple IP addresses one a single network interface (NIC) in Windows. An example of such situations can be the need to run multiple sites with unique IP addresses and SSL certificates (e. g., SSL certificates from Let’s Encrypt) on one IIS or Apache server, preparing to change of IP addressing in a subnet, binding the applications to different IP addresses, etc.

Let’s consider how to add an additional static IP address on a network interface in Windows 10 (in the same way you can add an additional IP address to a NIC on Windows Server). First of all, make sure that only one IP address is assigned to your Ethernet network adapter. To do it, run this command:

ipconfig

Assign Multiple IP Addresses (Aliases) to a Single NIC

As you can see, one IP address (192.168.1.90) is assigned to the local network connection (it is called Ethernet0 in my case).

You can add the second static IP address in a number of ways.

How to Add an Additional IP Address via Windows GUI?

You can add the second IP address from the Windows GUI.

  1. Open the Control Panel –> Network and Internet –> Network and Sharing Center -> Change adapter settings (or just run the ncpa.cpl command);
  2. Open the properties of your network interface;
  3. Select TCP/IP v4 in the list of protocols and click Properties; Assign Multiple IP Addresses (Aliases) to a Single NIC
  4. Click the Advanced button and then press Add in the IP Addresses section;
  5. Specify an additional IP address, IP subnet mask and click Add;
  6. Save the changes by clicking OK several times. Assign Multiple IP Addresses (Aliases) to a Single NIC

Using the ipconfig command, make sure that the second IP address has appeared on this interface.

Assign Multiple IP Addresses (Aliases) to a Single NIC

Check the availability of the second IP address from other computers in the same network using the ping command. It should respond.

Assign Multiple IP Addresses (Aliases) to a Single NIC

SkipAsSource Flag

The main drawback of adding the second IP address using this method is that the SkipAsSource (SkipAsSource=False) flag is not enabled for it. If SkipAsSource is enabled (True), the IP address won’t be used by the system for outbound connections, except if it is explicitly used by a certain application. Also, if the flag is enabled, the second IP address is not registered in the DNS (even when the dynamic registration is enabled). In general, you can set the main IP address using SkipAsSource parameter.

How to Assign the Second IP Address Using Netsh Command?

You can assign an additional IP address from the command prompt using the Netsh utility. This command also allows you to set the SkipAsSource for an IP address.

Open the command prompt as administrator and run this command:

Netsh int ipv4 add address name="Local Area Connection" 192.168.1.92 255.255.255.0 SkipAsSource=True

Adding Secondary IP Address Using PowerShell

You can also add a second IP alias to a network interface using the NetIPAddress PowerShell cmdlets (this cmdlet appeared in PowerShell version in Windows 2012 / Windows 8.)

Display the list of available interfaces:

Get-NetIPAddress | ft IPAddress, InterfaceAlias, SkipAsSource

Assign Multiple IP Addresses (Aliases) to a Single NIC

IPAddress InterfaceAlias SkipAsSource<
--------- -------------- ------------
172.23.53.241 vEthernet False
192.168.1.90 Ethernet0 False
127.0.0.1 Loopback Pseudo-Interface 1 False

To add an additional IP address for the Ethernet0 NIC, run this command:

New-NetIPAddress –IPAddress 192.168.1.92 –PrefixLength 24 –InterfaceAlias “Ethernet0” –SkipAsSource $True

Assign Multiple IP Addresses (Aliases) to a Single NIC
IPAddress : 192.168.1.92
InterfaceIndex : 11
InterfaceAlias : Ethernet0
AddressFamily : IPv4
Type : Unicast
PrefixLength : 24
PrefixOrigin : Manual
SuffixOrigin : Manual
AddressState : Tentative
ValidLifetime : Infinite ([TimeSpan]::MaxValue)
PreferredLifetime : Infinite ([TimeSpan]::MaxValue)
SkipAsSource : True
PolicyStore : ActiveStore

To modify SkipAsSource parameter and allow the outgoing traffic from this IP address of the network interface, use this command:

Get-NetIPAddress 192.168.1.92 | Set-NetIPAddress -SkipAsSource $False

Assign Multiple IP Addresses (Aliases) to a Single NIC