10.3 Configure a hostname
You will now have an opportunity to configure a hostname on the router. The main reason for configuring a hostname on a device is to easily identify the device when accessing it remotely. For example, if you are working from an office in Milton Keynes but you are configuring a router physically located in London, the only reference you have via the command line is the hostname. It is possible that you could be connected to multiple routers at the same time, so it is important to establish the correct and identifiable hostname before you change the configuration of the device.
You are watching: Why is it important to configure a hostname on a device?
Watch the video below (which is about 2 minutes long) to see how to configure a hostname on a router.
The task for this part is to configure the router with the hostname ‘Piccadilly’. We are connected to an unconfigured router. If we are asked about the configuration wizard, remember to answer no. Then we need to get into global configuration mode. First we need to enter privileged exec mode by typing enable. Then we can type configure terminal. The prompt will change, and then we are in the configuration mode. We could use the question mark to find out the command, but there are a lot of options in this mode. The command that we need to use is hostname. If you get stuck half way through a command you can use the question mark to get help: it will tell you what options can be used with that command. If I use the question mark, we can see that the command needs a word as stated in the CLI. This word is what you want the router to be named. We want this router to be called ‘Piccadilly’, so the full command will be hostname Piccadilly. As you hit Return you will see the prompt change to ‘Piccadilly’. This configuration change will take immediate effect, as this is now part of the running configuration. This is the configuration the router is using to make any decisions currently.
If we want the changes to still be effective after a reboot, we will need to save the configuration to the startup configuration. When the router turns on it copies the startup configuration to the running configuration and then continues to make decisions based on this running configuration. We can save the config by going back to privileged exec mode with the command exit, then use the command copy running-config startup-config. Now the configuration is saved. If the router was to restart now, the configuration of the device would come back to the same state. In the next part we will look at configuring an IP address via the command-line interface.