Using Static Hostname Tables


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


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
Router1(config)#ip host router2


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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.