IP address used by nslookup and ping is different

h82 asked:

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

My answer:

This problem is caused by your using RFC1918 private addresses inside your internal network. As a result, you have to access the server using one address while on one side of the network and a different address on the other.

The short-term solution to this is to implement split-horizon DNS. This provides you consistent DNS entries within the network and without.

The long-term solution to this is to implement IPv6, in which you will have the same address for the server regardless of whether you’re internal or external.

View the full question and answer on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.