function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
svdsvd 

how to get system IP address using APEX

Hi ,

 

Can anyone tell me how to get system IP address (logged in system ip) using apex. are there any DNS related classes (like java)

or any other approaches. ?

 

thanks for your time and help,

SVD 

paul-lmipaul-lmi
are you trying to get an external ip, or an internal one?  for external, you can probably just use the wimi.com web service via an HTTP callout to get it, however, it may not be the server you're running code from if they proxy HTTP callouts.  for internal, that's probably not going to happen, due to the obvious security concerns they'd have about people using Apex to map their architecture.
melchisholm22melchisholm22
Is there any other way to get the local ip address of the user logged in salesforce? I used a java applet to do it but it doesn't seem to be accurate and it loads very slow.

Thanks!
Pat McQueenPat McQueen

Check out this posting:

 

http://community.salesforce.com/sforce/board/message?board.id=Visualforce&message.id=15162&query.id=258865

 

 

ApexPages.currentPage().getHeaders() will let you see:

 

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

X-Salesforce-SIP has the value if there is no caching integration (sandbox, developer edition orgs) or via the secure url 

fgwarb82fgwarb82
Thanks for posting the relevant text!  The link is dead now
vigneshwar kothavigneshwar kotha
Hi,

<apex:page id="page" controller="ip"> 
         
      {!ipstring}

</apex:page>
 
Controller 


public class ip {

    public String ipstring { get; set; }

    public String getIpstring() {
        return null;
    }
    public ip(){
    ipstring= ApexPages.currentPage().getHeaders().get('X-Salesforce-SIP');
    }



}