VMware ESXi and vSphere Cluster Management
Configure Static Hostname-to-IP Address Mappings on Cisco IOS
Learn how to configure, view, test, correct, and save local static hostname-to-IPv4 mappings on Cisco IOS when DNS is unavailable.
Static host mappings let a Cisco IOS device translate a human-readable hostname into an IPv4 address without contacting a DNS server. This is useful in small labs, isolated networks, and temporary environments.
What hostname resolution does
A hostname is a human-readable name used to identify a network device or service. An IPv4 address is the numeric address used to deliver traffic to an endpoint. Name resolution is the process of converting the hostname into an IP address.
For example, remembering HQ_SERVER is easier than remembering 192.168.5.27. When you enter ping HQ_SERVER, Cisco IOS first looks up the name, obtains the IPv4 address, and then sends the reachability test to that address.
Do not confuse the device's own hostname with a static host entry. The hostname command names the Cisco router or switch itself. The ip host command creates a separate name-to-address entry that the device can use when resolving names for management or testing traffic.
When local static mappings are appropriate
- Small labs: A few devices can be named manually without deploying DNS.
- Isolated networks: A management network may have no access to a DNS server.
- Temporary environments: A test topology can use short-lived mappings while it is being built.
- Limited exceptions: A static entry can provide a convenient name for a particularly important management destination.
Static mappings are manually maintained. They do not automatically change when an address changes. Every Cisco IOS device that needs to resolve a name must have its own correct entry.
For larger or frequently changing networks, DNS is normally preferred. The Domain Name System provides centralized, distributed hostname resolution, so administrators do not have to edit the same address on every network device.
Configure a static host entry
Use global configuration mode to create the mapping. The basic command is:
enable
configure terminal
ip host HQ_SERVER 192.168.5.27
The command components are:
ip hostidentifies the Cisco IOS static host-entry command.HQ_SERVERis the hostname label that you will use in commands.192.168.5.27is the IPv4 address associated with that label.
The hostname is locally significant to the device. Use a clear, consistent label, and enter it exactly as intended. Cisco IOS name matching and display behavior can vary by command and release, so consistent spelling and capitalization avoid confusion.
Using more than one name
If several labels should refer to the same address, configure an entry for each label when supported by the IOS syntax and platform. For example:
ip host HQ_SERVER 192.168.5.27
ip host FILE_SERVER 192.168.5.27
These are separate local labels that happen to point to the same address. Check the command help on the device with ip host ? if you need to confirm whether your IOS version supports additional addresses or alias-related syntax.
View configured host entries
Leave configuration mode if necessary, then run:
show hosts
This command displays hostname-resolution information, including locally configured host entries and any resolver information IOS reports. Look for the expected hostname and the associated IPv4 address.
Router# show hosts
Host Port Flags Age Type Address(es)
HQ_SERVER None ( perm, OK ) IP 192.168.5.27
The exact columns and formatting can vary by IOS release. A permanent local entry is different from a name learned or resolved through another mechanism. The output and flags help identify the source and status of an entry; do not assume that every displayed name was created with ip host.
Test resolution and reachability
Test the configured name from the same Cisco IOS device:
ping HQ_SERVER
IOS should resolve HQ_SERVER to 192.168.5.27 before sending the ICMP echo requests. Successful ping replies provide evidence for two separate conditions:
- Name resolution succeeded: IOS converted the hostname into an IP address.
- IP reachability succeeded: The destination replied to the ICMP test.
A name can resolve correctly while the ping fails. In that case, investigate the mapped address, routing, interfaces, firewalls, and whether the remote host permits ICMP. You can also test the numeric address directly:
ping 192.168.5.27
Other commands can use a resolvable hostname when appropriate, including ssh, telnet, and traceroute. These commands can demonstrate name use for management or path testing, but they do not replace checking whether the address is correct.
Static Cisco IOS Host Mapping Commands
| Task | IOS command | Expected result |
|---|---|---|
| Add a hostname-to-address entry | ip host HQ_SERVER 192.168.5.27 | Creates a local static mapping in global configuration mode. |
| View configured host entries | show hosts | Displays hostname-resolution information and configured entries. |
| Test resolution and reachability | ping HQ_SERVER | IOS resolves the name and sends an ICMP test to the resulting address. |
| Remove a host entry | no ip host HQ_SERVER 192.168.5.27 | Deletes the specified local static entry. |
| Save the running configuration | copy running-config startup-config | Preserves the mapping across a reload. |
Save the configuration
The new entry initially exists in the running configuration. To retain it after a reload, save the running configuration:
copy running-config startup-config
Confirm the prompts as appropriate for your device. If the device reloads before the mapping is saved, the entry may disappear.
Correct or remove a mapping
Suppose the server moved from 192.168.5.27 to 192.168.5.40. Remove the old entry and create the replacement:
configure terminal
no ip host HQ_SERVER 192.168.5.27
ip host HQ_SERVER 192.168.5.40
end
show hosts
ping HQ_SERVER
copy running-config startup-config
The no form removes an unwanted or outdated entry. Verify the result with show hosts, then test the revised name. Recreating the entry is often the clearest way to correct an address or hostname.
Compare local mappings with DNS
| Characteristic | Local static mapping | DNS |
|---|---|---|
| Configuration location | On each Cisco IOS device that needs the name. | On DNS servers and their administrative systems. |
| Administrative effort | Manual entry, review, and correction. | Centralized administration with client resolver configuration. |
| Scalability | Practical for a small number of stable names. | Designed for larger and changing environments. |
| Update propagation | Must be copied manually to every affected device. | Clients query the authoritative or configured DNS service. |
| Best-fit environment | Labs, isolated networks, temporary setups, and limited exceptions. | Production networks with many devices, services, or changing addresses. |
For example, configuring HQ_SERVER on one router does not make the name available on another router. If a second device must resolve it, configure the same mapping there:
SecondRouter# configure terminal
SecondRouter(config)# ip host HQ_SERVER 192.168.5.27
As the number of devices and entries grows, manually keeping mappings consistent becomes error-prone. That operational limitation is a strong reason to use DNS in larger production networks.
Troubleshooting static hostname resolution
The hostname is not recognized with ping
- Run
show hostson the device initiating the test. - Check that the
ip hostentry exists and that the hostname is spelled correctly. - Confirm that the entry was configured on this device rather than on a different router or switch.
- Add or correct the local entry, then repeat
ping HQ_SERVER.
The hostname resolves, but ping receives no replies
- Confirm the address displayed by
show hosts. - Ping the numeric address directly to separate name resolution from reachability.
- Check interface status and routing to the destination network.
- Consider whether the remote host is down, filtering ICMP, or configured not to answer.
The mapping disappears after a reload
- Check whether the entry exists in the running configuration.
- Save the active configuration with
copy running-config startup-configbefore reloading.
Devices resolve the same name differently
- Run
show hostson every affected device. - Look for missing entries, spelling differences, or outdated addresses.
- Standardize the static mappings, or migrate the environment to DNS when centralized management is more appropriate.
Exam-relevant points
ip hostcreates a local static hostname-to-IP mapping in global configuration mode.show hostsverifies hostname-resolution information.ping hostnametests both name resolution and, if replies are received, IP reachability.- A successful name lookup does not guarantee that the destination is reachable.
- The mapping is not automatically shared with other Cisco IOS devices.
- Use the
noform to remove an entry and save the configuration if it must survive a reload.
For related study, see hostname-to-IP address mapping on Cisco IOS.