Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Resolve host name to an ip address

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?

like image 471
Mahesh Avatar asked Jul 06 '10 08:07

Mahesh


People also ask

What server resolves a hostname to an IP address?

Actually, on the backed, the DNS server takes the hostname and resolves it to an IP address which the browser or application then connects to.

What does it mean to resolve a host name?

Hostname Resolution refers to the process through which an assigned hostname is converted or resolved to its mapped IP Address so that networked hosts can communicate with each other. This process can either be achieved locally on the host itself or remotely through a designated host configured to serve that purpose.


3 Answers

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.

like image 131
paxdiablo Avatar answered Oct 04 '22 04:10

paxdiablo


Try tracert to resolve the hostname. IE you have Ip address 8.8.8.8 so you would use; tracert 8.8.8.8

like image 31
IT wannabe Avatar answered Oct 04 '22 05:10

IT wannabe


You could use a C function getaddrinfo() to get the numerical address - both ipv4 and ipv6. See the example code here

like image 26
Sathya Avatar answered Oct 04 '22 05:10

Sathya