Reputation: 3221
I've a server with several IP Addresses assigned to the network adapter.
On that server is a client app to connect to another server app via TCPClient. For all outgoing communications my servers default IP address is being used, however for this one application I'd like the outgoing communication to be send out on another local IP address.
Is it possible when communicating out to specify another locally assigned IP?
I'm trying to make the remote server app think it's from another IP so it will pass through firewalls etc....
Thanks in advance
Upvotes: 11
Views: 12937
Reputation: 32629
You can use the constructor of TcpClient
that accepts a local endpoint address:
TcpClient c=new TcpClient(new System.Net.IPEndPoint(...));
For example:
TcpClient c=new TcpClient(new IPEndPoint(IPAddress.Parse("192.168.1.1"), 0);
Reference: TcpClient Constructor (IPEndPoint)
Upvotes: 20