Get Your Salesforce Org Current IP Address Using Apex
In Salesforce IP whitelisting is one of the most effective methods of ensuring secure connections to external systems. Salesforce provides a range of IP addresses that can be whitelisted by external systems based on your Salesforce instance.
Note: Add https://api.ipify.org in your Org remote site settings before executing below code.
Sample Code:
HttpRequest request = new HttpRequest(); request.setEndpoint('https://api.ipify.org'); request.setMethod('GET'); Http http = new Http(); HttpResponse response = http.send(req); String responseBody = response.getBody(); System.debug('Your Org current IP Address: ' + responseBody);