Using Static Hostname Tables

Problem

You want to create a static host lookup table on the router.

Solution

The ip host command lets you configure static host entries in the router:

Router1#configure terminal 
Enter configuration commands, one per line.  End with CNTL/Z.
Router1(config)#ip host freebsd 172.25.1.1
Router1(config)#ip host router2 10.1.1.1 172.22.1.4
Router1(config)#end
Router1#

Discussion

Many router commands will accept a hostname in place of an IP address. This helps make the configuration files more readable because it is much easier for humans to work with device names than IP addresses. However, the router still needs to have a way of translating these names into the IP addresses that it prefers to work with. Cisco supports two methods for resolving hostnames into IP addresses. You can either use static host entries, as we do in this recipe, or DNS, as we do in the next recipe.

Static host entries are strictly local to the router. The router does not share this information with other routers or other devices. And unlike DNS, static host entries are not dependent on any external services such as nameservers. If you have both DNS and static host definitions, the router will prefer the static entries. This allows you to override the normal DNS if you don’t want to use it.

The biggest problem with static entries is, quite simply, that they are static. So they don’t respond to IP address changes without manual intervention. The biggest advantage to static entries is that being ...

Get Cisco IOS Cookbook, 2nd Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.