Skip to main content

How to flush the DNS query cache

·380 words·2 mins
Table of Contents

Like all other platforms, IBM i uses DNS (domain name system) to translate a hostname to an ip address before connecting to that host. After getting the ip address from the DNS server, IBM i stores the result in a cache and uses the cache for any future lookups for that hostname.

Resolving
#

The translation from hostname to ip address is called “resolving”, and having a cache for previously resolved hostnames is great for speeding up connections to hosts - IBM i does not need to ask the DNS server before connecting, it can simply use the ip address from the cache.

However, the cache content can become outdated and invalid, if the DNS server is updated with a new ip address for that host. IBM i does not know that the DNS server now gives another reply, because it is never asked! So how do we tell IBM i to clear or “flushing” the DNS query cache?

Flushing the cache
#

The obvious answer is to IPL the system…

But this is an IBM i and rebooting the system is not necessary in most situations. So what else can we do?

Well, the trick and not so obvious answer is to run the command CHGTCPDMN without any parameters!

This will clear the cache for the DNS resolver, and IBM i will now ask the DNS again for the information previously in the cache. The cache will be populated once more and store the new replies from the DNS server.

This trick can be used in situations where you might get messages like TCP3202 (“Unknown host”) and you are certain the DNS contains the hostname. The DNS information can be verified by using the nslookup command, e.g. nslookup 'www.google.com'.

In this situation you run CHGTCPDMN and flush the DNS cache to make IBM i call the DNS server once more.

The trick is documented in this IBM Support page.

You register one or more DNS servers in the TCP/IP configuration using the CHGTCPDMN command (or go through menu CFGTCP and choose option 12. Change TCP/IP domain information).

For more information, read about the domain name system on IBM i here

I hope you find this post useful. Feel free to reach out to me, if you have any questions.

Reply by Email
Christian Jorgensen
Author
Christian Jorgensen