Basic Cisco Ios Commands

Download as pdf or txt
Download as pdf or txt
You are on page 1of 9

BASIC CISCO IOS COMMANDS

1. User and Enable mode (Privileged Exec Mode)


Once the switch/router has booted and we have pressed the enter key, we end up in what
we call the user mode or user EXEC mode. In this mode, we have permission to use some
simple commands but we are restricted to congure anything or use some more advanced
commands. Right now, the command line will show you this:

1 Switch>

The “>” symbol tells us that we are currently in user mode. To get full access to the switch, we have to
enter privileged mode, also called enabled mode. Here is how to do this:

1 Switch> enable
2 Switch#

Above you can see that the “>” symbol changed to “#”. This tells us we are now in enabled mode,
granting us full access to the switch.

1 Switch# exit
2 Switch>

The exit command lets you jump back to user mode.


2. Show commands
The show command is probably the most used command for Cisco IOS. We can use it to fetch
any information from the switch. Let’s start with a simple example, let’s say we want to see
some general information about the switch:

1 Switch#show

The show mac address-table dynamic command tells us all MAC addresses that the switch
has learned.

1 Switch# show mac address-table

What if we want to see the entire conguration of the switch? There’s a show command for
that:

1 Switch# show running-config


The show running-cong command gives us the entire active conguration of the switch. Even
though we haven’t congured anything yet, there is a basic conguration.

3. Saving the configuration


We entered a couple of commands but once we pull the power plug, everything is gone…
Why? Everything we congure on our switch is applied to the running conguration. This
conguration is only active in RAM, pull the plug and it’s gone.
If we want to save our conguration, we have to save it as the startup conguration which is
saved in NVRAM. Next time we boot our switch, it will look for the startup conguration and
use that. Here’s how to copy our running conguration to the startup conguration:

1 Switch# copy running-config startup-config

Use the copy command to copy the running conguration to the startup conguration.
Here’s a simple illustration to help you visualize the two conguration files:
Instead of copy, we can also use write to save our configurations

1 Switch# write

4. Configuration
You probably want to make some changes to the conguration of your switch/router. Change its
default hostname, perhaps add an IP address so you can manage it remotely, etc.

To do this, we have to use conguration mode. In this mode, we can make changes to the
conguration of the switch. Here’s how you enter configuration mode:

1 Switch> enable

First, you need to make sure you are in enable mode. Now you can use the following
command:

1 Switch# configure terminal

With the congure terminal command, we enter conguration mode. Now we can make
changes to the switch.
Let’s start with something simple, let’s change the name of our switch with the hostname command:

1 Switch(config)#hostname SW1
2 SW1(config)#
Here is a picture to help you visualize the different modes and how to move from one to
another:

5. Do Command
If you are in the conguration mode, you will face the following issue if you try a show
command:

1 SW1(config)#show version
2 ^

3 % Invalid input detected at '^' marker.

Why? The command is typed correctly but the problem here is that this is a command for the
enable mode, not the conguration mode.
You could exit the conguration mode but instead, you can add do in front of the show
command:

1 SW1(config)#do show version

Problem solved !
6. Question Mark
Not sure what the command was again or how to type it? The question mark is your friend. If
you use it, it will tell you all possible commands:

1 SW1#?

The question mark works in user, enable and conguration mode so go ahead and try it
everywhere. It also helps you finding out which commands are possible. For example :

1 SW1#cl?
2 clear clock

If I type cl? then the CLI tells me there are two possible commands:

• clear
• clock

7. Abbreviation
There is no need to type the exact command for CLI to accept it. You can also shorten
commands. For example, I just used copy running-config startup config but I don’t have to
type the entire thing. This will also work:

1 SW1#copy run st

After the copy command, there is only one parameter that starts with “run” which is
running-cong. The only parameter that starts with “st” is startup-cong. Once you get more
experience with the CLI and become familiar with the different commands, you will
automatically use this more often.
8. Advanced Configurations (Hostname, Interface, Telnet, SSH, console…)
With the congure terminal command, we enter conguration mode. Now we can make
changes to the switch/Router.

A. Hostname

Let’s change the name of our switch with the hostname command:

1 R1(config)#hostname name
2 name(config)#

B. Interface (IP Address)

Let’s say we want to make changes to one of our interfaces:


Fort his example we use 192.168.10.1 as IP for the interface

1 R1(config)#interface gig 0/0


2 R1(config-if)# ip address 192.168.10.1

C. Enable Password (Privilege mode)

1 R1(config)#enable secret “password”

D. Console Port

For physical access to the router through a PC

• First put a set of username and password


Here we can either use “password” or “secret” before typing the password

1 R1(config)#username name password password


2 R1(config)#
• Move to the Console mode and use the “login local”

1 R1(config)#line cons 0
2 R1(config-line)#login local

E. VTY (SSH & Telnet)

• First put the set of username and password


• Move to the vty mode and use the “login local”. We can also set a range for the
number of connections we want simultaneously, from 0 to 15
Here we’re going to set a range of 5 remote connection

1 R1(config)#line vty 0 4
2 R1(config-line)#login local

• For the SSH

Here we need to add some commands into the configuration mode.


Configure a hostname for the router
Configure the username & password credentials
Configure the enable password
Then set the domain name
Finally set the encryption

1 R1(config)#hostname test
2 test(config)#ip domain-name “name.com”
3 test(config)#crypto key generate rsa

Now on the remote PC, we put the next commands:

1 C:\>ssh -l root 192.168.10.1

Here the root stands for the username in the set of username & password and
192.168.10.1 stands for the IP address of the remote router
• For the Telnet

After configuring our set of username and password, we can just connect to our remote computer
and tape the next command to reach the remote router through Telnet

1 C:\>telnet 192.168.10.1

F. DHCP

• Create a pool for the dhcp


• Assign a range of addresses to that pool
• Set a default gateway which is the router ip interface connected to the network

1 R1(config)#ip dhcp pool name-of-pool


2 R1(dhcp-config)#network ip mask
3 R1(dhcp-config)#default-router router-interface-ip

• In case we want to exclude a part within our range

1 R1(config)#ip dhcp excluded-address ip1-ip2

Here, ip1 refers to the start of our range and ip2 refers to the end of it

G. Static Routes
DETAILED STEPS

Step 1
Enters configuration mode.

1 R1#configure terminal
2 R1(config)#

Step 2
Configures a static route and the interface for this static route. You can optionally configure
the next-hop address.

ip route {ip-addr ip-mask} {[next-hop | nh-prefix]

1 R1(config)#ip route 192.168.10.0 255.255.255.0 <next-hop>

Step 3
(Optional) Displays information about static routes.

1 R1(config)#show ip route

You might also like