将主机名解析为IP地址 [英] Resolve host name to an ip address

查看:212
本文介绍了将主机名解析为IP地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发了一个客户端/服务器模拟应用程序.我在两台不同的Windows XP计算机上部署了客户端和服务器.客户端无法以某种方式将请求发送到服务器.

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.

我尝试了以下选项:

  1. 使用ip地址成功从客户端ping通服务器计算机.

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

使用ip地址从服务器成功绑定了客户端计算机.

Pinged client machine successfully from server using ip-address.

从两台计算机上检查了netstat命令行工具.服务器处于LISTENING模式,客户端处于SYS_SENT模式.但是它用来发送的外部地址不是主机名,而是主机名.

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.

使用客户端的主机名无法成功ping通服务器计算机.

Pinged server machine unsuccessfully using host name from client.

已成功使用服务器上的主机名对客户端计算机执行ping操作.

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.

能否让我知道如何强制应用程序使用IP地址而不是主机名?还有其他方法可以将主机名映射到IP地址吗?

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?

推荐答案

转到您的客户端计算机并输入:

Go to your client machine and type in:

nslookup server.company.com

当然用服务器的真实主机名代替server.company.com.

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

这应该告诉您客户端正在使用哪个DNS服务器(如果有的话),以及它认为问题出在名称上.

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

要强制应用程序使用IP地址,通常只需将其配置为使用IP地址而不是主机名即可.如果主机名是硬编码的,或者应用程序坚持优先使用主机名而不是IP地址(正如您的其他评论之一所示),那么您可能不走运.

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.

但是,您可以更改大多数计算机解析主机名的方式,例如使用UNIXy系统上的/etc/resolv.conf/etc/hosts以及

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.

这篇关于将主机名解析为IP地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆