Discovering computer networks: hands on in the Open Networking Lab
Discovering computer networks: hands on in the Open Networking Lab

Start this free course now. Just create an account and sign in. Enrol and complete the course for a free statement of participation or digital badge if available.

Free course

Discovering computer networks: hands on in the Open Networking Lab

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.

Watch the video below (which is about 2 minutes long) to see how to configure a hostname on a router.

Add a hostname

Download this video clip.Video player: 61_add_a_hostname.mp4
Skip transcript


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.

End transcript
Interactive feature not available in single page view (see it in standard view).

It is highly recommended to set a hostname on every router or switch. You need to be aware that there are rules for hostnames. For example, a hostname must not exceed 63 characters. It must start and end with a letter or digit, and contain only letters, digits, or hyphens.

Activity 3 Try it out

5 minutes

Open PT Anywhere [Tip: hold Ctrl and click a link to open it in a new tab. (Hide tip)] in a new tab or window so you can read these instructions.

  1. Select the router, open the CLI tab, then go to the appropriate configuration mode to configure a hostname.
  2. Configure the hostname ‘Coventry’ on the device and save the configuration.


You should have used the command enable to enter the privileged exec mode, and then the command configure terminal to enter global configuration mode. The next step was to enter the command hostname Coventry. Following this you should have noticed the prompt change from Router (config)# to Coventry (config)#. To save the change you should have entered the command exit to return to privileged exec mode and then used the command copy running-config startup-config.

You’ve now used the commands in the CLI to configure a hostname on a router. Now you know which router you are connected to, you can start making configuration changes. The next section will explain how to set an IP address on a router.


Take your learning further

Making the decision to study can be a big step, which is why you'll want a trusted University. The Open University has 50 years’ experience delivering flexible learning and 170,000 students are studying with us right now. Take a look at all Open University courses.

If you are new to University-level study, we offer two introductory routes to our qualifications. You could either choose to start with an Access module, or a module which allows you to count your previous learning towards an Open University qualification. Read our guide on Where to take your learning next for more information.

Not ready for formal University study? Then browse over 1000 free courses on OpenLearn and sign up to our newsletter to hear about new free courses as they are released.

Every year, thousands of students decide to study with The Open University. With over 120 qualifications, we’ve got the right course for you.

Request an Open University prospectus371