Cover | Table of Contents | Colophon
Router1#tftp://172.25.1.1/NEWCONFIG Destination filename [running-config]? <enter> Accessing tftp://172.25.1.1/NEWCONFIG... Loading NEWCONFIG from 172.25.1.1 (via FastEthernet0/0.1): ! [OK - 24 bytes] 24 bytes copied in 0.192 secs (125 bytes/sec) Router1#
172.25.1.1 using TFTP. The router copies the
entire file via TFTP before entering the commands into the running
configuration. This is extremely useful because using some commands
in the middle of a configuration could disrupt your access to the
router—but the rest of the commands might fix the problem. If
you tried to enter them manually using Telnet and configure
terminal
, you would simply lock yourself out of
the router. A typical example of this problem happens when you
replace an active access list. When you enter the first line, the
router puts an implicit deny allFreebsd% /tftpboot/router1-confg Freebsd% /tftpboot/router1-confg Freebsd% Router1 Trying 172.25.1.5... Connected to Router1. Escape character is '^]'. User Access Verification Password: <vtypassword> Router1>en Password: <enablepassword> Router1#tftp://172.25.1.1/router1-confg Address or name of remote host [172.25.1.1]? <enter> Destination filename [router1-confg]? <enter> !!! 9640 bytes copied in 3.956 secs (2437 bytes/sec) Router1#
Router1#configure terminal Enter configuration commands, one per line. End with CNTL/Z. Router1(config)#service config Router1(config)#Network-auto 172.25.1.1 Router1(config)#Router8-auto 172.25.1.1 Router1(config)#end Router1#
Router1#configure terminal Enter configuration commands, one per line. End with CNTL/Z. Router1(config)#service compress-config Router1(config)#end Router1#
Router1#copy running-config startup-config Destination filename [startup-config]? <enter> Building configuration... Compressed configuration from 9664 bytes to 4903 bytes[OK] Router1#
Router1#erase nvram: Erasing the nvram filesystem will remove all files! Continue? [confirm] <enter> [OK] Erase of nvram: complete Router1#reload System configuration has been modified. Save? [yes/no]: no Proceed with reload? [confirm] <enter>
Router1#erase startup-config Erasing the nvram filesystem will remove all files! Continue? [confirm] <enter> [OK] Erase of nvram: complete Router1#reload Proceed with reload? [confirm] <enter>
--- System Configuration Dialog --- Would you like to enter the initial configuration dialog? [yes/no]: no Would you like to terminate autoinstall? [yes]: yes Press RETURN to get started! Router>
Router#show running-config
Building configuration...
Current configuration : 431 bytes
!
version 12.2
service timestamps debug uptime
service timestamps log uptime
no service password-encryption
!
hostname Router
!
!
ip subnet-zero
!
!
!
!
interface Ethernet0
no ip address
shutdown
!
interface Ethernet1
no ip address
shutdown
!
interface Serial0
no ip address
shutdown
!
interface Serial1
no ip address
shutdown
!
ip classless
ip http server
ip pim bidir-enable
!
!
line con 0
line aux 0
line vty 0 4
!
end
Router#Router1#tftp://172.25.1.1/c2600-ik9o3s-mz.122-12a.bin Destination filename [c2600-ik9o3s-mz.122-12a.bin]? <enter> Accessing tftp://172.25.1.1/c2600-ik9o3s-mz.122-12a.bin... Erase flash: before copying? [confirm] <enter> Erasing the flash filesystem will remove all files! Continue? [confirm] <enter> Erasing device... eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee ... erased Erase of flash: complete Loading c2600-ik9o3s-mz.122-12a.bin from 172.25.1.1 (via FastEthernet0/0.1): !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! [OK - 11135588 bytes] Verifying checksum... OK (0xE643) 11135588 bytes copied in 82.236 secs (135410 bytes/sec) Router1# reload Proceed with reload? [confirm] <enter>
Router1#show flash
Router1#configure terminal Enter configuration commands, one per line. End with CNTL/Z. Router1(config)#flash:c3620-jk9o3s-mz.122-7a.bin Router1(config)#flash:c3620-jos56i-l.120-11.bin Router1(config)#slot0:c3620-ik9s-mz.122-13.bin Router1(config)#boot system rom Router1(config)#end
Router1#configure terminal Enter configuration commands, one per line. End with CNTL/Z. Router1(config)#c2500-io-l.122-7a.bin 172.25.1.1 Router1(config)#boot system flash Router1(config)#end Router1#
Freebsd% /tftpboot/c2600-ik9o3s-mz.122-12a.bin Freebsd% /tftpboot/c2600-ik9o3s-mz.122-12a.bin Freebsd% Router1 Trying 172.25.1.5... Connected to Router1. Escape character is '^]'. User Access Verification Password: <vtypassword> Router1>en Password: <enablepassword> Router1#flash:c2600-ik9o3s-mz.122-12a.bin tftp Address or name of remote host [ ]? 172.25.1.1 Destination filename [c2600-ik9o3s-mz.122-12a.bin]? <enter> !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 11135588 bytes copied in 52.588 secs (211752 bytes/sec) Router1#
Router1#copy xmodem: slot1: **** WARNING **** x/ymodem is a slow transfer protocol limited to the current speed settings of the auxiliary/console ports. The use of the auxilary port for this download is strongly recommended. During the course of the download no exec input/output will be available. ---- ******* ---- Proceed? [confirm] <enter> Destination filename [ ]? c3620-ik9s-mz.122-12a.bin Erase slot1: before copying? [confirm] <enter> Use crc block checksumming? [confirm] <enter> Max Retry Count [10]: <enter> Perform image validation checks? [confirm] <enter> Xmodem download using crc checksumming with image validation Continue? [confirm] <enter> Ready to receive file...........CC <start xmodem file transfer here> 4294967295 bytes copied in 1450.848 secs (1271445669961 bytes/sec) Router1#
Router1#erase slot1: Erasing the slot1 filesystem will remove all files! Continue? [confirm] <enter> Erasing device... eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee ...erased Erase of slot1: complete Router1#
Router1#delete slot1:c3620-ik9s-mz.122-13.bin Delete filename [c3620-ik9s-mz.122-13.bin]? <enter> Delete slot1:c3620-ik9s-mz.122-13.bin? [confirm] <enter> Router1#
|
Router type
|
Filesystem type
|
|---|---|
|
7000(RSP)
|
Class A
|
|
7500(RSP2,4, & 8)
|
Class A
|
|
12000
|
Class A
|
|
Route Switch Module (RSM)
|
Router1#configure terminal Enter configuration commands, one per line. End with CNTL/Z. Router1(config)#2 8 8 Router1(config)#end Router1#
Router1#show slot1:
PCMCIA Slot1 flash directory, partition 1:
File Length Name/status
1 7723664 c3620-ajs56i-mz.120-25.bin
[7723728 bytes used, 664880 available, 8388608 total]
8192K bytes of processor board PCMCIA Slot1 flash (Read/Write)
PCMCIA Slot1 flash directory, partition 2:
File Length Name/status
1 7723664 c3620-ajs56i-mz.120-25.bin
[7723728 bytes used, 402736 available, 8126464 total]
8192K bytes of processor board PCMCIA Slot1 flash (Read/Write)
Router1#
Router1#configure terminal Enter configuration commands, one per line. End with CNTL/Z. Router1(config)#flash:c2600-ik9o3s-mz.122-12a.bin Router1(config)#end Router1#
Router1#configure terminal Enter configuration commands, one per line. End with CNTL/Z. Router1(config)#99 Router1(config)#99 Router1(config)#flash:c2600-ik9o3s-mz.122-12a.bin 99 Router1(config)#end
Router1#configure terminal Enter configuration commands, one per line. End with CNTL/Z. Router1(config)#ijbrown Router1(config)#ianpassword Router1(config)#end Router1#copy ftp: running-config Address or name of remote host [172.25.1.1]? 172.25.1.1 Source filename [ ]? test Destination filename [running-config]? <enter> Accessing ftp://172.25.1.1/test... Loading /test [OK - 24/4096 bytes] 24 bytes copied in 0.276 secs (87 bytes/sec) Router1#
Router1#ftp://ijbrown:ianpassword@172.25.1.1/c3620-ik9s-mz.122-10a.bin Destination filename [c3620-ik9s-mz.122-10a.bin]? <enter> Accessing ftp://ijbrown:ianpassword@172.25.1.1/c3620-ik9s-mz.122-10a.bin... Loading pub/c3620-ik9s-mz.122-10a.bin !!!! Erase slot1: before copying? [confirm]
#!/usr/local/bin/perl
#
$template_file_name="rtr-template.txt";
while(<>) {
($location, $name, $lo0ip, $frameip, $framedlci, $eth0ip, $x)
= split (/,/);
open(TFILE, "< $template_file_name") || die "config template file $template_file_name:
$!\n";
$ofile_name = $name . ".txt";
open(OFILE, "> $ofile_name") || die "output config file $ofile_name: $!\n";
while (<TFILE>) {
s/##location##/$location/;
s/##rtrname##/$name/;
s/##eth0-ip##/$eth0ip/;
s/##loop0-ip##/$lo0ip/;
s/##frame-ip##/$frameip/;
s/##frame-DLCI##/$framedlci/;
printf OFILE $_;
}
}
#!/usr/local/bin/expect
#
# rtrcfg.exp -- a script to perform mass configuration changes to
# a list of routers using Telnet and Expect
#
#
# Set Behavior
set tftp "172.25.1.1"
set workingdir /home/cisco/rtr
#
puts stdout "Enter user name:"
gets stdin userid
system stty -echo
puts stdout "Enter login password:"
gets stdin vtypasswd
puts stdout "\nEnter enable password:"
gets stdin enablepwd
system stty echo
system "cp $workingdir/NEWCONFIG /tftpboot/NEWCONFIG"
set RTR [open "$workingdir/RTR_LIST" r]
set LOG [open "$workingdir/RESULT" w]
while {[gets $RTR router] != -1} {
if {[ string range $router 0 0 ] != "#"} {
set timeout 10
spawn telnet; expect "telnet>"; send "open $router\n"
expect {
{Username} { send "$userid\r"
expect {
{*Password*} { send "$vtypasswd\r" }
}
}
{Password} { send "$vtypasswd\r" }
timeout { puts $LOG "$router - telnet failed"
close; wait; continue
}
}
expect {
{Password} { puts $LOG "$router - vty login failed"
close; wait; continue
}
{Username} { puts $LOG "$router - vty login failed"
close; wait; continue
}
{>} { puts $LOG "$router - vty login ok" }
timeout { puts $LOG "$router - vty login failed"
close; wait; continue
}
}
send "enable\r"
expect "Password"
send "$enablepwd\r"
#
expect {
{*#} { puts $LOG "$router - enable login ok" }
{*>} { puts $LOG "$router - enable login failed"
close; wait; continue
}
timeout { puts $LOG "$router - enable login failed"
close; wait; continue
}
}
# CMDs
set timeout 30
send "copy tftp://$tftp/NEWCONFIG running-config\r"
expect "running-config"
send "\r"
expect {
{OK} { puts $LOG "$router - TFTP successful"}
timeout { puts $LOG "$router - TFTP failed"
close; wait; continue }
}
send "copy running-config startup-config\r\r\r"
expect {
{OK} { puts $LOG "$router - config saved"}
timeout { puts $LOG "$router - config failed"
close; wait; continue }
}
#CMDs
send "exit\r"; close; wait
}
}
close $RTR; close $LOG
system "rm /tftpboot/NEWCONFIG"#!/bin/sh
#
# inventory.sh -- a script to extract valuable information
# from a list of routers. (Name, Type, IOS version)
#
#
# Set behaviour
public="ORARO"
workingdir="/home/cisco"
#
LOG=$workingdir/RESULT.csv
infile=$workingdir/RTR_LIST
snmp="/usr/local/bin/snmpget -v1 -c $public"
#
while read device
do
$snmp $device sysName.0 > /dev/null
if [ "$?" = "0" ] ; then
rtr=`$snmp $device .1.3.6.1.4.1.9.2.1.3.0 | cut -f2 -d\" `
type2=`$snmp $device .1.3.6.1.4.1.9.9.25.1.1.1.2.3 | cut -f2 -d$ `
ios=`$snmp $device .1.3.6.1.4.1.9.9.25.1.1.1.2.5 | cut -f2 -d$ `
prot=`$snmp $device .1.3.6.1.4.1.9.9.25.1.1.1.2.4 | cut -f2 -d$ `
echo "$device, $rtr, $type2, $ios, $prot" >> $LOG
fi
done < $infile
#!/usr/local/bin/perl
#
# backup.pl -- a script to automatically backup a list of
# router configuration files on a nightly basis.
#
#
# Set behaviour
$workingdir="/home/cisco/bkup";
$snmprw="ORARW";
$ipaddress="172.25.1.1";
$days="30";
#
#
$rtrlist="$workingdir/RTR_LIST";
$storage="$workingdir/storage";
$latest="$storage/LATEST";
$prev="$storage/PREV";
if (! -d $storage) {mkdir ($storage, 0755)};
if (! -d $prev) {mkdir ($prev, 0755)};
if (! -d $latest) {mkdir ($latest, 0755)};
($sec, $min, $hr, $mday, $mon, $year, @etc) = localtime(time);
$mon++; $year=$year+1900;
$today1=sprintf("%.4d_%.2d_%.2d", $year, $mon, $mday);
$today="$storage/$today1";
system("cp -p $latest/* $prev/");
unlink <$latest/*>;
mkdir ($today, 0755);
open (RTR, "$rtrlist") || die "Can't open $rtrlist file";
open (LOG, ">$workingdir/RESULT") || die "Can't open $workingdir/RESULT file";
print LOG "Router Configuration Backup Report for $year/$mon/$mday\n";
print LOG "= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =\n";
print LOG "Device Name Status\n";
print LOG "= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =\n";
while (<RTR>) {
chomp($rtr="$_");
$oid=".1.3.6.1.4.1.9.2.1.55.$ipaddress";
$snmpset ="/usr/local/bin/snmpset -v1 -c $snmprw -t60 -r2 $rtr";
$rtrfile="/tftpboot/$rtr.cfg";
unlink $rtrfile;
open (CFG, ">$rtrfile"); print CFG " ";close CFG;
chmod 0666, $rtrfile;
chop ($status=`$snmpset $oid s $rtr.cfg`);
$status=~/.+ = "(.+)".*$/;
if($1 eq "$rtr.cfg") {
if( -z "$rtrfile" ) {
$result="not ok (File empty)";
unlink $rtrfile;
}
else {
$result="ok";
chmod 0444, $rtrfile;
system("mv $rtrfile $latest");
}
}
else {
$result="not ok";
unlink $rtrfile;
}
printf LOG ("%-28s %-28s\n", $rtr,$result);
}
system ("cp -p $latest/*cfg $today");
$time=$days*86400;
print "$time\n";
($sec, $min, $hr, $mday, $mon, $year, @etc) = localtime(time-$time);
$mon++; $year=$year+1900;
$rmdir=sprintf("%s/%.4d_%.2d_%.2d",$configs, $year, $mon, $mday);
system ("rm -r -f $storage/$rmdir");Router1#configure terminal Enter configuration commands, one per line. End with CNTL/Z. Router1(config)#rt Router1(config)#on Router1(config)#end Router1#
Router1#configure terminal Enter configuration commands, one per line. End with CNTL/Z. Router1(config)#rt Router1(config)#on Router1(config)#end Router1#
Router1(config)#rt
Router1#rt
Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
* - candidate default, U - per-user static route, o - ODR
P - periodic downloaded static route
Gateway of last resort is 172.25.1.1 to network 0.0.0.0
S 192.168.10.0/24 [1/0] via 172.22.1.4
172.16.0.0/24 is subnetted, 1 subnets
C 172.16.2.0 is directly connected, FastEthernet0/0.2
172.20.0.0/16 is variably subnetted, 3 subnets, 3 masks
O 172.20.10.0/24 [110/74] via 172.20.1.2, 00:52:55, Serial0/0.2
C 172.20.1.0/30 is directly connected, Serial0/0.2
O 172.20.100.1/32 [110/65] via 172.20.1.2, 00:52:55, Serial0/0.2
172.22.0.0/16 is variably subnetted, 2 subnets, 2 masks
D 172.22.0.0/16 is a summary, 20:31:03, Null0
C 172.22.1.0/24 is directly connected, FastEthernet0/1
Router1#Router1#configure terminal Enter configuration commands, one per line. End with CNTL/Z. Router1(config)#Ethernet0 Router1(config-if)#600 Router1(config-if)#end Router1#
Router1#configure terminal Enter configuration commands, one per line. End with CNTL/Z. Router1(config)#100 Router1(config)#200 Router1(config)#50 Router1(config)#50 Router1(config)#end Router1#
Router1#configure terminal Enter configuration commands, one per line. End with CNTL/Z. Router1(config)#Ethernet0 Router1(config)#Ethernet0 Router1(config)#Ethernet0 Router1(config)#Ethernet0 Router1(config)#end Router1#
|
Buffer size
|
|---|
Router1#configure terminal Enter configuration commands, one per line. End with CNTL/Z. Router1(config)#cdp run Router1(config)#Se