Specify the outgoing IP address to use with WCF client

前端 未结 3 1837
忘了有多久
忘了有多久 2020-12-06 15:35

How to define the LocalEndPoint to use by a WCF client when calling a WCF service (if the client machine has multiple IP addresses) ?

I have a machine located

3条回答
  •  北海茫月
    2020-12-06 15:56

    This is an older thread, but I have a suggestion for anyone finding this one as it lead me to track down a slightly different solution. We have two processes that we needed to run on separate processes on the same server.

    The issue was each by default chose the primary address that was bound to the NIC. We couldn't find a way to get the app to bind to a secondary address on the NIC.

    The workaround was to add a second NIC to the VM, move the secondary IP to the second NIC as the primary IP of the 2nd NIC. In Windows, you cannot have two default gateways (even if they point to the same address).

    So, on the 2nd NIC, we assigned the IP and the Subnet Mask only. To get the traffic to route out the proper interface, we added a route statement in the format of:

    route add 4.3.2.1 mask 255.255.255.255 1.2.3.4 IF 0x10002
    

    Where the host we needed the process to talk to is 4.3.2.1, the local Default Gateway is 1.2.3.4 and the second NIC shows up in the routing table as interface number 0x10002 (from route print).

    I hope this helps. I have a few more grey hairs because of this one.

提交回复
热议问题