Midrange News for the IBM i Community

Posted by: Bob Cozzi
Rogue Programmer
Cozzi Productions, Inc.
Add Entry to IBM i (AS/400 iSeries) HOSTS File
has no ratings.
Published: 12 Sep 2011
Revised: 28 Apr 2016 - 2947 days ago
Last viewed on: 22 May 2024 (36072 views) 

Using IBM i? Need to create Excel, CSV, HTML, JSON, PDF, SPOOL reports? Learn more about the fastest and least expensive tool for the job: SQL iQuery.

Add TCP/IP Host Table Entry (ADDTCPHTE) Published by: Bob Cozzi on 12 Sep 2011 view comments(2)

Adding an Entry to the IBM i (iSeries, AS/400) Hosts File

If you use commands that use TCP/IP, such as FTP or TELNET and are constantly typing in the IP address of remote systems, there's an easier way.

For example, today, if you wanted to FTP a file to a backup system that has an IP address of you would do something like:


If you're like me and remember numbers very well, such as phone numbers, addresses, social security numbers, vault codes, etc., this isn't an issue. But if you're like most people, this can mean stopping, looking for the IP address, then typing it in--somewhat bothersome.

Wouldn't it be great to be able to simply enter an alias, such as we do today in our Web Browsers, rather than that long IP address? Some like the following:


All systems that use TCP/IP (are there any that do not?) support what's known as the HOSTS file (table). Your PC and Mac have it, so does your Linus box, and guess what? So does the IBM i platform. Here's a link to a Wikipedia article on the HOSTS file topic. This is normally just a plain ASCII text file that contains one entry per line. Each entry is the IP address of your choice, followed by an alias name. When a TCP/IP application, such as FTP, TELNET or a web browser specify this alias name, the system looks up that name in the HOSTS file and if it finds it, redirects the application to the corresponding IP address.  Sort of like having a micro-DNS on your system.

To display the current IBM i HOSTS file entries, use the CFGTCP command and select option 10 (Work with host table entries). You'll see the typically IBM-designed subfile panel with any and all of your HOSTS file entries.

The IBM i interfaces refers to this file as the "HOST TABLE" instead of the more common "HOSTS FILE" but they are effectively the same thing.

The HOST table is named QATOCHOST and is located in the QUSRSYS library.

Adding Entries to the HOSTS FILE (HOST TABLE) on IBM i

To find the right CL command to add an entry to the HOSTS FILE, first run the following:


From the list of TCP commands, select the "Add TCP/IP Host Table Entry" command (ADDTCPHTE) which is Option 4 on my system. You can also directly type in ADDTCPHTE and press F4/prompt instead.

                     Add TCP/IP Host Table Entry (ADDTCPHTE)                    
 Type choices, press Enter.                                                     
 Internet address . . . . . . . . INTNETADR  ____________________
 Host names:                      HOSTNAME  _                                   
   Name . . . . . . . . . . . . .            ________________________________                                             
                           + for more values _
 Text 'description' . . . . . . . TEXT  _____________________________________

To add an entry, simply fill out the first two parameters. The IP address goes in the first parameter, and then some short name goes into the second. Specify option text description for the entry being added and press Enter. Here's what the completed command would look like:


You will need *IOSYSCFG authority in order to add an entry to this file.

Once added, you can now issue a much more friendly and easier to remember FTP, TELNET or other command and specify the HOSTNAME instead of the more difficult to remember IP address:


In my shop, since we have about 9 AS/400 systems, we create short 4-character IDs for each box and add each of them to each system's HOST file. That way no matter where we are on the network, we can easily access the other systems without worrying about the IP address. The other benefit is that should the IP address change for any system, you can modify the HOST file and leave your applications alone. For example, if you regularly FTP files to a remote system, add a HOST file entry and use the alias in the CL program running the FTP command. That way if that remote system's IP changes, you simply go into the HOST file, update the IP address, and the program that uses that alias, doesn't need to be touched!

Pretty cool, huh?

Return to midrangenews.com home page.
Sort Ascend | Descend


(Sign in to Post a Comment)
Posted by: Viking
Premium member *
Comment on: Add Entry to IBM i (AS/400 iSeries) HOSTS File
Posted: 8 years 1 months 1 days 6 hours 10 minutes ago

Note:  If you are trying to add a host name to the host table using the ADDTCPHTE command and you already have previously existing host entries for that TCPIP address, use CHGTCPHTE command to add additional host names to the existing entry.

Posted by: clbirk
Premium member *
Comment on: Add Entry to IBM i (AS/400 iSeries) HOSTS File
Posted: 8 years 24 days 12 hours 33 minutes ago

far easier to use the graphical inav which you get under network tcp/ip configurations. It is available both in the windows based and the navigator for i (port 2001) version.


In addition to "internal devices", lets say you have to communicate with a new website that the public dns has not yet rolled to it, that is say you need to do a webservice with  www.xyz.com and currently that is at but the one you need to test is at you can set up an entry in the hosts file that www.xyz.com points to and that is where the i will go look for it.