2

What I need is quite the same asked here, I don't understand the answer too well, because of my knowledge, so maybe someone could help me.

What I'd like to do is using the connected user's IP address (Client IP) to make the server-side HttpWebRequest, so I would grab the user's IP and make the call with it.

What I'd like to obtain is that every connected user makes HttpWebRequests with their IP.

Is it possible?

If it is, how should I edit that code to do this?

Thanks.

Community
  • 1
  • 1
  • I don't think this is possible; the linked question is a bit different, as it refers to using a *local* IP. (I'm not sure though, it might be possible to do some fancy networking to make your server act as a *proxy*.) Can you provide more info as to what you're trying to accomplish? – McGarnagle Aug 20 '12 at 23:01
  • I have to call a service that limits the requests per IP address. Since many users use the same web application, I would use the user's client IP to make the webrequest, like it was a client call. I hope it's more clear now. Thanks for the answer though. –  Aug 20 '12 at 23:04
  • Gotcha ... and it's not possible for you to make the service call directly from the client (ajax)? – McGarnagle Aug 20 '12 at 23:06
  • Nope, actually I have to do that server-side, like the example in the other question. –  Aug 20 '12 at 23:07
  • re: "like the example in the other question" -- Perhaps I am missing something, but the other example is using client side code to enforce which NIC is used to contact the server. It sounds like you want to have the server make a connection to itself using the remote client's IP address. Don't think that's going to work. – Jesse Chisholm Aug 25 '12 at 22:44

2 Answers2

1

This is impossible. My answer to the other question was about selecting which IP Address (read: network adapter) to use for a request. However, you cannot invent IP Addresses out of thin air, nor use IP Addresses that are not yours (in a physical, attached-to-this-computer sense).

Now, technically, using Raw Sockets, you can spoof another IP Address in your packets. However, the problem with that is that the return traffic will go to the IP Address you specify, not the one you actually have!

So, my advice is to not pursue this line of thought any further, and find another way to do whatever it is that you are trying to do.

Mike Caron
  • 14,351
  • 4
  • 49
  • 77
0

You may only make outbound connections from your server using an IP that is assigned to the server. If you tried to use a client's IP, it would fail.

Even if it did not fail, it would be a form of spoofing and would fail pretty qucikly anyway- the handshake that occurs using tcpip would case the remote connection to send an acknowledge packet back to the source ip (in your case, the client ip) which would result in an error.

If you are using UDP, it actually is possible to do this, but that is a different subject.

Brady Moritz
  • 8,624
  • 8
  • 66
  • 100