Freigeben über


Client IP Address

Can I get the IP address of a client connecting to my service?

No. Sorry. In most cases this information is not available. Exposing such functionality is left to the transport to be done in an implementation-specific manner. The most popular transports we supply out of the box do not offer this. You can ask the client to supply that information as part of its identity, although you need a way of making sure that the client isn't lying before taking action based on the IP address. However, it is possible under some circumstances for the client to lie about its address even when you can directly query the socket.

Comments

  • Anonymous
    May 16, 2007
    Yes, but it'd be so nice if MS would let us know how we could get it for, say, TCP and HTTP bindings. For example, almost the entire world of VoIP communication relies only on IP authentication. Regardless if it's not secure, it's a business requirement and we're stuck with a problem when we can't track IPs. For now, we have to run those services in IIS and turn on the ASP.NET compatible mode to access HttpContext, but of course that only helps where we're using HTTP and IIS...

  • Anonymous
    May 16, 2007
    The comment has been removed

  • Anonymous
    May 16, 2007
    Even with NAT, at least you have the NAT'd IP, and most companies are operating under the premise that their own LAN is correctly secured and routed. That said, billions of dollars flow based purely on IP authentication (over UDP none-the-less). Having the client send their IP is pointless :.

  • Anonymous
    May 16, 2007
    It should be noted that transports that DO know about this information will deposit Information level traces into any tracing that you are doing with respect to the connection.

  • Anonymous
    May 16, 2007
    Right the transports must know, so how can we get it (via reflection or something)?

  • Anonymous
    May 16, 2007
    You can of course pull the data out through a few uses of reflection.  It it worthwhile to do so?  Your program will be very brittle and likely to break with the slightest of changes as it's intimately depending on internal implementation details.

  • Anonymous
    May 17, 2007
    I am very disappointed with WCF. This is basic stuff. We should be able to easily have this IP address info.

  • Anonymous
    May 22, 2007
    Nicholas, Can you explain WHY the ip address is not made available in the transport? I have never heard of a server logging mechanism that didn't include the ip address as a basic piece of information. Even if it cannot be completely relied upon, its better to have the information than not have it.

  • Anonymous
    May 29, 2007
    I'd be more than happy to pull it out via reflection -- where should I look? It'll break with the next framework: I can handle that.