English 中文(简体)
Using Clients IP as the Servers IP
原标题:

This might be one of those "huh, why?" questions, but I figured it would be worth the try.

How would one, from a server-side application, use the clients IP address as the applications IP address to another website? The basic idea is that any work the server side application does, is seen as the client itself doing the work, and not the servers static IP.

I am not sure if changing HTTP headers would work, but I could be wrong. Is there any documentation out there on this?

Thanks,

Kyle

最佳回答

Utterly, utterly impossible. You won t even be able to open a TCP connection because the other website s server will try to handshake with the client, and fail.

An IP address isn t just any old ID, it s the actually address that servers will send any response to. Spoofing it basically only makes sense if you can fit your request into a single IP packet (which rules out TCP and thus HTTP) and are not interested in the response. Even then it can fail because your ISP s routers may have anti-spoofing rules that drop packets with "outside" IP addresses originating from "inside" networks.

问题回答

Why on earth would a legitimate application want to spoof its IP address?

Changing HTTP headers might cut it, but most likely it won t. Depends on how naive the other server is.

It sounds like you re trying to do something the wrong way, can you give a bit more information as to what exactly the use-case is?

If there s no processing to be done in between, you can do port forwarding on your server s IP firewall, so the client connects to your server but ends up talking to the other server.

If there s more involvement of your server, then the correct thing to do would be to pass the client s IP to the other server as part of the URL (if it s a web app) or elsewhere in the data (if not) so the receiving server can know and correctly log the process without any need for fakery. Of course this would also call for a change in the other app.

Again assuming we re talking about HTTP, another idea that came to my mind would be to redirect your client to the other server. As long as all necessary data is in the URI, you could advise the client s browser to connect to the other server with a URI of your own creation that could carry whatever extra value your server s processing adds to the request.

Decades ago, the designer of internet asked, "how can we prevent Kyle Rozendo from doing such a devious thing?"

If the client is cooperating, you can install some software on client machine, and do the work from there. For example, a signed java applet on your page. [kidding]If the client is not cooperating, install some trojan virus[/kidding]





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签