Boje z „apgrejdem” IOS :)
Chciałem wgrać inny ios na router 2651. Więc skasowałem stary i chciałem pobrać jak to się robi najzwyczajniej w świecie z tftp. I bach…buba czy jak tam zwał, pobrać się pobrało lecz nie zapisało i tak w kółko. Z drżącymi rękoma, po kilku nie udanych próbach wpisałem reload. Zrestartował się router i … no właśnie nie odnalazł‚ iosa bo w sumie jak mógł go znaleść skoro sam go wykasowałem
Router gdy nie znalazł iosa i oświadczył to :
device does not contain a valid magic number
boot: cannot open "flash:"
boot: cannot determine first file name on device "flash:"
przeskoczył w tryb ROMMON czyli czekało mnie ręczne wklepanie potrzebnych danych do ściągnięcia iosa z tftp. No to siup, po kolei mozolnie sobie wbijałem :
rommon 1 > IP_ADDRESS=1.1.1.1
rommon 2 > IP_SUBNET_MASK=255.255.255.252
rommon 3 > DEFAULT_GATEWAY=1.1.1.2
rommon 4 > TFTP_SERVER=1.1.1.2
rommon 5 > TFTP_FILE=c2600-is-mz.122-4.T1.bin
rommon 6 > tftpdnld
IP_ADDRESS: 1.1.1.1
IP_SUBNET_MASK: 255.255.255.252
DEFAULT_GATEWAY: 1.1.1.2
TFTP_SERVER: 1.1.1.2
TFTP_FILE: c2600-is-mz.122-4.T1.bin
Invoke this command for disaster recovery only.
WARNING: all existing data in all partitions on flash will be lost!
Do you wish to continue? y/n: [n]: y
....
ARP: address resolution for 1.1.1.2 timed out.
ARP failed with failure code 1. TFTP transfer aborted.
Nosz kurka wodna nadal nie można załadować iosa a w dodatku coś nie odpowiada z ARP.
Dopisanie dwóch magicznych linijek jednak rozwiązało problem :
rommon 16 > TFTP_RETRY_COUNT=20
rommon 17 > TFTP_VERBOSE=2
rommon 18 > tftpdnld
IP_ADDRESS: 1.1.1.1
IP_SUBNET_MASK: 255.255.255.252
DEFAULT_GATEWAY: 1.1.1.2
TFTP_SERVER: 1.1.1.2
TFTP_FILE: c2600-is-mz.122-4.T1.bin
Invoke this command for disaster recovery only.
WARNING: all existing data in all partitions on flash will be lost!
Do you wish to continue? y/n: [n]: y
Performing tftpdnld over Fast Enet.
Interface is operating at: 100Mbps/FULL DUPLEX
Initializing interface.
Interface link state down.
Interface link state up.
ARPing for 1.1.1.2
ARPing for 1.1.1.2
ARPing for 1.1.1.2.
ARPing for 1.1.1.2
ARPing for 1.1.1.2
ARPing for 1.1.1.2.
ARPing for 1.1.1.2
ARPing for 1.1.1.2.
ARPing for 1.1.1.2
ARPing for 1.1.1.2
ARPing for 1.1.1.2.
ARP reply for 1.1.1.2 received. MAC address 4c:00:10:7b:05:18
Receiving c2600-is-mz.122-4.T1.bin from 1.1.1.2 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
File reception completed.
TFTP flash copy: Error, image size (11451328) mismatches netsize (7128460).
No normalnie przegięcie dalej coś nie tak. Znów się przyczepił, że nie może zapisać do flasha wrr. Przypomniało mi się, że w ROMMON istnieje tryb uprzywilejowany wywoływany poleceniem priv, tyle że pyta o hasło. No, ale hasło można na szczęście znaleźć wpisujac magiczna komende cookie :
> cookie
cookie:
01 01 00 07 0e 80 7d 00 43 20 80 ff 01 c0 00 20
00 00 00 00 00 00 00 00 4a 41 42 05 34 30 46 50
45 02 00 00 00 00 00 00 00 ff ff ff 58 06 49 12
1e 04 ff ff ff ff ff ff ff ff ff ff ff ff ff ff
ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
Gdy już mamy ten HEXaciąg to interesuje nas pierwsze pięć liczb hexadecymalnych czyli :
01 01 00 07 0e 80 7d 00 43 20
i dodajemy sobie je według wzoru :
password = w1 + w2 + w3 + w4 w5 + mod 2 do 16
gdzie W1 – W5 są pierwsze 5 wyrażeń w pliku cookie. 2 do 16 = 65536 = 0x10000.
Lub kopiujemy całą linijkę i wklejamy do tego "kalkulatora"
Wreszcie uzyskałem moje magiczne hasło a brzmi ono : cfa8
rommon 18 > priv
Password: cfa8
You now have access to the full set of monitor commands.
Warning: some commands will allow you to destroy your
configuration and/or system images and could render
the machine unbootable.
rommon 19 > ?
addrloop walk 1 thru range of addresses
alias set and display aliases command
alter alter locations in memory
berrscan scan range of addresses for bus errors
boot boot up an external process
break set/show/clear the breakpoint
call call a subroutine at address with converted hex args
cat concatenate files
checksum checksum a block of memory
clrerr clear the error log
compare compare two blocks of memory
confreg configuration register utility
cont continue executing a downloaded image
context display the context of a loaded image
cookie display contents of cookie PROM in hex
cpu cpu / system information and control
dev list the device table
dir list files in file system
dis display instruction stream
dnld serial download a program module
dump display a block of memory
echo monitor echo command
errlog display the error log
fdump file dump utility
fill fill a block of memory
flash flash services command
frame print out a selected stack frame
help monitor builtin command help
history monitor command history
ifill fill a block of memory w/incrementing pattern
initfs re-initialize the file system access structures
isp print version and checksum of ISP part
jump call a subroutine at address with argc/argv
launch launch a downloaded image
leds check out the error LED
memdebug write/read/verify scope loop
meminfo main memory information
memloop write or read scope loop
memtest simple memory test
menu main diagnostic menu
move move a block of memory
repeat repeat a monitor command
reset system reset
set display the monitor variables
sleep millisecond sleep command
speed timed performance loop
stack produce a stack trace
sync write monitor environment to NVRAM
sysret print out info from last system return
tcal timer calibration test
tftpdnld tftp image download
tscope timer scope loop
unalias unset an alias
unset unset a monitor variable
watchdog test watchdog rebooting of the box
xmodem x/ymodem image download
Mnie interesowały testy sprzętu więc wybrałem :
> menu
Main Diagnostic Menu
a: alter diag flags
b: basic utilities
c: do all diags in this menu
d: do group of diags in this menu
e: bus error test
f: monitor image checksum test
g: internal interrupt test
h: ip state test
i: timer interrupt test
j: size main memory
k: main memory test
l: main memory refresh test
m: flash memory test
n: aux loopback test
o: aux port interrupt test
p: serial cookie test
q: data cache test
r: mpc860 test
s: nvram test
t: pci bridge test
x: return to previous menu
FLAGS: Continuous OFF Stop on error OFF Loop on error OFF Quiet mode OFF
a później :
enter Main Diagnostic Menu item > c
bus error test completed, ... 0 errors
monitor image checksum test completed, ... 0 errors
internal interrupt test completed, ... 0 errors
ip state test completed, ... 0 errors
timer interrupt test completed, ... 0 errors
size main memory test completed, ... 0 errors, found 32 mb
main memory test completed, ... 0 errors
main memory refresh test completed, ... 0 errors
flash memory test completed, ... 0 errors
Polled AUX loopback test
*** Fatal error during Polled AUX loopback test,
Timeout on receive of first char - make sure loopback adaptor is installed
Interrupt driven AUX loopback test
*** Fatal error during Interrupt driven AUX loopback test,
Timeout on receive of first char - make sure loopback adaptor is installed
serial cookie test completed, ... 0 errors
cache burst test completed, ... 0 errors
mpc860 test completed, ... 0 errors
NVRAM test completed, ... 0 errors, found 32 KB
xilinx test completed, ... 0 errors
2 total accumulated errors
No jak widać z flaszem wszsytko ok, czego o AUX nie można powiedzieć. Zastanowiło mnie to. Spróbowałem wgrać ios który był wcześniej :
> tftpdnld
IP_ADDRESS: 1.1.1.1
IP_SUBNET_MASK: 255.255.255.252
DEFAULT_GATEWAY: 1.1.1.2
TFTP_SERVER: 1.1.1.2
TFTP_FILE: c2600-io3-mz.123-13.bin
Invoke this command for disaster recovery only.
WARNING: all existing data in all partitions on flash will be lost!
Do you wish to continue? y/n: [n]: Y
Do you wish to continue? y/n: [n]: y
Performing tftpdnld over Fast Enet.
Interface is operating at: 100Mbps/FULL DUPLEX
Initializing interface.
Interface link state down.
Interface link state up.
ARPing for 1.1.1.2
ARPing for 1.1.1.2
ARPing for 1.1.1.2.
ARPing for 1.1.1.2
ARPing for 1.1.1.2
ARPing for 1.1.1.2.
ARPing for 1.1.1.2
ARPing for 1.1.1.2.
ARPing for 1.1.1.2
ARPing for 1.1.1.2
ARPing for 1.1.1.2.
ARP reply for 1.1.1.2 received. MAC address 4c:00:10:7b:05:18
Receiving c2600-io3-mz.123-13.bin from 1.1.1.2 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
File reception completed.
Copying file c2600-io3-mz.123-13.bin to flash.
Erasing flash at 0x607c0000
program flash location 0x607a0000
rommon 11 > reset
I po resecie wszystko zatrybiło i działa. Hmm szczerze już nie chce mi się wnikać dlaczego, jest to w sumie router do labów, a nie na produkcji więc jakoś nie zależy mi na zmianie iosa, chociaż z drugiej strony jakbym miał kilka dostepnych obrazów innych iosów to bym spróbować. No cóż to koniec mych zmagań ze zmianą iosa, którego w sumie nie zmieniłem