My org has some callouts to another server. but the server requires to add IP address to whitelist. So I need to know how many IP addresses does each org have and how can I get it through coding or something else.
Salesforce's IP ranges can be found on this page - https://help.salesforce.com/articleView?id=000003652&type=1. Your particular org can possibly attempt external connections from any IP address in that range, although as the answer linked in comments notes, you can use nslookup to find the IP range of your particular pod, at the risk of that range being subject to change without notice.