Pick IP/NIC used to send UDP traffic

Discussion in 'Server Networking' started by Smedly Tonker, Oct 26, 2006.

  1. Is there any network Gurus out there that can answer the below question?



    Question:

    How in software can I specify that socket traffic only be sent using a
    certain IP? Remember that binding to an address only grantees which IP the
    traffic can come from and not how it is sent. From my description of the
    problem below, it is not possible to mess with the route table as either one
    instance of my server software will work and the other will fail. What is
    needed is a way to grantee delivery using a certain IP at the socket level.



    Description of problem:

    I need to be able to run two instances of my server software on a server
    (Windows Server 2003). I have two NICs within the server and should be able
    to bind a listen socket on the same port for each IP address. I will bind
    each listen socket to one of the two IP address. This will grantee that
    incoming traffic will only be received by the designated NIC. It will not
    however grantee which IP/NIC is used to send a UDP message. Messages must be
    sent from the correct IP address or the corresponding ACKs will be received
    by the wrong server instance. If each NIC has the same route metric than it
    is a dice game on which will be used to send my UDP traffic.
     
    Smedly Tonker, Oct 26, 2006
    #1
    1. Advertisements

  2. Smedly Tonker

    Markus Humm Guest

    Hello,

    I'd say this depends on your subnet configuration. Think about the NICs
    being on different subnets, then there may only be one route.

    Greetings

    Markus
     
    Markus Humm, Oct 26, 2006
    #2
    1. Advertisements

  3. I don't think that there is any good documented way to override the routing
    table with selecting which physical interface to send on with the default
    Microsoft sockets provider in use. SO_DONTROUTE is, as far as I know,
    ignored for Microsoft providers.

    I think that the DHCP client service (in dhcpsvc.dll) used some undocumented
    setsockopt and WSAIoctl calls to turn off routing for a UDP socket, but I'm
    not sure if these are still used for modern OS's. You might try
    disassembling a bit of dhcpsvc to find out.
     
    Skywing [MVP], Oct 26, 2006
    #3
  4. Smedly Tonker

    Mike Lowery Guest

    You need to modify your route table. See
    http://www.informit.com/articles/article.asp?p=24375&rl=1.
     
    Mike Lowery, Oct 26, 2006
    #4
  5. Did you read in my post why setting a route table entry would not work?
    Assuming you did, but did not understand, the reason is that if these NICs
    are on the same subnet and you give one IP/NIC a preference in the route
    table, then all traffic by either server will be deliver from the IP/NIC. So
    if a message is sent from server A then it might be delivered by server Bs
    IP/NIC. This will cause my remote client to ACK server B and not server A.
    As far as server A knows the message was not delivered.
     
    Smedly Tonker, Oct 26, 2006
    #5
  6. Smedly Tonker

    Mike Lowery Guest

    Mike Lowery, Oct 27, 2006
    #6
  7. Smedly Tonker

    Pavel A. Guest

    For a quick and 100% robust solution, try a virtual machine.
    Bind it's NIC to your other physical NIC, and run the 2nd instance
    of your server in the VM.

    --PA
     
    Pavel A., Oct 27, 2006
    #7
  8. Interesting; thanks for this link.

    So, if one computer has two adapters connected to the same physical network,
    how should they be configured, and can this be accomplished with DHCP?
     
    Michael K. O'Neill, Oct 27, 2006
    #8
  9. Smedly Tonker

    Bill Grant Guest

    No, you can't really do that with DHCP. When a machine starts, the NIC
    sends a broadcast on the wire to find a DHCP server. The server will send
    back an offer of an IP from the scope which matches the IP subnet where the
    broadcast was received.

    If two NICs are on the same Ethernet segment they will always get IP
    addresses in the same IP subnet, because the request will always arrive
    directly at the same NIC on the DHCP server.

    What exactly do you want these two NICs to do?
     
    Bill Grant, Oct 27, 2006
    #9
  10. Or use IPHLPAPI to change forwarding on the fly
    Arkady
     
    Arkady Frenkel, Oct 28, 2006
    #10
  11. Thanks, but I'm not the OP. I am simply trying to gain a better
    understanding of the proper configuration of such systems.

    So, I guess I should apologize for hijacking the thread.

    Mike
     
    Michael K. O'Neill, Oct 28, 2006
    #11
  12. Are you suggesting to change the routing table using the IPHLPAPI or
    something else? Each server instance will be sending up to 60 messages per
    second - If you are suggesting changing the routing table this often, I
    don't think this is going to fly.
     
    Smedly Tonker, Oct 30, 2006
    #12
  13. In such scenario you need to use different configuration ( design )
    Arkady
     
    Arkady Frenkel, Oct 31, 2006
    #13
  14. Thanks for the reply - this sounds the most reasonable of all of the
    suggestions.
     
    Smedly Tonker, Nov 2, 2006
    #14
  15. "Vista your problem just does not exist - MSFT solved it for you". So how
    did they do it, or rather how do I take advantage of this in Vista? Is thier
    a new socket API that allows me to send traffic through a specific NIC/IP?
     
    Smedly Tonker, Nov 9, 2006
    #15
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.