Andy J
Andy J

Reputation: 556

Obtain the IP Address of a server

Here is the situation, we have a site that is hosted and updated by a third party vendor. I am providing links to additional resources that are hosted on our servers. A client will access the vendor site and click on a link to gain access to our additional resources. To validate that the request came from our third party vendor I need to get the IP address of the vendors server.

My question is, is there a way to get the IP address of the vendors servers using ColdFusion? I can't use the clients IP address, I need the vendor server address the client is using.

Upvotes: 1

Views: 1491

Answers (4)

Sergey Galashyn
Sergey Galashyn

Reputation: 6956

You have to work with 3rd party to accomplish this goal, this is for sure.

I can see at least two more or less working approaches here.

(1) Append some kind of protection token to the links. Your vendor generates encrypted string or hash including some information only you two know, so you can decrypt (or generate same hash) and validate it.

Example with hashing:

moment = DateConvert("local2utc", Now());
token = Hash("SecretSaultYouBothKnow" & DateFormat(moment, "yyyy-mm-dd") & TimeFormat(moment, "-HH-mm"));

This token is passed with link and expires quickly to prevent sharing/leaking.

You can generate and validate it on your side.

It's a raw idea and there could be possible problems with validation, plus avoiding invalid links for clients (maybe skip "mm" mask as well).

Encrypted/decrypted string would work similarly. You both just need to now the secret key.

By the way, your vendor could encrypt their server IP address or other identifier for you to check it against your database and maybe apply some other actions.

(2) Your vendor could set up simple web-service for you to validate the incoming links (it could respond with 0/1 or something else simple).

Exact implementation may be different. Again, it could be some token in URL which you send back for validation.

This is similar to solution which Jason suggested: vendor could send the server-to-server request to your server on link click and then relocate to the resource. But this may be complicated because you have to be sure 1st request is already handled when client arrives.

Hope these ideas make sense.

Upvotes: 5

steve
steve

Reputation: 1490

try placing a page on your server that uses the cfhttp tag to fetch: http://www.dslreports.com/whois

That will give you the IP address of the web server.

Upvotes: 1

Evik James
Evik James

Reputation: 10503

To access the CGI variables available to ColdFusion, you can do something like this:

<cfset ThisIP = CGI.SERVER_NAME>

There are many useful CGI variables available here:

http://www.perlfect.com/articles/cgi_env.shtml

Upvotes: 1

Jason Dean
Jason Dean

Reputation: 9615

No, there isn't. Not if the request comes directly from the client. If the vendor sends some sort of a message first you can use that to validate. Or if the vendor's server is the one making the request on behalf of the client then you could use CGI.REMOTE_ADDR. But if the vendor is just providing a link to your site, then no, you cannot be assured of the IP of the vendor's server.

The closest you could come is to check the HTTP_REFERER, as Jeremy said above, but that can be spoofed (very easily), so it wouldn't be very secure.

Upvotes: 3

Related Questions