On a Cisco router, which global configuration command correctly changes the hostname of the device to a new name?

Difficulty: Easy

Correct Answer: router(config)#hostname newname

Explanation:


Introduction / Context:
This question checks your understanding of basic Cisco IOS configuration modes and the correct syntax for changing a router's hostname. Although simple, this task is performed frequently and appears in many introductory configuration labs and exam questions.


Given Data / Assumptions:
- You are working on a Cisco router using the command line interface.
- You want to change the hostname from its default (for example, Router) to a new, more descriptive name.
- You must know both the correct configuration mode and the exact command syntax for changing the hostname.


Concept / Approach:
On Cisco IOS, the hostname is configured in global configuration mode, not from user EXEC, privileged EXEC, or routing protocol sub-configuration modes. The exact command is hostname followed by the desired name, such as hostname Branch-R1. When you press Enter, the router prompt changes immediately to reflect the new hostname, confirming the change. The command does not include additional keywords like router-name or host name; it is simply hostname.


Step-by-Step Solution:
Step 1: From the initial prompt, enter privileged EXEC mode using enable if necessary.Step 2: Enter global configuration mode with configure terminal.Step 3: At the router(config)# prompt, use the command hostname newname, replacing newname with your chosen router name.Step 4: Observe that the command prompt changes to newname(config)#, indicating that the hostname has been updated.Step 5: Save the configuration with copy run start or write memory if you want the change to persist after reload.


Verification / Alternative check:
You can verify the configured hostname in several ways. The most obvious is the appearance of the new name in the CLI prompt. You can also use show running-config and look for the hostname line near the top of the configuration. If the new name is present, then the change was applied correctly in global configuration mode.


Why Other Options Are Wrong:
Option A uses host name with a space and is entered in privileged EXEC mode, which is invalid syntax and the wrong mode. Option B shows router(config-router)#, which is a router protocol subconfiguration mode, not global configuration mode. Option C uses the user EXEC prompt router> and again uses host name with a space, which is incorrect. Option E invents a router-name keyword that is not supported by IOS; the proper keyword is hostname. Only option D shows the correct mode and the correct command syntax.


Common Pitfalls:
New learners sometimes confuse host name and hostname or issue the command from the wrong mode, leading to error messages or no effect. Another pitfall is forgetting to save the configuration, causing the hostname to revert on reboot. Remember that most device-wide settings such as hostname, domain name, and passwords are configured in global configuration mode using simple, specific commands.


Final Answer:
The correct command is router(config)#hostname newname, entered from global configuration mode.

Discussion & Comments

No comments yet. Be the first to comment!
Join Discussion