Building a Host Table

Building a Host Table
A host table provides name resolution only on the router that it was built upon. The command
to build a host table on a router is as follows:
ip host host_name tcp_port_number ip_address
The default is TCP port number 23, but you can create a session using Telnet with a
different TCP port number if you want. You can also assign up to eight IP addresses to
a hostname.
Here’s an example of configuring a host table on the Corp router with two entries to resolve
the names for the R1 router and the ap device:
Corp#config t
Enter configuration commands, one per line. End with CNTL/Z.
Corp(config)#ip host R1 ?
<0-65535> Default telnet port number
A.B.C.D Host IP address
additional Append addresses
mx Configure a MX record
ns Configure an NS record
srv Configure a SRV record
Corp(config)#ip host R1 10.2.2.2 ?
A.B.C.D Host IP address

Corp(config)#ip host R1 10.2.2.2
Corp(config)#ip host ap 10.1.1.2
Notice in the previous router configuration that I can just keep adding IP addresses to reference
a host, one after another, up to eight IP address. And to see the newly built host table,
just use the show hosts command:
Corp(config)#do show hosts
Default domain is not set
Name/address lookup uses domain service
Name servers are 255.255.255.255
Codes: UN - unknown, EX - expired, OK - OK, ?? - revalidate
temp - temporary, perm - permanent
NA - Not Applicable None - Not defined
Host Port Flags Age Type Address(es)
ap None (perm, OK) 0 IP 10.1.1.2
R1 None (perm, OK) 0 IP 10.2.2.2
Corp(config)#^Z
Corp#
You can see the two hostnames plus their associated IP addresses in the preceding router
output. The perm in the Flags column means the entry is manually configured. If it said temp,
it would be an entry that was resolved by DNS. Here is an example of a router resolving a hostname
and then telnetting to the resolved IP address:
Corp#r1
Trying R1 (10.2.2.2)... Open
User Access Verification
Password:
R1>Ctrl+Shift+6
Corp#ap
Trying ap (10.1.1.2)... Open
User Access Verification
Password:
ap>Ctrl+Shift+6
Corp#
Corp#sh sessions
Conn Host Address Byte Idle Conn Name
1 r1 10.2.2.2 0 1 r1
* 2 ap 10.1.1.2 0 0 ap
Corp#
If you want to remove a hostname from the table, just use the no ip host command, like
this:
RouterA(config)#no ip host R1
The problem with the host table method is that you would need to create a host table on
each router to be able to resolve names. And if you have a whole bunch of routers and want
to resolve names, using DNS is a much better choice!