SystemGlobal Config

hostname [name]

Sets the hostname of the device, which is used to identify the router or switch in the CLI prompt and network management systems.

Syntax·Global Config
hostname [name]

When to Use This Command

  • Assigning a unique name to a new router during initial deployment to distinguish it from other devices.
  • Renaming a device after a network reorganization or acquisition to reflect its new role.
  • Setting a descriptive hostname for easy identification when accessing multiple devices via SSH or console.
  • Configuring a hostname that matches the device's DNS record for consistent network management.

Command Examples

Setting a basic hostname

Router(config)# hostname R1
R1(config)#

The prompt changes from 'Router(config)#' to 'R1(config)#', indicating the hostname is now R1.

Setting a hostname with a domain name

R1(config)# hostname Branch-Office-1
Branch-Office-1(config)#

The prompt updates to reflect the new hostname 'Branch-Office-1'. This name is used in the CLI prompt and can be included in system messages.

Understanding the Output

The hostname command does not produce a separate output; instead, it immediately changes the CLI prompt to reflect the new hostname. The prompt format is 'hostname(config)#' in global configuration mode. A meaningful hostname helps in identifying the device during troubleshooting and management. There are no 'good' or 'bad' values, but best practices recommend using a consistent naming convention (e.g., location-role-number).

CCNA Exam Tips

1.

Remember that the hostname command is executed in global configuration mode; it does not require a reload to take effect.

2.

The hostname can be up to 63 characters and can include letters, digits, and hyphens, but cannot start or end with a hyphen.

3.

The hostname appears in the router prompt and in system messages like 'R1(config)#' or 'R1#'.

4.

On the CCNA exam, you may be asked to identify the correct command to change the device name or to interpret the prompt after a hostname change.

Common Mistakes

Typing the command in user EXEC mode (Router>) instead of global configuration mode (Router(config)#), resulting in an error.

Including spaces or special characters (like underscores) in the hostname, which are not allowed.

Forgetting that the hostname change is immediate and cannot be undone without re-entering the command with a different name.

Related Commands

Practice for the CCNA 200-301

Test your knowledge with hundreds of CCNA practice questions covering all exam domains.

Practice CCNA Questions