6

I've got a Windows Server 2012R2 VM with 3 IP addresses: 4.70, 4.17 and 4.18

4.70 is the 1st IP address entered on the Properties Sheet, 4.17 and 4.18 are entered in the advanced dialog.

As you can see in the route print, windows is binding 4.17 as the default IP, and I want to force windows to use 4.70 as the default. 4.17/4.18 are used in IIS, and there's some non-trivial firewall issues that need to get worked out. In the mean time, I need the rest of the traffic on the box to originate from 4.70.

ipconfig/all:

Ethernet adapter Ethernet0:
Description . . . . . . . . . . . : Intel(R) 82574L Gigabit Network Connection
Physical Address. . . . . . . . . : 00-50-56-9B-33-55
DHCP Enabled. . . . . . . . . . . : No
IPv4 Address. . . . . . . . . . . : 192.168.4.17(Preferred)
Subnet Mask . . . . . . . . . . . : 255.255.254.0
IPv4 Address. . . . . . . . . . . : 192.168.4.18(Preferred)
Subnet Mask . . . . . . . . . . . : 255.255.254.0
IPv4 Address. . . . . . . . . . . : 192.168.4.70(Preferred)
Subnet Mask . . . . . . . . . . . : 255.255.254.0
Default Gateway . . . . . . . . . : 192.168.4.1

Route Print:

IPv4 Route Table
===========================================================================
Active Routes:
Network Destination        Netmask          Gateway       Interface  Metric
      0.0.0.0          0.0.0.0      192.168.4.1     192.168.4.17    266

3 Answers3

9

have you seen this link? http://securahosting.com/technical-insight/windows-server/set-primary-ip-address-windows-server-2012#.VOe_0EfF98E

and this: http://www.confusedamused.com/notebook/source-ip-address-preference-with-multiple-ips-on-a-nic/

shortly, in netsh address setup use SkipAsSource=true flag for all non-primary IPs

4

You can easily use PowerShell to do this:

Set-NetIPAddress -IPAddress 192.168.1.221 -SkipAsSource:$true

Do that for all IP addresses on interface that you don't want to be default. Leave one IP where SkipAsSource = False. That IP will end up being the default.

2

Here I found a post with a very detailed example on how to define the primary IP output:

https://www.sysadmit.com/2018/12/windows-configurar-ip-primaria-salida.html

Example extracted from previous link:

Imagine that we want to configure the following IP addresses in the same network interface: 172.17.0.2, 172.17.0.3 and 172.17.0.10 but that the primary IP address of output is: 172.17.0.10 instead of 172.17.0.2.

We remove the current TCP / IP configuration and execute the following:

netsh int ipv4 add address "Ethernet0" 172.17.0.2/16 SkipAsSource = true

netsh int ipv4 add address "Ethernet0" 172.17.0.3/16 SkipAsSource = true

netsh int ipv4 add address "Ethernet0" 172.17.0.10/16 SkipAsSource = false

If we look, with the first two lines, we indicate that both 172.17.0.2 and 172.17.0.3 are ignored as primary IP addresses of output, therefore it will be the IP address 172.17.0.10 which will be considered as the primary IP address of output.