IP address used by nslookup and ping is different

domain-name-systeminternal-dnsnslookuppingtcpip

I have a web server hosted in the network. It has a domain name registered. However, I also host a DNS server for the LAN. So, when someone wants to access the web server, it would check the DNS server and use the internal address 192.168.x.x. The web server's public address is 203.x.x.x.

When my computer is working fine, I would ping or try nslookup www.mydomain.com. Both points to 192.168.x.x which is internal address. Sometimes, I or someone could not access www.mydomain.com. When I check, nslookup returns the internal address. But when I ping, it would try to connect using the public address like this.

Pinging www.mydomain.com [203.x.x.x] with 32 bytes of data:

If that happens, repairing the connection mostly help. Sometimes, the workstation (Win XP) has to be restarted. In DNS settings of the workstations, primary DNS points to the DNS Sserver and secondary DNS points to ISP DNS server.

What I want to know is the cause of this problem and prevention from it?
Or a better fix than my current ones. Thanks

Best Answer

You've configured the client to lookup against your internal DNS for its primary, and an external DNS server as a secondary? You have a race condition; if the internal DNS happens to be too slow to respond, then the client gets an unusable response from the public DNS server. ping is using the cached response from the lookup against the external DNS server, while nslookup sends a fresh request that gets a valid response from your internal DNS server.

Having inconsistent views of DNS between your primary and secondary servers is bound to cause problems like this. Instead, either stand up a second internal DNS server and use it as secondary, or configure the client with no secondary DNS server at all.