Archive

Archive for the ‘Switch’ Category

RANCID for interfaces err-disable

December 30, 2016 Leave a comment

*This script is for RANCID only.

  1. Edit the file /usr/local/rancid/bin/rancid
  2. Add the following line
     	{'show variables boot'		=> 'ShowBoot'},
     	{'show flash'			=> 'ShowFlash'},
     	{'show cdp neighbors detail'	=> 'ShowCDPNeighborsDetail'},
    +	{'show interfaces status err-disabled'	=> 'ShowStatErrDis'},
     	{'dir /all nvram:'		=> 'DirSlotN'},
     	{'dir /all bootflash:'		=> 'DirSlotN'},
     	{'dir /all slot0:'		=> 'DirSlotN'},
  3. Add the sub routine
    # A test routine for parsing the output of "show interfaces status err-disabled"
    +sub ShowStatErrDis {
    +    print STDERR "    In ShowStatErrDis: $_" if ($debug);	
    +
    +    while (<INPUT>) {
    +        tr/\015//d;
    +        last if (/^$prompt/);
    +        next if (/^(\s*|\s*$cmd\s*)$/);
    +        return(1) if /^\s*\^\s*$/;
    +        return(1) if /Line has invalid autocommand /;
    +        return(1) if /(Invalid input detected|Type help or )/;
    +        return(-1) if (/command authorization failed/i);
    +        # the pager can not be disabled per-session on the PIX
    +        if (/^(<-+ More -+>)/) {
    +            my($len) = length($1);
    +            s/^$1\s{$len}//;
    +        }
    +        ProcessHistory("COMMENTS","keysort","IO","!SISED: $_");
    +    }
    +    ProcessHistory("COMMENTS","keysort","IO","!\n");
    +    return(0);
    +}
Advertisements

Cisco 2960 enable routing

November 14, 2014 Leave a comment

1) Enable SDM routing.

Switch(config)#sdm prefer lanbase-routing

2) Save config & reload.
3) Enable IP routing

Switch(config)#ip routing

Categories: Cisco, Switch Tags: ,

Cisco Catalyst Password Reset

October 23, 2014 Leave a comment

In the event that you forgot any remote login password, there is no way to recover the password but there is away to change the password and retail all the configuration.

1) Put the switch in ROMmon state.
2) Initialize the switch with command flash_init
3) Rename the flash:config.text file to flash:config.text.renamed
4) Boot the switch.
5) After rebooting, the switch is back to factory setting, copy the renamed config file to the running config.
6) Amend the remote password, save and reload.

Categories: Cisco, Switch Tags: , ,

RANCID for mass configuration changes

April 21, 2014 Leave a comment

*This script is for RANCID only.

1) mkdir device-lists in rancid homedir.
2) create a file with list of devices (one per line), save the file as syslog-changes.dl into device-lists folder.
3) mkdir change-scripts in rancid homedir.
4) create a file with the changes (as the way you type them in switches), save the file as syslog-changes.cs into change-scripts folder.
5) create a file config-push.sh and save it into etc folder under rancid homedir.
6) copy and paste the following scripts into the file config-push.sh that you had created on step 5.
7) command to test the script, sh config-push.sh

#!/usr/local/bin/bash
#
# The purpose of this script is to automate configuration changes to a
# large number of devices. The script identifies the device list, as well
# as the change script, and then pushes the changes one by one.
#

CLOGINPATH=”/usr/local/rancid/bin/clogin” 
CREDENTIALS=”/usr/local/rancid/.cloginrc” 
DEVICELISTPATH=”/usr/local/rancid/device-lists/” 
CHANGESCRIPTPATH=”/usr/local/rancid/change-scripts/” 
CHANGELOG=”/usr/local/rancid/var/logs/changelog-`date +%m-%d-%Y`.log” 

clear 
echo “=====[ Rancid Config Push Script ]=====” 
echo “” 
echo “Please enter the proposed device list:” 
echo “`ls $DEVICELISTPATH`” 
echo “————————————–” 
echo -n “> ” 
read DEVICELIST 

if [ -f $DEVICELISTPATH$DEVICELIST ] 
then 
echo “” 
echo “Device List = \”./device-lists/$DEVICELIST\” (confirmed)” 
else 
echo “” 
echo “Device list = \”./device-lists/$DEVICELIST\” (does not exist!)” 
echo “Aborting…” 
echo “” 
exit 
fi 

echo “” 
echo “Please enter name of change script:” 
echo “`ls $CHANGESCRIPTPATH | grep -v “.sh” | grep -v “device-lists”`” 
echo “———————————–” 
echo -n “> ” 
read CHANGESCRIPT 

if [ -f $CHANGESCRIPTPATH$CHANGESCRIPT ] 
then 
echo “” 
echo “Change Script = \”./change-scripts/$CHANGESCRIPT\” (confirmed)” 
echo “” 
else 
echo “Device list = \”./change-scripts/$CHANGESCRIPT\” (does not exist!)” 
echo “Aborting…” 
echo “” 
exit 
fi 

echo “– Proposed Changes –” 
echo “`cat $CHANGESCRIPTPATH$CHANGESCRIPT`” 
echo “– Proposed Changes –” 
echo “” 
echo “Are you sure you want to proceed? If so, type \”yes\”:” 
echo -n “> ” 
read AREYOUSURE 

if [ $AREYOUSURE != “yes” ] 
then 
echo “” 
echo “Aborting…” 
echo “” 
exit 
else 
echo “” 
echo “Implementing Changes…” 
echo “” 
fi 

#for i in `cat $DEVICELISTPATH$DEVICELIST` 
# do echo “===[ $i ]===”
# $CLOGINPATH -f $CREDENTIALS -x $CHANGESCRIPTPATH$CHANGESCRIPT $i
#done 

for DEVICE in `cat $DEVICELISTPATH$DEVICELIST` 
do 
echo “===[ $DEVICE ]===” 
echo “” >> $CHANGELOG 
echo “===[ $DEVICE ]===” >> $CHANGELOG 
echo “” >> $CHANGELOG 
OUTPUT=`$CLOGINPATH -f $CREDENTIALS -x $CHANGESCRIPTPATH$CHANGESCRIPT $DEVICE` 
echo “$OUTPUT” >> $CHANGELOG 
done 

Categories: Cisco, Linux, Switch Tags: , ,

Cisco switch test cable distance

March 4, 2014 Leave a comment

Command to test cable length that is connected to Cisco switch.

Cisco-Switch# test cable-diagnostics tdr interface [interface-number]
Cisco-Switch# show cable-diagnostics tdr interface [interface-number]

The command above not only shows connected device to the switch port, it also calculate open end cable that is connected to switch port.

Categories: Cisco, Switch Tags: , , ,

Trap console message on terminal

October 25, 2013 Leave a comment

To view live console message on terminal (SSH or telnet session)

Cisco-switch# terminal monitor

The command above is only active per terminal session, once you exit the terminal session the command will be deactivate.

Categories: Cisco, Switch Tags: , , , ,

ARP Caching issue

April 3, 2013 Leave a comment

Issue: Replace existing static IP device with brand new and used back exiting static IP. Unable to ping to the new device.

Solution: Clear the arp cache from the core switch.

Example: cisco# clear ip arp <IP>

Categories: Cisco, Switch Tags: ,