Cisco IOS CLI

From Help
Jump to: navigation, search

Return to main page

Most of these assume you are already in ENABLED mode.

Get basic info

  • show version
    • This will tell you which IOS you have installed (version and image), uptime, MAC, model number, serial number, etc
  • show interfaces
    • Gives detailed information for each interface, including duplex, MTU, hardware type, # of packts (inputed, outputted, dropped, etc)
    • use show interfaces ? to get a list of other types of information you can get, such as vlan, counters, flowcontrol, rate-limit
  • show vlan
    • This will give you a list of vlans, what ports are on them, their status, etc
  • show spanning-tree
    • Will show the VLAN STP list, which interfaces are on what tree

Return to Top

Set IP Address

config t

hostname 2960G

ip domain-name tpfnd.cat

interface vlan 1

ip address 10.0.0.9 255.255.255.0

ip default-gateway 10.0.0.1

exit

copy run start

Return to Top

Creating VLANs

NOTE: replace the number 5 with what ever number you want the vlan to be. Replace XYZ to the freindly name you want. This is multi-step, requiring:

  • enabling IP routing
  • initial vlan creation
  • assigning IP info to vlans
  • assigning ports to vlans
  • Initial vlan creation

enable

config t

vlan 5

exit

  • Assigning IP info to vlans: replace the values with the specifics to your requirements. Helper-address is the IP for your DHCP server.

interface vlan 5

ip address 10.1.0.9 255.255.255.0

ip helper-address 10.0.0.59

no shutdown

exit

  • Assigning ports to vlans: this command will put the Gigabit port at 0/10 to vlan 5:

interface Gi0/10

switchport access vlan 5

exit

  • This will "trunk" up port 1 to allow vlan 1, 5, and 10 to be passed up. It also will set the default 1 vlan 1 in case of STP trunk failure:

interface Gi0/1

switchport mode trunk

switchport trunk allowed vlan 1,5,10

switchport trunk native vlan 1

exit

NOTE: don't forget to write (wr m) to keep these settings on reboot.

Disable DHCP, enable helper

config t

interface vlan 1

ip helper-address 10.0.0.59

exit

copy run start (THIS WILL EXIT EXPRESS SETUP MODE)

Return to Top

Enable Telnet

enable

configure t

line vty 0

password cisco

login

logging synchronous

exec-timeout 40

motd-banner

exit

copy run start (THIS WILL EXIT EXPRESS SETUP MODE)

Return to Top

SSH Setup

enable

config t

crypto key generate rsa

1024

line vty 0 4

transport input ssh

login local

password cisco

exit


line con 0

exec-timeout 0 0

logging synchronous

login local

exit

config t

username cisco password cisco

enable secret cisco

service password-encryption

exit

copy run start (THIS WILL EXIT EXPRESS SETUP MODE)


TO TEST: sh ip ssh

Return to Top

Enable IP-based routing

NOTE: reload will reboot the switch

enable

config t

sdm prefer lanbase-routing

exit

wr m

reload

Return to Top

Find what device is on an interface

This is a two-step processes. First, you need to find the MAC address associated with the device. You can use various methods to do this, or use the below command. Then, you need to query the MAC address table to find what interface it is connected to. So you will use show ip arp | include * and show mac address-table | include *

In this example, we are looking for the IP of 10.0.0.211

To find the MAC associated with the IP:

3560G#show ip arp | include 10.0.0.211
Internet  10.0.0.211             62   7427.ea00.d32b  ARPA   Vlan1
3560G#show mac address-table | include 7427.ea00.d32b
   1    7427.ea00.d32b    DYNAMIC     Gi0/20

From this output you can see this device is attached to Gi/20.

You can also get a complete list of all dynamic MACs by just using sh mac-address-table dynamic:

3560#sh mac-address-table dynamic
          Mac Address Table
-------------------------------------------
Vlan    Mac Address       Type        Ports
----    -----------       --------    -----
   1    0015.5d00.381d    DYNAMIC     Fa0/4
   1    00e0.4c68.033b    DYNAMIC     Fa0/2
   1    00e0.4c68.033f    DYNAMIC     Fa0/4

You can get a list of IPs and MACs with just the sh ip arp:

3560G#sh ip arp
Protocol  Address          Age (min)  Hardware Addr   Type   Interface
Internet  10.0.0.1                0   0017.c5c2.5904  ARPA   Vlan1
Internet  10.0.0.8                -   0021.5607.1ac0  ARPA   Vlan1
Internet  10.0.0.9              138   001f.2655.0dc0  ARPA   Vlan1
Internet  10.0.0.50              32   78ac.c0a8.7a3a  ARPA   Vlan1
Internet  10.0.0.53             201   0015.5d00.3828  ARPA   Vlan1
Internet  10.0.0.59               0   78ac.c0a6.7255  ARPA   Vlan1
Internet  10.0.0.76               1   18a9.0518.c1cc  ARPA   Vlan1
Internet  10.0.0.81               4   0015.5d00.4d0d  ARPA   Vlan1
Internet  10.0.0.201            144   0021.9b55.b951  ARPA   Vlan1
Internet  10.0.0.206              3   0015.5d00.4d0a  ARPA   Vlan1
Internet  10.0.0.211            146   7427.ea00.d32b  ARPA   Vlan1
Internet  10.0.0.208             58   2c44.fd2c.5506  ARPA   Vlan1

And then run a mac address table with the MAC as a qualifier. I usually copy and paste and make a small text like:

sh mac address-table | include 0017.c5c2.5904
sh mac address-table | include 001f.2655.0dc0
sh mac address-table | include 78ac.c0a8.7a3a
sh mac address-table | include 0015.5d00.3828
sh mac address-table | include 78ac.c0a6.7255
sh mac address-table | include 18a9.0518.c1cc
sh mac address-table | include 0015.5d00.4d0d
sh mac address-table | include 0021.9b55.b951
sh mac address-table | include 0015.5d00.4d0a
sh mac address-table | include 7427.ea00.d32b
sh mac address-table | include 2c44.fd2c.5506

then copy it into the session and get back:

3560G#sh mac address-table | include 0017.c5c2.5904
   1    0017.c5c2.5904    DYNAMIC     Gi0/1
3560G#sh mac address-table | include 001f.2655.0dc0
   1    001f.2655.0dc0    DYNAMIC     Gi0/24
3560G#sh mac address-table | include 78ac.c0a8.7a3a
   1    78ac.c0a8.7a3a    DYNAMIC     Gi0/5
3560G#sh mac address-table | include 0015.5d00.3828
   1    0015.5d00.3828    DYNAMIC     Gi0/3
3560G#sh mac address-table | include 78ac.c0a6.7255
   1    78ac.c0a6.7255    DYNAMIC     Gi0/18
3560G#sh mac address-table | include 18a9.0518.c1cc
   1    18a9.0518.c1cc    DYNAMIC     Gi0/3
3560G#sh mac address-table | include 0015.5d00.4d0d
   1    0015.5d00.4d0d    DYNAMIC     Gi0/6
3560G#sh mac address-table | include 0021.9b55.b951
3560G#sh mac address-table | include 0015.5d00.4d0a
   1    0015.5d00.4d0a    DYNAMIC     Gi0/6
3560G#sh mac address-table | include 7427.ea00.d32b
   1    7427.ea00.d32b    DYNAMIC     Gi0/20
3560G#sh mac address-table | include 2c44.fd2c.5506
3560G#


Return to Top

References

Return to Top