Resolve host name to an ip address

后端 未结 5 722
醉话见心
醉话见心 2021-02-01 02:33

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 se

相关标签:
5条回答
  • 2021-02-01 02:55

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

    0 讨论(0)
  • 2021-02-01 02:59

    This is hard to answer without more detail about the network architecture. Some things to investigate are:

    • Is it possible that client and/or server is behind a NAT device, a firewall, or similar?
    • Is any of the IP addresses involved a "local" address, like 192.168.x.y or 10.x.y.z?
    • What are the host names, are they "real" DNS:able names or something more local and/or Windows-specific?
    • How does the client look up the server? There must be a place in code or config data that holds the host name, simply try using the IP there instead if you want to avoid the lookup.
    0 讨论(0)
  • 2021-02-01 03:14

    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.

    0 讨论(0)
  • 2021-02-01 03:15

    Windows XP has the Windows Firewall which can interfere with network traffic if not configured properly. You can turn off the Windows Firewall, if you have administrator privileges, by accessing the Windows Firewall applet through the Control Panel. If your application works with the Windows Firewall turned off then the problem is probably due to the settings of the firewall.

    We have an application which runs on multiple PCs communicating using UDP/IP and we have been doing experiments so that the application can run on a PC with a user who does not have administrator privileges. In order for our application to communicate between multiple PCs we have had to use an administrator account to modify the Windows Firewall settings.

    In our application, one PC is designated as the server and the others are clients in a server/client group and there may be several groups on the same subnet.

    The first change was to use the functionality of the Exceptions tab of the Windows Firewall applet to create an exception for the port that we use for communication.

    We are using host name lookup so that the clients can locate their assigned server by using the computer name which is composed of a mnemonic prefix with a dash followed by an assigned terminal number (for instance SERVER100-1). This allows several servers with their assigned clients to coexist on the same subnet. The client uses its prefix to generate the computer name for the assigned server and to then use host name lookup to discover the IP address of the assigned server.

    What we found is that the host name lookup using the computer name (assigned through the Computer Name tab of the System Properties dialog) would not work unless the server PC's Windows Firewall had the File and Printer Sharing Service port enabled.

    So we had to make two changes: (1) setup an exception for the port we used for communication and (2) enable File and Printer Service in the Exceptions tab to allow for the host name lookup.

    ** EDIT **

    You may also find this Microsoft Knowledge Base article on helpful on Windows XP networking.

    And see this article on NETBIOS name resolution in Windows.

    0 讨论(0)
  • 2021-02-01 03:17

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

    0 讨论(0)
提交回复
热议问题