To make chkdnsrr() work, please follow these steps:

Step 1) Verify that your IBM i can resolve external addresses. From the 5250 command line:


Review the messages that appear by displaying the job log:


Page back to see the messages under the ping command. The messages should be similar to this:

Verifying connection to host system ZEND.COM at address
PING reply 1 from took 69 ms. 256 bytes. TTL 241.
PING reply 2 from took 56 ms. 256 bytes. TTL 241.
PING reply 3 from took 56 ms. 256 bytes. TTL 241.
PING reply 4 from took 56 ms. 256 bytes. TTL 241.
PING reply 5 from took 56 ms. 256 bytes. TTL 241.
Round-trip (in milliseconds) min/avg/max = 56/58/69.
Connection verification statistics: 5 of 5 successful (100 %).

These messages indicate a successful ping. If you see messages similar to these, proceed to the next step.

However, if you see something like this:

Unknown host, ZEND.COM.

Then your IBM i is not configured to resolve external addresses. You will need to configure tcp/ip before continuing. Your Network Administrator should be able to complete this task for you.

Step 2) Find your DNS Server addresses. From the command line, as QSECOFR or a *SECOFR class user, use F4 to prompt this command:


The 'Change TCP/IP Domain (CHGTCPDMN)' menu will appear. Find the 'Domain name server:' parameter by paging down. You should find one or more Internet addresses, similar to this:

Domain name server:
Internet address . . . . . . . ''
Internet address . . . . . . . ''
Internet address . . . . . . . *SAME

Copy down these Internet addresses exactly. Ignore any entries that say '*SAME'. These addresses are used in the next step.

Step 3) Still logged in as QSECOFR or a *SECOFR class user, use this command to enter the PASE shell:

call qp2term

In the PASE shell, enter this command:

cat /etc/resolv.conf 

If the output looks like this:

cat: 0652-050 Cannot open /etc/resolv.conf. 

This is fine. The file is not created yet, and you can create it now. If the output shows some file contents, skip ahead to the next section to see if the file is correct. If it is not correct, you can remove it using this command:

rm /etc/resolv.conf

To create the file, enter a command for each Internet address found under the Domain name server parameter. In our example, we found two addresses:

echo 'nameserver' >> /etc/resolv.conf 
echo 'nameserver' >> /etc/resolv.conf

Use the cat command again to verify the file is entered correctly:

cat /etc/resolv.conf 

In this example, the nameserver entries exactly match the Internet address entries found in the CHGTCPDMN command. This is what we want.

Step 4) Verify that the chkdnsrr() function is working. Create this script and run it on your Zend Server instance:

echo '<pre>';
$host = '';
echo 'Test for host $host <br><br>';
$ip = gethostbyname($host);
echo 'The ip for $host is $ip <br><br>';
// Note: If the host is not found, $ip will be set to $host
if ($ip == $host) {
echo '$host was not found<br><br>';
} else {
echo '$host was found OK<br><br>';
$tests = array('A', 'MX', 'NS', 'SOA', 'PTR', 'CNAME', 'AAAA', 'A6', 'SRV', 'NAPTR', 'TXT', 'ANY');
foreach ($tests as $type) {
echo ' Type = $type : ';
var_dump(checkdnsrr($host, $type));

This is the expected output:

Test for host

The ip for is was found OK

Type = A : bool(true)
Type = MX : bool(true)
Type = NS : bool(true)
Type = SOA : bool(true)
Type = PTR : bool(false)
Type = CNAME : bool(false)
Type = AAAA : bool(false)
Type = A6 : bool(false)
Type = SRV : bool(false)
Type = NAPTR : bool(false)
Type = TXT : bool(true)
Type = ANY : bool(true)

Note that several of the entries are true. This is good. If the entries are all false, then chkdnsrr() is not functioning correctly.