Project

General

Profile

Cisco Lab

User documentation
09/13/2017

  • Last Updated: 11/24/2021

Cisco Lab

By now the user should have completed the "Student Lab Setup" guide found here:
https://neatrack.globalweb.net/documents/3

In this lab, you will learn the basics of Cisco routing and switching. The techniques you learn in this lab will show how a single inbound connection can be spread all across a myriad of machines efficiently. The command line interface for Cisco products can be intimidating to beginners, and as such the reader can expect this document to serve as instruction as well as a guide to basic commands.

By the end of this lab the user should be able to remotely access the switch from the server via Ethernet connection.

Accessing a Cisco Switch.

There are two recommended ways for you to access your Cisco switch.

The first is Minicom, a Linux command line Console tool. This guide explains how to use it:
https://neatrack.globalweb.net/documents/24

If you are using a Windows machine, read the following guide on how to use puTTY for Console connections:
https://neatrack.globalweb.net/documents/30

Choose a method and access the switch's command line now.

Accessing the Switch Terminal

After entering your username (which should be admin) and password (most likely from your teacher), you should get a prompt like so:

trainswitch>

This is the command line for the switch. Now enter the following command to access privileged mode:

trainswitch>enable
trainswitch#

You are now in privileged mode (if you see the "#" next to the switch name). In this mode, you are able to see the configuration and setup of the switch. However, this mode is not designed to edit that configuration. To actually edit the config of the switch, use the following command:

trainswitch#configure terminal
trainswitch(config)#

This is configuration mode. As long as you see the "(config)#", you are able to change the config of the switch.

Viewing Configuration

The whole configuration of the switch is located in a file you can see from this view. To see this file, run

do show run
. Something like the following will appear:

trainswitch(config)#do show run
Building configuration...

Current configuration : 3627 bytes
!
version 12.1
no service pad
service timestamps debug datetime msec localtime
service timestamps log datetime msec localtime
service password-encryption
service linenumber
!
logging buffered 512000 debugging
no logging console
!
clock timezone est -5
clock summer-time est recurring
ip subnet-zero
!
 --More-- 

The "Do" command only works in configuration mode. Essentially, it tells the switch to run the following command as opposed to modifying a configuration. "Show run" shows the running configuration seen on the switch.

You can see the rest of the switches config by pressing enter for one line at a time or spacebar for a page at a time. You can exit out of this view by typing another command or CTRL + C.

This is extremely useful with Cisco switches. They are designed to be easy to configure: thus, this isn't just the configuration scheme but also a set of commands to set up a switch. If you copied the whole configuration of a Cisco switch and pasted it in the terminal of a clean switch, they would become identical switches.

SSH

SSH is the process of remotely accessing a machine through an encrypted line. To allow SSH into a machine, it must have a key that allows access to encrypt the line. To generate these keys, run the following command. If it prompts you to overwrite old keys, say yes. Use a 1024 bit key. Then run the rest of the commands to ensure SSH is properly configured.

trainswitch(config)#crypto key generate rsa                                     
The name for the keys will be: trainswitch.train.local.                         
% You already have RSA keys defined for trainswitch.train.local..               
% Do you really want to replace them? [yes/no]: yes                             
Choose the size of the key modulus in the range of 360 to 2048 for your         
  General Purpose Keys. Choosing a key modulus greater than 512 may take        
  a few minutes.                                                                

How many bits in the modulus [512]: 1024                                        
Generating RSA keys ...                                                         
[OK]                                                                            

trainswitch(config)# ip ssh logging events
trainswitch(config)# ip ssh authentication-retries 2
trainswitch(config)# ip ssh time-out 30
trainswitch(config)# ip ssh version 2
  • crypto key generate rsa: this command puts an RSA host key pair in flash memory and makes it so you can SSH into the device, if it does not have SSH already enabled.
  • How many bits in modulus: you choose the size of the RSA key in bits, generally 1024 is the default but if you want higher security, a higher number is better, like 2048
  • ip ssh logging events: this logs all of the SSH log in attempts, both successful and failed, and it logs who was trying to log into the device
  • ip ssh authentication-retries 2: this limits the number of times a user can try to login before being kicked out of the SSH session the user is trying to makes
  • ip ssh time-out 30: this is the time limit that the device waits for the SSH server to negotiate a session key and the encryption used when connected with a device
  • ip ssh version 2: this specifies that this is a secure method for establishing an SSH connection compared to using Telnet or FTP

Creating a login for Console

These commands will create a user for anyone requesting access to the switch. Privilege 15 is the highest available, "secret" is a more secure type of password

trainswitch(config)# username admin privilege 15 secret 15.learner
trainswitch(config)# service password-encryption

  • username admin privilege 15 secret 15.learner: this creates the username that is allowed toe log into the device, the level 15 is allowing the user to have full access to the device, and the secret is the password that is associated with the username
  • service password-encryption: this makes the password encrypted so that even if someone goes into the device and tries to find passwords of other users, they won't be able to because the password would look like a jumble of letters and numbers; without this command anyone who logs into the device and gain access to the passwords of any other users on the device

AAA Commands

AAA stands for Authentication, Authorization, & Accounting. These commands regulate how logins, permissions, and logging are managed. These basic commands are often used for setting up a Cisco device.

trainswitch(config)# aaa new-model
trainswitch(config)# aaa authentication login default local
trainswitch(config)# aaa authorization exec default local if-authenticated
trainswitch(config)# aaa session-id common

  • aaa new-model: this makes AAA enabled on the device
  • aaa authentication login default local: this lets the device use the local database that is on the deviceto authenticate a user; however, you can use a RADIUS or TACACS server to authenticate a user
  • aaa authorization exec deafault local if-authenticated: this allows a user who has already been authenticated through a successful login, be authenticated again if the router loses communication between the device and its local database
  • aaa session-id common: this makes sure that the session ID is maintained throughout authentication, authorization, and accounting packets in the session

Console Configuration

These commands will effect a user consoling in via the switch's serial port

trainswitch(config)# line con 0
trainswitch(config-line)# session-timeout 60
trainswitch(config-line)# exec-timeout 60 0
trainswitch(config-line)# privilege level 15
trainswitch(config-line)#transport preferred none

  • line con 0: this is the console port that connects to the device; there is usually only 1, so this is the only choice, however, there are some cases that there are more which will be labeled
  • session-timeout 60: this is the time the session will wait for the user to type in something, if the timeout expires, the session will close
  • exec-timeout 60 0: this will disconnect the console if a user doesn't do anything after 60 seconds, this will also make the user type in the password to log back into the device
  • privilege level 15: again this command gives the user all available access to the device
  • transport preferred none: this command helps prevent any typos one might make while in the command line from making a misleading DNS lookup

These commands will effect a user SSHing in via ethernet

trainswitch(config)# line vty 0 15
trainswitch(config-line)# session-timeout 60
trainswitch(config-line)# exec-timeout 60 0
trainswitch(config-line)# privilege level 15
trainswitch(config-line)#transport preferred none
trainswitch(config-line)#transport input ssh

Many of these will be the same as for the serial port but there are some differences that will be noted here:
  • line vty 0 15: vty stands for virtual teletype which acts as a virtual port for SSH or Telnet and you can have up to 16 connections to choose from (0-15)
  • transport input ssh: this creates an encrypted connection between the user and the device, which will usaully need a username and password

Vlan Access

In a switch, different ports can have access to different vlans. This allows for the virtual creation of separate networks with no connections to each other. We already set up vlan 60 at the beginning of the year. To create or modify a vlan, enter the "int" command followed by the vlan number. We're going to continue to use 60 because we have vlan 10 or whatever was chosen to be our Internet access.

To create a vlan on the switch, use the basic command "vlan x" where x is the number vlan you are creating. For example, when making vlan 60:

trainswitch(config)#vlan 60                                               
trainswitch(config-vlan)#

You have now created vlan 60 on this machine. You know you are in vlan config mode by the "(config-vlan)#" prompt. While you are here, go ahead and give your vlan a name. You can do this like so:

trainswitch(config-vlan)#name test_vlan                                               
trainswitch(config-vlan)#

In this case, we named our vlan "test_vlan". Exit this specific vlan configuration with the "exit" command like so:

trainswitch(config-vlan)#exit                                             
trainswitch(config)#

Now you are back in interface mode, once again denoted by the "(config)#" prompt.

There are two ways vlans are edited. You already used the first. The second form edits the vlan as an interface. This allows us to give the vlan layer 3 qualities such as an ip address. To enter interface config of a vlan, use the following:

trainswitch(config)#int vlan 60                                               
trainswitch(config-if)#

You are now in the configuration mode for that vlan, as seen by the "(config-if)#" where "if" is short for interface.

Vlan Settings

There are a few common settings that you can change inside of a vlan. For example, "desc" (or description) allows the user to enter a small phrase describing what that vlan is used for. Give a description to your vlan.

Each vlan also has an ip address. Follow these commands to give the switch an ip address:

trainswitch(config)#int Vlan 60                                               
trainswitch(config-if)# ip address 172.30.60.10 255.255.255.0

We are using 172.30.60.10 because 172.30.60.15 is already in use for the DHCP server and we don't want to cause a conflict in IP addresses.

Finally, we want to enable the vlan. This essentially allows us to turn it on. Use this command:

trainswitch(config-if)#no shutdown

Port Access

If you scrolled down far enough on the switch configuration, you would see that each different port has its own configuration with a variety of settings. You can select a port by running the following command where ? is the port number you wish to access:

trainswitch(config)#int f 0/?

That line also highlights the autocompletion of Cisco devices. If there are no other words that fit the beginnings of the words in a command, Cisco automatically completes the command. The above command is the same as:

trainswitch(config-if)#interface fastEthernet 0/?

We've already configured a range of ports to use during the Student Setup Lab, so we don't need to configure another range. However, feel free to go over how to select a range and apply configurations to it in the instructions below.

To select more than one port, we use the "range" keyword. You can configure each port manually, but selecting all of them is much faster. Example:

trainswitch(config)#int ra F 0/9 - 16                                           
trainswitch(config-if-range)#

Most of the words I used auto-completion on, but you know you selected ports when you see "trainswitch(config-if-range)#" in the parenthesis.

Port Configuration

There are various settings we can apply to ports on a switch. The first is assigning what kind of data it deals with which vlan. We set up vlan 60 for the first few ports at the beginning of the year, so we won't apply a new vlan to the rest of the ports on the switch in case we add more in future labs. To assign a vlan to a port, use the "switchport access" command followed by vlan and the number. Below is an example giving ports 10 through 12 access to vlan 60:

trainswitch(config)#int ran f 0/10 - 12
trainswitch(config-if-range)#switchpo acc vl 60

Now, if you go ahead and plug (or unplug and plug back in) a device to that port, it will take about 30 seconds for the light above the port to turn green, signaling access. (NOTE: if you do this with the machine you are currently working on, you will need to reconnect to the switch!) That a lot slower than you have probably seen in just about every other ethernet port.

Ports connecting have three stages: Listening, learning, and forwarding. During those first 30 seconds the port was listening and learning before it started forwarding. To bypass this delay, we can enable portfast. Portfast allows a port to instantly enter the forwarding stage and allow internet access to the connected device. To enable portfast, use the following command on all ports you use. If you disconnect and reconnect your device, you should see that the orange light turns green much faster.

trainswitch(config-if-range)#spanning-tree portfast trunk

There are two main port types we use. The first is an access port. An access port allows for a straight connection to the source with no complexities. A trunk port, on the other hand, tags the end of packets with a short key. This key states what network is being sent through that line. If you wish to use more than one network or vlan in a single port, trunking must be enabled. You can enable trunking with the "switchport mode" command followed by trunk, but DO NOT do this for your selected ports.

Another useful feature of Cisco switches is the ? in Cisco. If you type switchport mode ? into the console, the following will appear:

trainswitch(config-if)#switchport mode ?                                   
  access   Set trunking mode to ACCESS unconditionally                     
  dynamic  Set trunking mode to dynamically negotiate access or trunk mode 
  trunk    Set trunking mode to TRUNK unconditionally
It lists the different options for the command. This works after any incomplete command in Cisco, even if there is no command and only the ?. Feel free to experiment with this. But we'll go over these options in detail:
  • access: forces any device pluggged into this type of port to only communicate with devices that share the same VLAN
  • dynamic: gives port profiles to devices connected without needing access or trunk (not commonly used but still an option)
  • trunk: lets multiple devices from different VLANs go onto the same port instead of limiting to only one VLAN

Type the "exit" command until you are back in privileged mode. Your screen should look something like this:

trainswitch(config-if)#exit
trainswitch(config)#exit
trainswitch#

Possibly the most important part of switching is saving your changes. To do this, use the following command. Do this every time you are done editing a Cisco device. If the device loses power, it will revert back to its last saved config.

trainswitch#write mem
Building configuration...
[OK]
trainswitch#

After this, you can reenter configuration mode.

Before you disconnect your console port, create a banner for your switch. This will appear anytime someone connects to it. Use the following command:

banner motd ^
Welcome to my switch!
^
  • motd: stands for Message of the Day

You can put anything between the carrots. After you finish this, run the "write mem" command to save your work. Disconnect your console cable.

Once you ssh into the switch, print out (on the screen) the run config for your switch using the following:

trainswitch>enable
trainswitch#show run

Setting up a Cisco Router

Now one of the useful qualities of Cisco devices is that the basic structure and feel of setting up different devices is very similar. For basic purposes, a Cisco Router and Switch will have many similar configuration commands. Make sure that are consoled in to the router and that you have followed the same setup instructions up to (but not including) step 1.2 for the router as you did for the switch in the Student Lab Setup. This will set up the basic configuration while leaving the ports untouched. You then need to do the same commands as above to set up SSH, a user account, AAA, and the console configuration. These commands do the same thing on both the switch and the router, so rather than directly influencing the network, they allow you better configure and manage these devices.

One of the important functionalities for a router is for it to have different ip addresses on each of its ports. This can be true on a switch as well, but it is especially important on a router. Because of this, we can set the ip address on the outward facing port (typically FastEthernet0/0) to be a static ip on a WAN, as well as a static ip on the internal LAN (typically on port FastEthernet0/1) such as 192.168.1.1 so that devices connected on the switch can reach it.

Setting up an ip address on a port is relatively straightforward: just enter the interface configuration and run a command to specify the address and subnet mask. After doing so, it is important to make sure the interface is up by doing "no shutdown". Do the example shown below:

trainrtr(config)#int fa 0/0
trainrtr(config-if)# ip address 172.30.60.1 255.255.255.0
trainrtr(config-if)# no shutdown

This will set the ip address of the internal facing port, which should be connected to your switch already, to 172.30.60.1 as well as specifying it is on a /24 subnet. This works well when there is only one internal network, but using vlans, we can have whole collection of internal networks, each on different subnets. Because of that, we will often want the router to be able to serve each of these different vlans, which we can use sub-interfaces to do. We will touch in more detail during the static routing lab how to set up a sub-interface, but using the entire physical interface works in this example.

SSH testing

At this point, both the switch and the router should have ports that are connected to the 172.30.60.0/24 network. If these ports are connected together by an ethernet cable, they should be able to talk directly to each other. If they are not already connected, either attach a cable from the router's internal port to one of the switch's ports configured on vlan 60, or connect the router's internal port to one of the switch's ports, then configure the port on the switch to access vlan 60.

By doing this, we make a connection where both the switch are attached to each other and are on the same network, therefor allowing them to communicate. We can test this by using the ssh command, which will allow you to access a console over the network. While connected to the router, use this command (make sure you are not in the configuration terminal):

trainrtr# ssh -l admin 172.30.60.10

If everything is working, it should ask you for the password for the switch, which once entered it will open up a console on the switch.

Files

switchRearPorts.jpg (556 KB) switchRearPorts.jpg Anonymous, 07/10/2018 10:40 AM
Rollovercable.jpg (2.77 MB) Rollovercable.jpg Anonymous, 07/10/2018 10:49 AM