DNS Errors

One of the most common errors associated with the use of HTTPAPI is that your System i has not been configured for DNS look ups. You see, when a computer is given a domain name (for example www.google.com), a computer needs to look up the corresponding IP address (such as 74.125.45.99).

When your computer wants to find the IP address associated with a domain name, it has two places to look: The host table, and DNS.

The host table can be configured on i by typing CFGTCP and then choosing option 10. This is a simple database file on your computer that is used to look up a name to get an IP address (or vice-versa). It's very simple -- but it has it's limits. It only works on the computer where the file resides. So to use a host table look up, you'd have to add the host name and it's IP address to every computer that needs to do the look up. Imagine if you're Google.com and you have to manually add 'www.google.com' to every computer (in the whole world) that uses it. Imagine if you had to change the IP address in all of those computers! It just wouldn't work.

DNS is much more managable. DNS is a world-wide, distributed database. When you configure your computer to performn DNS look ups, it will go out over the network and query computers all over the world, as needed, to find the IP address for a domain name (or vice-versa).

There are two parts to DNS. The DNS "resolver" and the DNS "server". The resolver is a part of any operating system that supports TCP/IP. The resolver knows how to accept a domain name, use it to format a request, and send it to a DNS server. It then waits for a response and when it gets the IP address as a response, it returns it to a computer program.

The DNS server does all of the work of contacting other DNS servers to determine the response. For example, if you're looking up "www.google.com", it first asks a "root" DNS server for information about "com". The root server tells it the IP address of another DNS server -- the one that knows about "com". It then asks the "com" server for information about "google", and then asks the "google" server for information about "www", which will finally result in an IP address.

The good news is: You don't need to run a DNS server to use HTTPAPI.

However, if you want HTTPAPI to be able to connect to URLs that contain domain names (such as www.google.com, or the www.scottklement.com sites featured in the EXAMPLExx programs) then your system must have it's DNS resolver configured.

Configuring the DNS resolver is fairly easy. You need to know three pieces of information:

  1. Your computer's name within the TCP/IP domain.
  2. The name of the TCP/IP domain.
  3. The IP address of at least one DNS server that you're allowed to use.

So you do need access to a DNS server -- but you don't have to run it yourself. Most companies do have their own internal DNS servers -- if you're one of those companies, ask your network administrator for the IP address of your DNS server.

Even if your company doesn't have it's own DNS server, every Internet Service Provider provides DNS servers for it's customers to use. This is pretty standard. You'll have to ask them what the DNS server is.

You can even run your own DNS server on your System i if you like -- but it's certainly not required. i5/OS is more than capable of using a seperate DNS server that's running on another computer on the network, and it doesn't matter what operating system that computer is running.

So for example, let's say you have access to two DNS servers with IP address 192.168.0.1 and 192.168.0.2. Also, your computer is named systemi.example.com

To set up the DNS resolver, you have to type the following command:

        CHGTCPDMN HOSTNAME('systemi')
                  DMNNAME('example.com')
                  HOSTSCHPTY(*LOCAL)
                  INTNETADR('192.168.0.1' '192.168.0.2')

This tells the DNS resolver to use IP address 192.168.0.1 as it's DNS server. When it wants to look up a host like www.google.com, it'll send the request to 192.168.0.1, and that will attempt the look up. If 192.168.0.1 doesn't respond, it'll try 192.168.0.2.

A few notes about the preceding CHGTCPDMN command:

  • The HOSTNAME and DMNNAME parameter specify your computer's name on the network. When it wants to know what it's own name is, it'll look at these parameters. When it wants to know it's own IP canonical IP address, it'll look up the IP address of this host and domain name.

  • HOSTSCHPTY determines whether the resolver looks at the host table first, or DNS first. *LOCAL means that it checks the host table first, and only it's not in the host table does it try DNS. *REMOTE is the opposite. I recommend *LOCAL

  • INTNETADR is the important one. It tells the resolver which DNS server (sometimes called "name server") should be used for DNS lookups. This is where you put the IP address you get from your network admin or ISP. Although I listed two IP addresses, only one is required. The second one is a "fall back" when the first one isn't responding.

Once you've set up the DNS resolver with the CHGTCPDMN command, you should be able to perform host lookups. To test this type:

PING RMTSYS('www.google.com')

The system should be able to convert www.google.com into an IP address, and it'll print that address on the screen. If it's able to determine the IP address (regardless of whether the echo requests work) you'll know that the DNS resolver is working.