Syed Jahanzaib Personal Blog to Share Knowledge !

November 8, 2016

Personnel Short Notes for Cisco Switches/Routers


This post contains some personnel short notes on various configuration related to Cisco Switches/Routers. I wrote this post so that I can find my day to day usage commands from this centralized location.

Regard’s
Syed Jahanzaib

 


> Method#0 – Erase setting while you are have already access on the switch

write erase
delete flash:vlan.dat
reload

After this switch will reload its OS, and will come back with default switch settings. Recommended to use Serial console cable.


> Method#1 – Reset Everything – Factory Default

Following is a quick method to reset Cisco switch to factory default settings. This method can also be used to recover password.

Requirements:

  • Cisco Switch
  • Console Cable
  • PC/Laptop with Serial Port

 

  • Connect your console cable from the switch Console port to PC/Laptop serial Port.
  • Open the Hyper Terminal application, and select settings as per your hardware. Following is configuration for Cisco 3750 Model.
    Bits per second: 115200
    Data bits: 8
    Parity: None
    Stop bits: 1
    Flow control: Xon / Xoff
  • Different switches connect with different Bits per Second setting . For Cisco 2950 Model try to lower it at 9600.

hyperterminal.PNG

  • Power Off the switch / Now hold the MODE button on the switch and power ON the switch.

sw-power.jpg

  • Once the switch initialize itself (may take 1 minute for 3750, and for 2950 it generally requires 5-6 seconds to hold mode button. ), This will interrupt the boot process before the Flash file system can initialize, and after a short while (continue holding the “mode” button) you will see the following prompt:

sw-1

Once you see the

The password-recovery mechanism is enabled.

you can release the Mode button.

  • Press enter few times to make sure you get the prompt. Now issue following commands to initialize flash and delete files which contains the switch configuration

flash_init
del flash:config.text
del flash:vlan.dat

Th eoutput may look a like following

switch:

switch: del flash:config.text
Are you sure you want to delete "flash:config.text" (y/n)?y
File "flash:config.text" deleted

switch: del flash:vlan.dat
Are you sure you want to delete "flash:vlan.dat" (y/n)?y
File "flash:vlan.dat" not deleted -- no such file or directory

switch:

Once its done, you may continue booting the switch which will allow you to do any configuration of your choice.

boot

This will continue booting the & after a while it will ask you following

Would you like to enter the initial configuration dialog? [yes/no]:

Type no and continue with below ..


Adding IP to default Vlan 1 interface

To add ip use following

en
config t
hostname zaib-switch
interface vlan 1
ip address 101.11.100.1 255.0.0.0
ip default-gateway 101.11.100.255
# Following is important, as vlan1 may be in shut status after ip config, so enable it
no shut
exit
exit
copy running-config startup-config
# When it will ask "Destination filename [startup-config]?" just press ENTER
wr

Connect ethernet cable to the switch port and see the ping result.

ping.PNG

Now you will be able to connect with the switch using IP.

Cisco configuration assistant software is the best GUI tool to configure the switch with ease and it will save you from remembering all the commands. Although command is more powerful in most cases but still GUI is feasible for most beginners.

cisco-network-gui

You can download Cisco Network Assistant and Hyper-Terminal it from my google drive.

https://drive.google.com/drive/folders/0B8B_P2ljEc2xQlpvRUQ2QWVfR0E


TIPS:


General Commands:

Show ALL Interfaces Status

at ENABLE section, use this command to get all ports status

show interfaces status


To show Ip addresses and interface status

show ip interface brief

To show vlan details (via enable mode)

show vlan

Add ENABLE section Password

en
config t
enable secret zaib1234
exit
wr


Reboot Switch

reload


Port is Down/Shutdown / Vlan1 is administratively down, line protocol is down

en
config t
interface vlan 1
no shut


Enable TELNET access

en
config t
line vty 0 15
transport input telnet
password zaibtelnetpass
login
exit
exit
wr


Enable SSH access

*** Set hostname and domain-name
config t
hostname cisco-switch
ip domain-name zaib.com

*** Generate the RSA Keys
crypto key generate rsa
“How many bits in the modulus [512]: 1024”

*** Set Up the Line VTY configurations
transport input ssh
login local
password zaib1234
exit

*** Set the console line
line console 0
logging synchronous
login local

*** Create the username password
config t
username zaib password zaib1234
enable secret zaib1234
service password-encryption


Method#2 – Password Recovery Only:
(While Keeping existing running configuration intact)

  • Connect Hyperterminal with the switch using console cable. [as mentioned in the beginning of this guide]
  • Power ON the switch while pressing mode button, one you see the “The password-recovery mechanism is enabled.”

More example for switch models:

sw-1

Now issue following commands one by one …

flash_init
dir flash:
rename flash:config.text flash:config.old
(The config.text file contains the password)

Now continue the boot process by following command

boot

When you see the following dialogue

Would you like to enter the initial configuration dialog? [yes/no]:

Enter n to abort the initial configuration dialog.

Now rename the config.old file to config.text so that we can get our existing settings restored , and still let us change the password

rename flash:config.old flash:config.text
Press enter when ask for destination file name

Now save the config in running-config so that switch must load all the settings on next boot

copy flash:config.text system:running-config
Press enter when ask for destination file name

Changing Password …

*** Overwrite the existing secret/password

en
conf t
enable secret zaib1234
enable password zaib12345

### Overwrite the existing vty password
line vty 0 15
password zaib1234

### Overwrite the existing console password
line con 0
password zaib1234
exit
exit
copy running-config startup-config
wr
DONE !

Some short notes for Cisco related command [added on 19-OCT-2017]


#SAVE Configuration
copy running-config startup-config
wr

#Enable interface
no shutdown
show ip route

#Reset running configuration

write erase
delete flash:vlan.dat
reload
show vlan br
show ip int brie
#To configure port 24 as TRUNK

enable
configure terminal
interface GigabitEthernet 1/0/1
switchport trunk encapsulation dot1q
switchport mode trunk

*** FIRST Create VLAN

en
conf t
vlan 1
name Default-Vlan
exit
vlan 2
name vlan2-users
exit
vlan 3
name vlan3-users
exit
interface vlan 1
ip address 192.168.254.1 255.255.255.0
interface vlan 2
ip address 192.168.2.1 255.255.255.0
interface vlan 3
ip address 192.168.3.1 255.255.255.0

(If range then use int range f0/1 - 15 )
interface GigabitEthernet 1/0/2
switchport mode access
switchport access vlan 2

interface GigabitEthernet 1/0/3
switchport mode access
switchport access vlan 3

#
en
conf t
show ip route
#OR#
show run | include ip route
ip route 0.0.0.0 0.0.0.0 192.168.254.2
# REMOVE IP ROUTE
en
conf t
no ip route 172.16.100.0 255.255.255.0 192.168.254.2
#---------------------------------------
#remove IP on interface
en
conf t
int vlan X
no ip address
OR
no ip address 192.x.x.x 255.255.255.0
#remove VLAN
en
conf t
no int vlan 24

Backup / Restore switch config from/to TFTP Server

Download any free TFTP Server like Solarwind TFTP , install it to your local Laptop/Desktop. Start it as showed below …

tftp

Make sure that switch and your TFTP can can communicate with each other.

Now from switch issue following command to backup to TFTP server.

copy running-config tftp

It will ask you to enter IP of TFTP server, enter the IP address where TFTP is running, example your Laptop/Desktop where you install the TFTP server.

tftp uploaded.JPG

Switch config file is uploaded successfully & can be viewed in c:\TFTP-Root folder.

To restore this config file to your switch, you can download it from the TFTP using following commands

copy tftp running-config

it will ask for TFTP server IP  & file name, enter details

Address or name of remote host []? 101.11.11.161
Source filename []? switch-confg
Destination filename [running-config]?
Accessing tftp://101.11.11.161/switch-confg...
Loading switch-confg from 101.11.11.161 (via Vlan1): !
[OK - 3946 bytes]

restore from tftp


Enable Logging to Remote SYS LOG server (liek syslog-ng)

login to switch terminal, and issue


logging 101.11.11.240
logging trap informaional

# to test log sending to log server
send log Hello World


Adding NTP client setting in Cisco Switch to synchronize time from external source

enable
configure terminal
ntp server 192.168.100.1
end
show ntp associations

Regard’s
Syed Jahanzaib

Advertisements

2 Comments »

  1. There is any way to recover the password without any configuration loses …?

    Like

    Comment by yssir — November 9, 2016 @ 3:07 AM


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: