Back to Command Reference
Global ConfigDomain 1.0

hostname

Modifies the display name of the device in the CLI prompt. This is the foundational step for device administration, logging identification, and generating RSA crypto keys for SSH.

Quick Reference

Execution ModeRouter(config)#
Privilege Level15 (Admin)
Default ValueRouter or Switch
Negation Commandno hostname

Syntax & Parameters

hostname [name]
ParameterDescription & Constraints
[name]The desired name of the device.
  • Must begin with a letter.
  • Must end with a letter or digit.
  • Internal characters can only be letters, digits, or hyphens.
  • Maximum length of 63 characters.
  • Cannot contain spaces.

CLI Deployment Scenarios

Scenario 1: Standard Deployment

You are configuring a brand new switch out of the box and need to name it for the Portland datacenter core.

Switch> enable
Switch# configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)# hostname PDX-CORE-SW1
PDX-CORE-SW1(config)# ! Notice the prompt changes instantly

Scenario 2: Removing the Hostname

You are decommissioning a router and want to return it to the default generic prompt.

PDX-CORE-SW1(config)# no hostname
Switch(config)#

CCNA Exam Gotchas

[!]

Prerequisite for SSH

You cannot generate RSA crypto keys (required for SSH remote access) if the router is still using the default generic Router hostname. Cisco IOS will throw an error. You must assign a unique hostname and an ip domain-name first.

[!]

Invalid Characters

If a simulator question asks you to set the hostname to "Core Switch 1", you must use hyphens or underscores (e.g., Core_Switch_1). Using a space will result in an "Invalid input detected" error.