How to get the Ip Address of User using Apex in Salesforce?

String ipAddress = ApexPages.currentPage().getHeaders().get('X-Salesforce-SIP');

'True-Client-IP' - when the request is coming via the caching integration.

'X-Salesforce-SIP' - when the request is not via caching integration (sandbox, developer edition orgs) or via the secure url.

Cheers!!!

3 comments:

  1. Could you please explain more, what do you mean by caching integration.???

    ReplyDelete
    Replies
    1. caching integration - sandbox, developer edition orgs.

      Cheers!!!

      Delete
  2. How to get My system IPv4 Address using apex in salesforce?

    How to get My system Address means Control panel->Network Access-->LAN-->IP4v Address

    ReplyDelete