Outgoing IP?

Hi,

I have a .NET client that has a TCP/IP socket connection to a remote server. This is done from a server which has several IP addresses assigned and configured at the network card. So, now I was wondering how I could direct the outgoing request through a specific IP of those assigned to the server.
Assume, server has IP's 1.1.1.1/10 - I'd like the outgoing request to be sent with IP 1.1.1.8.
Is there a way to do that

Thanks,

Tom


Answer this question

Outgoing IP?

  • GregAbd

    You can always bind to a local end point before you connect

  • BigMouthTortoise

    To expand on what Durga is saying:


    // create a socket
    Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

    // all traffic will be sent from x.x.x.x
    s.Bind(new IPEndPoint(IPAddress.Parse("x.x.x.x")));

    s.Connect(...)

     


    This should get you going.



  • Jassim Rahma

    thanks, that helped
  • Outgoing IP?