Router Hostname and DNS Settings

During the initial System Configuration Dialog, we gave our router a hostname of toronto-1. This can be changed using the hostname command. For example, to change the hostname of this router to cisco2501, enter the following from global configuration mode:

toronto-1(config)#hostname cisco2501

Notice that the command prompt name immediately changes to cisco2501. The hostname associated with the router is there to give you perspective on which router you are connected to. Unless you have an entry set up on a DNS server that maps this name to one of the router’s IP addresses (or appropriate host file entries), you still won’t be able to telnet into the router using its hostname.

By default, a Cisco router will always assume that any unrecognized command is the name of a host that you wish to initiate a telnet session with. Because of this, it will attempt to resolve the name to an IP address using DNS. For example, consider what happens when I enter “helpme” at the prompt and press enter.

Translating "helpme"...domain server (
% Unknown command or computer name, or unable to find computer address

If you want to avoid this frustrating and somewhat annoying action, you can always configure the router to not perform a DNS lookup on unrecognized commands using the no ip domain-lookup command.

cisco2501(config)#no ip domain-lookup
Translating "helpme"
% Unknown command or computer name, or unable to find computer address

You will probably get to a point where you’ll want to configure a router to resolve names, since these are generally easier to remember (and to input) than IP addresses. If you decide to do this, you have two choices – you can either configure your router to use DNS, or you can use a locally configured hosts table. If you’re familiar with the HOSTS file from UNIX or Windows environments, this is almost exactly the same – a group of static name-to-IP address entries that you manually define.

To configure a router to use a local hosts table, you will need to be in global configuration mode. In the example below, I have created entries for 2 different routers, named accra and montreal, using the ip host command.

cisco2501(config)#ip host accra
cisco2501(config)#ip host montreal
cisco2501#show hosts
Default domain is not set
Name/address lookup uses static mappings
Host Flags Age Type Address(es)
accra (perm, OK) 0 IP
montreal (perm, OK) 0 IP

The show hosts command is used to view the hosts table. The table shows us that the entries are permanent, along with hostnames and associated IP addresses. To be honest, creating a hosts table on each an every router would be painful – you are much better off using DNS if it’s available.

Configuring a router to use a DNS server to resolve hostnames isn’t much more difficult. Just remember that entries for the hosts and their associated IP addresses need to be entered in DNS prior to the router being able to resolve them. There are a couple of steps involved in setting up a router to query DNS. As a first step, we need to reinstate the ip domain lookup command that we turned off earlier.

cisco2501(config)#ip domain-lookup
cisco2501(config)#ip name-server
cisco2501(config)#ip domain-name

So what just happened? Well, we reinstated domain lookup to begin with. The second step set the IP address of the DNS server that the router will query. The final command set the domain name of the router to This domain name will be appended to hostnames when we don’t provide a fully qualified domain name (FQDN). For example, an attempt to resolve the hostname accra would be sent to the DNS server as a request to resolve

Author: Dan DiNicolo

Dan DiNicolo is a freelance author, consultant, trainer, and the managing editor of He is the author of the CCNA Study Guide found on this site, as well as many books including the PC Magazine titles Windows XP Security Solutions and Windows Vista Security Solutions. Click here to contact Dan.