I was given an API for a service through which I tried to send a post message from server A, but the connection cannot be built. Then I ping the domain name in the API. It doesn't work, so I thought it would be that the domain name had not been publicly mapped to the website.
To find the IP of the website, I pinged that in intranet from my client B, and then I used the IP shown in the message to replace the domain name and retried the post in server A. It didn't work. Then I mapped the IP to the domain name in /etc/hosts
as a host entry in server A and used the domain name as the post uri, and it worked.
I wonder why it didn't work when I replaced the domain name with the IP address in the API? Does it only work by adding a host entry?
I am new to serverfault, then if this question is duplicated(I think it would be highly possible) please let me know. Thanks.