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 192.168.1.101 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.
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:
ADDTCPHTE INTNETADR('192.168.1.101') HOSTNAME((DEVBOX))
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?