I have a Windows Server which has ~10 IP addresses statically bound. The problem is I don't know how to specify the default IP address.
Sometimes when I assign a new address to the NIC, the default IP address changes with the last IP entered in the advanced IP configuration on the NIC. This has the effect (since I use NAT) that the outgoing public IP changes too.
Even though this problem is currently on Windows Server 2008.
How can you set the default IP address on a NIC when it has multiple IP addresses bound?
There is more explication on my problem.
alt text http://www.nmediasolutions.com/_images/probleme/ip.png
Here is the output of 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
If I do a pathping
there is the answer, the first up is the 99.49, also if my default IP address is 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]
There is the routing table on the machine:
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
I think my route should look like:
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
How can I be sure the IP address used in the image (supposed to be the default IP address) will be use by my server as the default address?
With Server 2008 Service Pack 2 (not R2), or Vista SP2 and MS hotfix KB975808 there is a solution, although a bit clumsy. You would remove all the addresses you DON'T want as a source, then re-add each one at the command line using
The hotfix enables the "Skip As Source" flag.
For a deeper dive on how different Windows versions select source IPs, see this TechNet blog post.
There isn't such as thing as a "Default IP" for a network interface; rather your systems routing table defines which logical interface should be used when communicating with other devices.
It sounds like what you'd like to do is configure a default route. This would cause all conversations initiated by this machine to be made from a specific IP.
Use route add to add a default gateway
Your situation is not quite clear, but if I get you right:
1) Why won't you just set your "need-to-be the default" IP the last?
2) Or, maybe you can try this (assuming that the gateway address is 192.168.99.1):
To get more information about the syntax of the "route" command, look here: http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/route.mspx?mfr=true
Could you not use metrics on the IP addresses? In the TCP/IP properties, uncheck Automatic Metric and assign a static one with a value lower than 261 (as shown in your screenshot) to the address you want for your default.
A command in the form:
> route add 0.0.0.0 mask 0.0.0.0 192.168.99.1 metric xxx if yyy
will change the address seen when the machine goes to any non-192.168.99.0/24 and non-10.10.10.0/24 address. That is, when the default gateway is used. The metric (xxx) should be higher than anything else to ensure the rule is used. The interface (yyy) must be interface to use. But, I don't think there is a way to control which IP address on that interface to use if there are multiple IP addresses.
> route add 192.168.99.0 mask 255.255.255.0 metric xxx if yyy
is similar but is for any 192.168.99.0/24 address the system goes to. The fact is that assigning multiple IP addresses to a single interface can have these kinds of issues.
I've been able to duplicate your issue: it just looks like Windows uses the lowest assigned IP address on a given network interface as the "outgoing" one, regardless of the actual order in which they were assigned.
I wasn't able to find any documentation about this behaviour, but I'm quite sure it is by design.
Edit
I think this really can't be done at the O.S. level, but it can be done by code in your application: a socket can be explicitly bound to a chosen IP address/port pair before connecting it to the remote endpoint. But you'll have to use lower-level libraries than standard web-services ones. I.E. you'll have to manually open a socket, connect it and use it to read/write data.
.NET/C# example:
This will open a connection to 1.2.3.4:80 originating it from 192.168.99.100:4242, so the remote host will see it coming from exactly that IP address.
Tried and tested by connecting to IIS, it logs the request as coming from the specified IP address.
The source address selection for an outbound call is handled differently by the TCP/IP stack since the Vista overhaul. In XP/2003 and earlier, the source address was determined by the route table when not explicitly declared by the application making the outbound call. Since Vista/2008, the source address could be determined by prefix affinity to the destination or next hop gateway address if destination is not local. The following Technet Blog posting explains the behavior change very well.
http://blogs.technet.com/b/networking/archive/2009/04/24/source-ip-address-selection-on-a-multi-homed-windows-computer.aspx
I have Windows 2008 R2 SP1 x64 Enterprise edition being used as a Web servers with One NIC.
I ran into the same issue described above. I want the Outbound connections to be handled by the default IP address (the one signed to the server) but it keeps randomly choosing which IP address out of my 10 IP addresses for the my 10 websites on that server.
They all show as preferred IP addresses if you run the following command.
I tried downloading the Hot Fix but for some reason (and I double, triple checked) it said "it cannot run on this OS version). If you guys want to try here it is.
If you have MS DNS server running you will notice that the SAME server name will be registered 11 times (in my case) 1 IP for the server and 10 IP for each of the websites.
What I believe it could be a WORKAROUND (at this time, unless someone else have a better solution)
Is to go to the windows server under the TCP properties where you entered the IP addresses for the Server and Websites, you will see there a DNS tab. Now UNCHECK the REGISTER THE CONNECTIONS ADDRESSES and REBOOT the server (and leave unchecked).
If you check in DNS server all the DNS entries with the IPs will have disappeared.
Now Enter MANUALLY in DNS the Server name and the Preferred IP address. And it should fix the issue.
If any of you have any better solution please share with us.
Gripe: Not sure why MS did not fix this issue. They should have created an option (like a check box) for servers that carries multiple IP addresses on the same subnet for you to select which IP address should be the preferred.
A 'default address' is the one put in the first input box on the interface card properties since it will reply by default with this one, all others are considered secondary.
(ISA server is a good example of that behavior as you can't tell it to reply with the IP it was contacted with...)
I found a solution:
This worked in my 2008R2/IIS7 with 20 IP adresses.
BR, Matija