views:

258

answers:

8

I am making an EventLog which will log the transaction log in my website. The details of the log will include the Public IP from where the transaction has orginated and also the local IP address (under the public IP).

I have found ways to obtain the Public IP Address, but i am unable to find out the local IP or machine IP from where the transaction is made.

A large number of entries will be done by people using the same connection. ie 5 or 10 computers connected to the same connection.

I need to find the machine IP (192.168.0.1 for 1 system 192.168.0.2 for the next) of the machines making the transactions and also the Computer name...

Is this possible

+4  A: 

To clarify, you want the private IP address of a client when the client is connecting through a router? Then no, there isn't a way to do this.

Are you doing this purely to distinguish between different users?

Can you use another method like cookies?

Nader Shirazie
+1  A: 

If your client connects from behind a NAT or firewall you cannot reliably get his address or computer name. If you need such information then your protocol should request them as part of the request and the client machine should voluntarily provide them. There is no way to validate the information provided (short of deploying a trusted cryptographic infrastructure, ie. you establish a strong trust in the client machines themselves).

Remus Rusanu
+1  A: 

Sadly, the answer is no. No modern browser will present that private address in the HTTP transaction. The client's router which performs the NAT (Network Address Translation) offers only the public client IP address when making the IP connection.

the.jxc
A: 

Not likely. See a short discussion in http://javascript.about.com/library/blip.htm

A: 

try this code.....

public String GetIP()
{
    String ip = HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];

    if (ip == string.Empty || ip == null)
    {
        ip = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
    }

    return ip;
}
Muhammad Akhtar
A: 

Well yes we are doing this just to differentiate between the computers to know who is doing the entries...

Since you guys say that tracing the IP is not very reliable are there any other methods that i can use to do the same thing

I just need to know from which computer each entry is entered.

Any suggestions would be welcome

You should have edited your original question to add this. This is not a discussion forum, and this is not a reply. It's meant to be an answer, but it doesn't answer your question.
John Saunders
A: 

You are making the false assumption that there is a way to know from which computer each entry is entered. Nobody has the job of ensuring that this information exists. Often, it will not exist.

The only way to make sure each computer is uniquely identified is for you to identify it. You can do this through client certificates, for instance. In general, if you want each computer to have a unique identifier, then you need to create a unique identifier, then put it on that computer. You then need the computer to send that identifier back.

There is no other unique identifier for computers.

John Saunders
A: 

This is probably way beyond what you're looking for but it makes for an interesting read: Remote physical device fingerprinting

This allows you to uniquely identify a remote physical device without its cooperation, across NAT or whatever else you can imagine.

Gili