Image of Jeremy L. Gaddis, CCNA, CCNP (and Cortney, in case you were wondering)

Assigning Hostnames to Cisco Devices

by Jeremy L. Gaddis on September 6, 2011 · 1 comment

Post image for Assigning Hostnames to Cisco Devices

Just like children and pets, the devices in our network need to be named so that they can be clearly identified.

Imagine if none of the routers or switches in our networks had names. A diagram of our network might look something like this:

Unnamed Routers

If one of the routers in the network suddenly developed a problem, how would you explain to another person which one it was? By default, Cisco network devices have default hostnames of “Router” and “Switch” but these aren’t very helpful either. There are only three routers in the above diagram, but what if we had 100? When it came time to perform maintenance, confusion would surely ensue.

Naming Conventions

Most large organizations have established naming conventions that are to be followed when assigning hostnames to routers, switches, servers, and PCs. Some simply use “router1″, “router2″, and so on. One popular method of assigning hostnames takes a device’s type, location, and purpose into consideration. For example, the second core router in a company’s Chicago office might be named “chi-cr02″.

RELATED: At a former employer, it was decided that the hostnames assigned to servers would be comprised of a two-character city code, a hyphen, the word “server” and then a two-digit number beginning with 01. Following this convention, servers in Chicago would be named “ch-server01″, “ch-server02″, and so on. While this is a perfectly acceptable way of assigning hostnames, the names did not reflect the server’s purpose, operating system, or any services that ran on the server. A new employee would have no way of knowing what “ch-server14″ was used for.

Ultimately, how you choose to name your devices is up to you (or your company’s policy) but you should always try to use names that are meaningful in your environment. In my home Cisco lab and the examples in these articles, I will often simply use names such as “R1″ and “SW1″ for simplicity. In some cases, such as this one, we’ll use names of large cities to make visualizing the network easier.

Guidelines for Assigning Hostnames

There are some general rules that you should follow when choosing hostnames. Hostnames should:

  • Consist only of letters, numbers, and hyphens — no spaces or underscores!
  • Begin with a letter
  • End with a letter or number
  • Be less than 64 characters

NOTE: Microsoft Windows, for example, will allow you to name a server “14_Server” but this doesn’t mean that you should. In fact, you really shouldn’t, as it can cause problems, especially if the server handles Internet mail. The Internet standards regarding hostnames (RFC 952 and RFC 1123) provide more technical details on hostnames.

With this in mind, here’s an updated version of our network diagram depicting hostnames that we might assign to the routers:

Named Routers

With hostnames assigned, our network diagram is much more informative. Just by glancing at it, we know that our network consists of routers in three different cities in the United States.

In addition, it’s much easier to troubleshoot this network, especially if you are working with another person. Being told that “the router is down” isn’t very helpful when you have three of them. “The Boston router is down”, however, gives us information that we can use as a starting point in diagnosing the problem.

Configuring the Hostname

Setting hostnames is both a necessary step in the process of configuring a new device and amazingly easy as well. For this reason, I’ve picked this task as the first configuration task you will perform.

NOTE: If you don’t have your own Cisco devices to experiment with, you’ll want to obtain Dynamips and/or Cisco IOU so that you can follow along with this and the other Free CCNA Labs exercises.

You’ll need to be in global configuration mode in order to set the hostname.

Router> enable
Router# configure terminal
Enter configuration commands, one per line.  End with CNTL/Z.

If you explored the CLI while learning about the context-sensitive help in IOS, you may have already discovered that the hostname command is used to configure a device’s hostname. Let’s set the hostname to “Miami”:

Router(config)# hostname Miami

Notice how the prompt immediately changed to reflect the new hostname? This is a great example of how the changes we make will immediately take effect in IOS.

What if you wanted to change the hostname to something else? Simply issue the hostname command again, supplying the new hostname as the parameter:

Miami(config)# hostname ccna-router

Once again the change took effect immediately. Congratulations! Although it was very basic, you have now successfully configured a Cisco router!

Lab Exercise


In Introduction to Cisco Devices and Cisco IOS, we introduced the concept of the running configuration and the startup configuration. The hostname change that we made is now present only in the running configuration. If the router is reloaded or powered off, the change will be lost and the hostname will revert back to “Router”. In Erasing and Saving Configurations on Cisco Devices, you’ll learn how to make those changes permanent.

Image Source

  • Dogmentor

    I got wendal odems book for ccent which is great but I feel like its comptia network

    + so far, glad I found this page so I could enjoy some meat

Previous post:

Next post: