16.2 Adding hostnames and IP addresses
In this part we will configure hostnames and IP addresses on the routers to allow devices on the same LAN to communicate with each other. It is good practice to assign an identifiable hostname to a router to make it easier to check you are connected to the correct one when you are using the CLI.
Watch the video below, which is about 6 minutes long. In this video, the interfaces of router Branch-A and router Branch-B are configured and each router is assigned a hostname. The video shows some useful shortcuts when working in Packet Tracer, but unfortunately these do not work in PT Anywhere.
Configuring hostnames and addresses
Now we can start configuring the devices. We can see both networks connected to Branch A’s router will be configured with IPv4 addresses, and the two networks connected to Branch B’s router will be configured with IPv6 addresses.
Let’s start by configuring the IP addresses on Branch A’s router. To do this we need to click the router and select the CLI tab. Here if we are asked if we want to go through the first-time set-up wizard we will answer ‘no’.
If we press Return we will be in user exec mode. We can type enable to enter privilege exec mode indicated by the hash symbol. Now we can get into global configuration by typing configure terminal, or conf tfor short.
The first thing I will do is configure the hostname to reduce confusion later. We can do this by typing hostname Branch-A. We can see that the router prompt changes to ‘Branch-A’. Now we need to configure the interfaces of the router with IP addresses and then turn them on.
From global configuration, the command interface gigabit 0/0 will take us into the sub-configuration mode for that interface. Within this mode, we can set an IP address for the interface by typing ip address 172.20.16.1. We also need to specify the subnet mask, in this case a /23 subnet mask, the decimal equivalent of which is 255.255.254.0. The interfaces on routers by default are turned off, because they need to be configured first, so we need to turn this interface on. The command is no shutdown. Generally the opposite of any command in Cisco is preceded with no. As we type no shutwe will receive a notification message stating that the interface has come up. This means the interface is now functional.
As you become familiar with using the command-line interface you will learn a number of shortcuts to make your use of time more efficient. A number of shortcuts I use in this session include: tab to complete a command, up and down arrows to scroll through the history of commands, Ctrl+A to skip to the front of a command and Ctrl+E to skip to the end of a command. For example, instead of retyping all of those commands again to configure G0/1, we can use the up arrow and just edit the commands instead. Now we can configure gigabit Ethernet 0/1. If we use the up arrow we can get the IP address and just edit it to save some time and then move on to gigabit 0/2. Up arrow again; change the IP address and subnet mask. I forgot to turn gigabit Ethernet 0/1 on so we can just go back into 0/1 and issue no shutand then go back to 0/2 and do no shutagain. Now all the interfaces are configured for Branch-A.
We can check Branch-A’s IP configuration by using the showcommand show ip interface brief. This will show us the IP addresses and the state of the interface. We can see that all the interfaces that have been configured have the right IP addresses and the status is up, up, meaning the interface is configured correctly.
We can now move on to Branch-B. We answer no, type enable, configure terminal. We can set the hostname to host Branch-B. Go into interface G0/0. This is where the configuration changes slightly. To configure an IPv6 address, you must use ipv6 address and then the address followed by the subnet mask in CIDR notation. Note there is no space between the IP address and the subnet mask.
Now we can continue the configuration as before. First no shut to turn that interface on. Interface G0/1. IPv6 address 2001:DB8:FADE:100::1/64 no shut. Interface gigabit Ethernet 0/2. Set the IPv6 address. Oh, I made a typo. Not to worry: we can just remove the IP address and add the correct one. To do this use the up arrow, then to get to the start of the line you can use Ctrl+A. Then we can insert no and hit Return. This will remove the incorrect IP address. And now we can add the correct IP address 2001:DB8:FFFF:FFFF::2/64 no shut.
That completes Branch-B’s IP addressing.
We can check Branch-B’s IP configuration with show ip interface brief. You can see that there are no IPv4 addresses listed and they are all unassigned. That is because Branch-B is only using IPv6. The showcommand to see the IPv6 address configuration is show ipv6 show interface briefwhere we can see the address is configured and the status of the interface. We can see that all three interfaces have the correct IPs and are up, up meaning they are working.
When watching this video you may have wondered why a pair of IPv6 addresses were shown for each of the Branch-B router interfaces after the command show ip interface brief was issued. You probably recognised the second addresses in the pair as the ones configured for each router interface. The first address is an automatically assigned link-local address for the network segment. Link-local addresses were mentioned in Session 2. Such addresses are not intended for normal networking.
Activity 2 Test yourself
Why do you need to issue the no shutdown command on a router interface ?
Because, by default, interfaces on routers are switched off, whereas on switches they are on by default
The IPv6 address of G0/0 Branch-B router is given as 2001:DB8:FADE:FF::1. Explain the meaning of the double colon in this address.
An IPv6 address is usually written as eight blocks of four hexadecimal numbers, separated by a colon. A double colon indicates that one or more blocks in this position is the hexadecimal number 0000. In the example given, only five number blocks are shown; therefore there must be three 0000 blocks at the double colon.
Activity 3 Try it out
Openin a new tab or window so you can read these instructions. In this network only Branch-A’s router has been configured.
1. Check whether the configuration of Branch-A router’s interfaces agrees with the IP addresses given in the table below and make any corrections necessary.
|Device||Interface||IP address||Subnet mask|
2. Configure Router Branch-B with the IPv6 addresses given below. Don’t forget to configure the router’s hostname as well.
|Device||Interface||IPv6 address||Subnet mask|
3. Check to confirm that Branch-B’s router has been correctly configured.
To check Branch-A router’s interface configuration, you could use the show ip interface brief command, which can be used either in user exec mode or privilege exec mode. This would reveal an incorrect IP address for G0/0. You should have removed the incorrect IP address and then configured the interface with the correct IP address. Of course, you would also need to add the no shut command. Checking that the subnet masks are correct would require the use of the show ip interface command, which can also be used either in user exec mode or privilege exec mode. The show ip interface command gives the subnet mask in slash notation (or CIDR notation).
Because the Branch-B router uses IPv6 addresses, you need the command ipv6 address at the config-if prompt, followed by the appropriate IPv6 address and the subnet mask in CIDR notation. To configure the host name you would use
Router(config)# host Branch-B
This time, because the Branch-B router uses IPv6, the appropriate command to check the configuration of the interfaces is show ipv6 interface brief, or show ipv6 interface.
Now watch the video below, which is about 2.5 minutes long. It shows the Central router being configured with both IPv4 and IPv6 addresses.
Configuring the Central router
Now we can quickly configure the Central router. Open the command line. Answer no to the auto-configuration wizard. Type enable. Type configure terminal. Set the hostname to ‘Central’. Enter interface gigabit ethernet 0/0. Set an IPv4 address of 172.20.31.253 with a subnet mask of 255.255.255.252. Turn the interface on with no shut. Go to interface G0/1. Add its IPv6 address 2001:DB8:FFFF:FFFF::1/64. Turn the interface on with no shut.
Go to gigabit Ethernet 0/2 and this is where the configuration changes. On the Central router we have to configure both IPv4 and IPv6 addresses on the same interface to allow connection to the DNS server. So first we can set the IPv4 address, IP address 172.20.32.1 255.255.255.0 and then we can set the IPv6 address 2001:DB8:FADE:1000::1/64. And then turn the interface on. That completes the IP addressing of the Central router.
We can check the IP configuration of the Central router with show ip interface brief. As you can see, G0/0 and 0/2 both have IP addresses and they are up. We also need to check the IPv6 configuration show ipv6 interface brief. You can see that G0/1 and 2 are both configured and up.
Activity 4 Think about
The result of issuing the command show ip interface brief for a router that uses both IPv4 and IPv6 addresses is shown below.
Router#sh ip in br
Interface IP-Address OK? Method Status Protocol
GigabitEthernet0/0 22.214.171.124 Yes manual up up
GigabitEthernet0/1 unassigned YES unset up up
GigabitEthernet0/2 126.96.36.199 Yes manual up up
Vlan1 unassigned Yes unset administratively down down
Select the correct statement(s) from the list below.
No IP address has been assigned to interface G0/1.
Interfaces G0/0 and G0/2 only use IPv4 addresses.
Interface G0/1 is the only interface that could use an IPv6 address.
It is possible that all three interfaces have an IPv6 address assigned to them.
The correct answer is d.
Correct. An interface can have both an IPv4 and an IPv6 address assigned to it.
Activity 5 Try it out
Open PT Anywhere in a new tab or window so you can read these instructions. In this network both Router Branch-A and Router Branch-B have been configured.
1. Configure the Central router with the IPv4 and IPv6 addresses given below. Don’t forget to configure the router’s hostname as well.
|Device||Interface||IPv4 address||Subnet mask|
|Device||Interface||IPv6 address||Subnet mask|
2. Use the correct commands to check that the router’s interfaces have been correctly configured.
- At the (config-if)# command the correct command to configure IPv4 addresses is ip address followed by the appropriate IPv4 address and subnet mask. At the (config-if)# command the correct command to configure IPv6 addresses is ipv6 address followed by the appropriate IPv6 address and subnet mask in CIDR notation.
- The commands to check the correct interface configuration are show ip interface brief and show ipv6 interface brief. You need to be in either user exec or privilege exec mode to enter these commands. The results should look something like the following (although your link-local addresses, which are the ones beginning with FE80, might be different):
Central#show ip int br
Interface IP-Address OK? Method Status Protocol
GigabitEthernet0/0 172.20.31.253 YES manual up up
GigabitEthernet0/1 unassigned YES unset down down
GigabitEthernet0/2 172.20.32.1 YES manual up up
Vlanl unassigned YES unset administratively down down
Central#show ipv6 int br
Vlanl [administratively down/down]
Now watch the video below, which is about 2 minutes long. It shows the PCs being configured with their IP addresses
Configuring the PCs
Now we can configure the IP addresses on the PCs.
Click the PC, select the ‘Desktop’ tab, and then select the ‘IP Configuration’ option. Within this window we can configure both IPv4 and 6 addresses. We are configuring PC-A1 so the IP address is 172.20.16.10 and the subnet mask is 255.255.254.0. The default gateway is the IP address of the local router, 172.20.16.1 and for testing later I will set a DNS server address of 172.20.32.10.
I will now move to PC-B1 to demonstrate configuring a IPv6 address on a PC. It is very similar. Go to the ‘IP Configuration’ of the PC, but in the lower section of the window you add the IPv6 details instead. So for PC-B1 the IPv6 address is 2001:DB8:FADE:FF::10 with a mask of /64. The IPv6 gateway will be 2001:DB8:FADE:FF::1 and the DNS server will be 2001:DB8:FADE:1000:10.
These two configurations will need to be repeated on PC-A2 and PC-B2 with the appropriate addresses to complete the IP configuration of all the devices. In the background, the DNS server has been configured with its IPv4 and IPv6 address and an A record has been created for contoso.com for testing purposes in a later section.
Note that at the end of the above video the speaker says ‘… and an A record has been created for contoso.com for testing purposes’. An A record on a domain name server (DNS) links a domain name such as open.ac.uk to an IP address. When you type the URL into a browser, an A record at the DNS enables your computer to be informed of the IP address of the web page you wish to consult.
Activity 6 Think about
The video showed that when an IPv6 address is configured, the subnet mask has to given in CIDR – for example as /64. Why is this more sensible than using dotted decimal form for the subnet mask?
The slash notation is much simpler than the dotted decimal, and therefore less likely to be a source of error when it is keyed into the settings or written down. With IPv4, the dotted decimal notation is not too complicated, but in IPv6 it is horrendous. This is because IPv6 address consists of 128 bits arranged in eight groups of four hexadecimal digits. Each group of four hexadecimal digits represents 128 bits ÷ 8 = 32 bits. That is as many bits as an entire IPv4 address has. So, if the first 32 bits of an IPv6 subnet mask were all 1s, to show that this part of the address was in the network part of the address, the dotted decimal number in the subnet mask would be 4,294,967,295; and that would just be one-eighth of the subnet mask!
It would be less complicated to represent the subnet mask as a series of hexadecimal numbers, like the address itself. In that case, if the first 32 bits of an IPv6 subnet mask were all 1s then they would be represented as FFFF, which is not so bad, but it is still only one-eighth of the complete mask. The slash notation is much simpler.