Resolve host name to an ip address

Mahesh picture Mahesh · Jul 6, 2010 · Viewed 175.9k times · Source

I developed a client/server simulation application. I deployed client and server on two different Windows XP machines. Somehow, the client is not able to send requests to the server.

I tried below options:

  1. Pinged server machine successfully from client using ip-address.

  2. Pinged client machine successfully from server using ip-address.

  3. Checked netstat command line tool from both machines. Server is in LISTENING mode and client is in SYS_SENT mode. But the foreign address it is using to send is host name not the ip address.

  4. Pinged server machine unsuccessfully using host name from client.

  5. Pinged client machine successfully using host name from server.

I feel the problem is when the client is trying to connect to the server using the host name.

Could you please let me know how to force an application to use an ip address instead of a host name? Is there any other way to map the host name to an ip address?

Answer

paxdiablo picture paxdiablo · Jul 6, 2010

Go to your client machine and type in:

nslookup server.company.com

substituting the real host name of your server for server.company.com, of course.

That should tell you which DNS server your client is using (if any) and what it thinks the problem is with the name.

To force an application to use an IP address, generally you just configure it to use the IP address instead of a host name. If the host name is hard-coded, or the application insists on using a host name in preference to an IP address (as one of your other comments seems to indicate), then you're probably out of luck there.

However, you can change the way that most machine resolve the host names, such as with /etc/resolv.conf and /etc/hosts on UNIXy systems and a local hosts file on Windows-y systems.