VB.NET - DNS lookup caching in .net framework 1.1

Asked By Brian Jones on 08-Sep-09 11:23 AM

I am a developer working on a Windows client built in .NET 1.1, and am currently troubleshooting a problem with how a web service proxy within the client is resolving the service's internet address and connecting to the service.

The proxy is generated via WSDL, and then modified to get the URL at run time from the app.config.  This address does not change over the lifetime of the application.  What can change, however, is the actual IP address to which the address resolves.  This does not happen often, but can happen in the event of a disaster, in which case a backup data center configured with a different IP address, will take over.  Our DNS service (TZO.com) allows us to flip over the IP address in a short time (as low as 30 seconds).

The problem we are troubleshooting is that if we change the IP address while the client application is up and running, it does not appear to realize that the active IP address has changed and continues to create TCP connections to the old IP address when attempting to connect to the web service.

I am looking for some insight into how a DNS lookup is cached by the .NET framework and if it truly observes the indicated TTL on the DNS entry.  It would be nice to have a method by which I could flush the DNS cache manually if necessary, but I have not been able to find any documentation  on this.  Lacking that, are there any recommendations on how to force new connections to go to a new IP address?

Thanks in advance.

DNS problem in .net framework 1.1 - George Elam replied to Brian Jones on 09-Sep-09 10:12 PM


The application using the web service is at the top level (7) of the OSI model. Unless you program it to do so, it has no awareness of the IP address it has.

The DNS is down in the (i think) Network layer (3).

If the IP address of the Web service changes, the application must have a way of seeing that error and responding, like getting a new IP address.

Refer to the System.Net namespace, and specifically the DNS Class. In framework 1.1, there is the BeginResolve method, which will return an IP Address from a DNS host name.


I hope that helps. Good Luck, George

DNS flush - George Elam replied to Brian Jones on 09-Sep-09 10:19 PM


Check with your server admin guys, but I think that flushing the DNS can only be done on the DNS server, not in the client machine/application.

In the failover scenario, the DNS server might be scripted to refresh it's lookup for the Web host, then your app can get the new resolution, per the prior posting.


Flushing DNS - Chris Green replied to George Elam on 11-Dec-09 09:45 AM

Hi Brian,

Not sure if this is too late but you can flush the host's dns cache using 'ipconfig /flushdns' from the command line. It should be quite straight forward to add that into either code or a script. I'm not 'built in' method that does this within VB (let me know if you find one!).

You can show the current DNS using the simple command 'ipconfig /displaydns'.

Hope this helps!