Diferència entre revisions de la pàgina «A4. Transferència d'arxius»
(→Configurar el servidor TFTP a Ubuntu) |
(→Guardar/Restaurar configuració.) |
||
(Hi ha 12 revisions intermèdies del mateix usuari que no es mostren) | |||
Línia 2: | Línia 2: | ||
− | + | = Transferència d'arxius = | |
Línia 17: | Línia 17: | ||
− | === Reiniciar configuració | + | == Operacions Sistema d'arxius == |
+ | |||
+ | Es poden llistar els directoris dins les diferents memòries amb la comanda '''dir'''. | ||
+ | |||
+ | <html><pre><code class="cisco"> | ||
+ | Router#dir ? | ||
+ | WORD Directory or file name | ||
+ | flash0: Directory or file name | ||
+ | flash1: Directory or file name | ||
+ | flash: Directory or file name | ||
+ | nvram: Directory or file name | ||
+ | <cr> | ||
+ | Router#dir flash: | ||
+ | Directory of flash0:/ | ||
+ | |||
+ | 3 -rw- 33591768 <no date> c1900-universalk9-mz.SPA.151-4.M4.bin | ||
+ | 2 -rw- 28282 <no date> sigdef-category.xml | ||
+ | 1 -rw- 227537 <no date> sigdef-default.xml | ||
+ | |||
+ | 255744000 bytes total (221896413 bytes free) | ||
+ | </code></pre></html> | ||
+ | |||
+ | |||
+ | Es poden crear directoris '''mkdir''' i esborrar-los '''rmdir'''. | ||
+ | |||
+ | Copiar arxius amb l'ordre '''copy''', i esborrar-los fent servir l'ordre '''delete''' indicant la memòria on s'ubica l'arxiu. | ||
+ | |||
+ | <html><pre><code class="cisco"> | ||
+ | Router#delete flash:c1900-universalk9-mz.SPA.151-4.M4.bin | ||
+ | Delete filename [c1900-universalk9-mz.SPA.151-4.M4.bin]? | ||
+ | Delete flash:/c1900-universalk9-mz.SPA.151-4.M4.bin? [confirm] | ||
+ | </code></pre></html> | ||
+ | |||
+ | |||
+ | == Reiniciar configuració == | ||
La configuració inicial es troba a la memòria nvram, només cal esborrar-la. | La configuració inicial es troba a la memòria nvram, només cal esborrar-la. | ||
− | <pre> | + | <html><pre><code class="cisco"> |
− | Router# | + | Router#dir nvram: |
− | + | Directory of nvram:/ | |
− | + | ||
+ | 238 -rw- 578 <no date> startup-config | ||
+ | |||
+ | 578 bytes total (237588 bytes free) | ||
+ | |||
+ | Router#erase startup-config | ||
+ | Erasing the nvram filesystem will remove all configuration files! Continue? [confirm] | ||
[OK] | [OK] | ||
− | Router# | + | Erase of nvram: complete |
+ | %SYS-7-NV_BLOCK_INIT: Initialized the geometry of nvram | ||
+ | Router#dir nvram: | ||
+ | Directory of nvram:/ | ||
+ | |||
+ | No files in directory | ||
+ | |||
Router# | Router# | ||
Router#reload | Router#reload | ||
Proceed with reload? [confirm] | Proceed with reload? [confirm] | ||
− | </pre> | + | </code></pre></html> |
− | + | ||
+ | == Configurar el servidor TFTP a Ubuntu == | ||
http://www.davidsudjiman.info/2006/03/27/installing-and-setting-tftpd-in-ubuntu/ | http://www.davidsudjiman.info/2006/03/27/installing-and-setting-tftpd-in-ubuntu/ | ||
Línia 38: | Línia 85: | ||
Es pot comprovar si funciona fent | Es pot comprovar si funciona fent | ||
− | <pre> | + | <html><pre><code class="cisco"> |
$netstat -l -udp | $netstat -l -udp | ||
(Not all processes could be identified, non-owned process info | (Not all processes could be identified, non-owned process info | ||
Línia 48: | Línia 95: | ||
udp 0 0 *:tftp *:*- | udp 0 0 *:tftp *:*- | ||
udp 0 0 *:mdns *:*- | udp 0 0 *:mdns *:*- | ||
− | </pre> | + | </code></pre></html> |
− | + | == Guardar/Restaurar configuració. == | |
Configurar IP de la mateixa xarxa que el servidor TFTP | Configurar IP de la mateixa xarxa que el servidor TFTP | ||
+ | |||
+ | <html><pre><code class="cisco"> | ||
Router(config)#interface FastEthernet 0 | Router(config)#interface FastEthernet 0 | ||
Router(config-if)#ip address 192.168.2.7 255.255.255.0 | Router(config-if)#ip address 192.168.2.7 255.255.255.0 | ||
Línia 62: | Línia 111: | ||
Interface IP-Address OK? Method Status Prol | Interface IP-Address OK? Method Status Prol | ||
FastEthernet0 192.168.2.7 YES manual up up | FastEthernet0 192.168.2.7 YES manual up up | ||
+ | </code></pre></html> | ||
+ | |||
Per guardar la configuració | Per guardar la configuració | ||
+ | |||
+ | <html><pre><code class="cisco"> | ||
Router#copy running-config tftp | Router#copy running-config tftp | ||
Address or name of remote host []? 192.168.2.40 | Address or name of remote host []? 192.168.2.40 | ||
Línia 69: | Línia 122: | ||
.!! | .!! | ||
1453 bytes copied in 8.332 secs (174 bytes/sec) | 1453 bytes copied in 8.332 secs (174 bytes/sec) | ||
− | + | </code></pre></html> | |
Per restaurar la configuració (Cal que el fitxer de configuració estigui a la carpeta del tftp, amb permisos suficients 777) | Per restaurar la configuració (Cal que el fitxer de configuració estigui a la carpeta del tftp, amb permisos suficients 777) | ||
+ | <html><pre><code class="cisco"> | ||
Router#copy tftp running-config | Router#copy tftp running-config | ||
Address or name of remote host [192.168.2.40]? | Address or name of remote host [192.168.2.40]? | ||
Línia 84: | Línia 138: | ||
1453 bytes copied in 10.468 secs (139 bytes/sec) | 1453 bytes copied in 10.468 secs (139 bytes/sec) | ||
Router# | Router# | ||
− | + | </code></pre></html> | |
− | |||
− | + | == Guardar/Restaurar l'IOS == | |
Línia 93: | Línia 146: | ||
− | + | <html><pre><code class="cisco"> | |
Router#dir flash: | Router#dir flash: | ||
Directory of flash:/ | Directory of flash:/ | ||
Línia 118: | Línia 171: | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
13672808 bytes copied in 60.828 secs (224778 bytes/sec) | 13672808 bytes copied in 60.828 secs (224778 bytes/sec) | ||
+ | |||
+ | </code></pre></html> | ||
− | + | = Mode Monitor = | |
− | El mode monitor de ROM és un estat en que arrenca el | + | El mode monitor de ROM és un estat en que arrenca el Router si no disposa de IOS o existeix algun error que no permet carregar-lo (s'ha cancel·lat la càrrega d'aquest per exemple). |
− | |||
Aquest mode té un conjunt senzill de comandes que permeten recuperar el IOS, establir comunicacions TFTP o canviar el registre del router i restablir contrasenyes per exemple. | Aquest mode té un conjunt senzill de comandes que permeten recuperar el IOS, establir comunicacions TFTP o canviar el registre del router i restablir contrasenyes per exemple. | ||
+ | Es pot forçar entrar en mode monitor enviant '''CTRL + BREAK''' durant la càrrega inicial (CTRL + SHIFT + BREAK + C, al Packet Tracer 5.3). | ||
− | + | <html><pre><code class="cisco"> | |
+ | rommon 1> | ||
+ | </code></pre></html> | ||
− | + | == Restaurar IOS == | |
− | |||
− | |||
− | |||
− | == | ||
+ | Primerament cal configurar la comunicació amb el servidor TFTP per poder descarregar l'arxiu | ||
+ | <html><pre><code class="cisco"> | ||
/* Aquesta és l’adreça que s’assignarà a la interfase del router */ | /* Aquesta és l’adreça que s’assignarà a la interfase del router */ | ||
rommon 1> IP_ADDRESS=192.168.1.2 | rommon 1> IP_ADDRESS=192.168.1.2 | ||
− | |||
rommon 2> IP_SUBNET_MASK=255.255.255.0 | rommon 2> IP_SUBNET_MASK=255.255.255.0 | ||
Línia 149: | Línia 203: | ||
rommon 3> DEFAULT_GATEWAY=192.168.1.10 | rommon 3> DEFAULT_GATEWAY=192.168.1.10 | ||
− | |||
rommon 4> TFTP_SERVER=192.168.1.10 | rommon 4> TFTP_SERVER=192.168.1.10 | ||
− | |||
− | |||
rommon 5> TFTP_FILE=c1700-y-mz.122-2.XJ.BIN | rommon 5> TFTP_FILE=c1700-y-mz.122-2.XJ.BIN | ||
Línia 158: | Línia 209: | ||
rommon 6> tftpdnld | rommon 6> tftpdnld | ||
− | |||
rommon 7> reset | rommon 7> reset | ||
+ | </code></pre></html> | ||
− | + | == Restaurar contrasenya == | |
Cal modificar el registre del Router (normalment en valors 0x2102 o 0x10) per desactivar la càrrega de la configuració a l'inici ( 0x2142) | Cal modificar el registre del Router (normalment en valors 0x2102 o 0x10) per desactivar la càrrega de la configuració a l'inici ( 0x2142) | ||
+ | <html><pre><code class="cisco"> | ||
rommon 1> confreg 0x2142 | rommon 1> confreg 0x2142 | ||
+ | rommon 2> reset | ||
+ | </code></pre></html> | ||
− | |||
− | Modifica l’arxiu de configuració com has realitzat a les activitats anteriors i torna a posar el valor del registre inicial | + | Modifica l’arxiu de configuració com has realitzat a les activitats anteriors i torna a posar el valor del registre inicial. Guarda els canvis en la configuració a l’arxiu de configuració inicial |
+ | |||
+ | <html><pre><code class="cisco"> | ||
router1# config-register 0x2102 | router1# config-register 0x2102 | ||
+ | router1# copy running-config startup-config | ||
+ | </code></pre></html> | ||
− | |||
− | + | ||
+ | == Restaurar contrasenya (Switch) == | ||
+ | |||
+ | En els switchs 2950 Series es pot entrar mode switch: presionant "mode" mentre s'encèn | ||
+ | |||
+ | <html><pre><code class="cisco"> | ||
+ | switch: flash_init | ||
+ | switch: load_helper | ||
+ | switch: delete flash:config.text | ||
+ | switch: boot | ||
+ | </code></pre></html> | ||
+ | |||
+ | (Això no està disponible des del Packet Tracer) | ||
+ | |||
+ | |||
+ | |||
+ | == Carregar imatge IOS (Switch) == | ||
+ | |||
+ | |||
+ | La càrrega en aquest cas s'ha de fer per la connexió de consola i és molt lenta | ||
+ | |||
+ | <html><pre><code class="cisco"> | ||
+ | switch: flash_init | ||
+ | switch: load_helper | ||
+ | switch: copy xmodem: flash:c2955-i6q4l2-mz.121-13.EA1.bin | ||
+ | Begin the Xmodem or Xmodem-1K transfer now... | ||
+ | CCCCCCC......................................................................... | ||
+ | ................................................................................ | ||
+ | ................................................................................ | ||
+ | ................................................................................ | ||
+ | ................................................................................ | ||
+ | ................................................................................ | ||
+ | ................................................................................ | ||
+ | ................................................................................ | ||
+ | ............................................................................. | ||
+ | File "xmodem:" successfully copied to "flash:c2955-i6q4l2-mz.121-13.EA1.bin" | ||
+ | |||
+ | !--- If the Xmodem file transfer fails for some reason, restart the process. | ||
+ | !--- If the Xmodem file transfer is successful, you return to the | ||
+ | !--- switch: prompt. | ||
+ | switch: | ||
+ | switch: boot flash:c2955-i6q4l2-mz.121-13.EA1.bin | ||
+ | </code></pre></html> | ||
+ | |||
+ | |||
+ | (Això no està disponible des del Packet Tracer) |
Revisió de 21:00, 18 gen 2025
torna M7 - Planificació i administració de xarxes
Contingut
Transferència d'arxius
Per transferir arxius entre els dispositius (CISCO) i un ordinador es fa servir el protocol TFTP. Aquest és un protocol lleuger, semblant al FTP que funciona sobre el port 69 UDP.
Les principals utilitats són:
- Guardar / Restaurar la configuració
- Actualitzar IOS
- Guardar / Restaurar IOS (Sistema Operatiu)
Els exemples es basen en el IOS d'un CISCO de la sèrie 1700 (Router).
Operacions Sistema d'arxius
Es poden llistar els directoris dins les diferents memòries amb la comanda dir.
Router#dir ?
WORD Directory or file name
flash0: Directory or file name
flash1: Directory or file name
flash: Directory or file name
nvram: Directory or file name
Router#dir flash:
Directory of flash0:/
3 -rw- 33591768 c1900-universalk9-mz.SPA.151-4.M4.bin
2 -rw- 28282 sigdef-category.xml
1 -rw- 227537 sigdef-default.xml
255744000 bytes total (221896413 bytes free)
Es poden crear directoris mkdir i esborrar-los rmdir.
Copiar arxius amb l'ordre copy, i esborrar-los fent servir l'ordre delete indicant la memòria on s'ubica l'arxiu.
Router#delete flash:c1900-universalk9-mz.SPA.151-4.M4.bin
Delete filename [c1900-universalk9-mz.SPA.151-4.M4.bin]?
Delete flash:/c1900-universalk9-mz.SPA.151-4.M4.bin? [confirm]
Reiniciar configuració
La configuració inicial es troba a la memòria nvram, només cal esborrar-la.
Router#dir nvram:
Directory of nvram:/
238 -rw- 578 startup-config
578 bytes total (237588 bytes free)
Router#erase startup-config
Erasing the nvram filesystem will remove all configuration files! Continue? [confirm]
[OK]
Erase of nvram: complete
%SYS-7-NV_BLOCK_INIT: Initialized the geometry of nvram
Router#dir nvram:
Directory of nvram:/
No files in directory
Router#
Router#reload
Proceed with reload? [confirm]
Configurar el servidor TFTP a Ubuntu
http://www.davidsudjiman.info/2006/03/27/installing-and-setting-tftpd-in-ubuntu/
Es pot comprovar si funciona fent
$netstat -l -udp
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address StatePID/Program name
udp 0 0 *:59450 *:*-
udp 0 0 *:bootpc *:*-
udp 0 0 *:tftp *:*-
udp 0 0 *:mdns *:*-
Guardar/Restaurar configuració.
Configurar IP de la mateixa xarxa que el servidor TFTP
Router(config)#interface FastEthernet 0
Router(config-if)#ip address 192.168.2.7 255.255.255.0
Router(config-if)#no shut
Router(config-if)#no shutdown
Router(config-if)#exit
Router(config)#exit
Router#show ip interface brief
Interface IP-Address OK? Method Status Prol
FastEthernet0 192.168.2.7 YES manual up up
Per guardar la configuració
Router#copy running-config tftp
Address or name of remote host []? 192.168.2.40
Destination filename [router-confg]? running-config
.!!
1453 bytes copied in 8.332 secs (174 bytes/sec)
Per restaurar la configuració (Cal que el fitxer de configuració estigui a la carpeta del tftp, amb permisos suficients 777)
Router#copy tftp running-config
Address or name of remote host [192.168.2.40]?
Source filename [running-config]?
Destination filename [running-config]?
Accessing tftp://192.168.2.40/running-config...
Loading running-config from 192.168.2.40 (via FastEthernet0): !
[OK - 1453 bytes]
1453 bytes copied in 10.468 secs (139 bytes/sec)
Router#
Guardar/Restaurar l'IOS
El IOS es guarda en la part de la memòria del Router anomenada FLASH
Router#dir flash:
Directory of flash:/
1 -rw- 13672808 c1700.bin
33292284 bytes total (19619412 bytes free)
Router#copy flash: tftp
Router#copy flash: tftp:
Router#copy flash: tftp
Source filename []?
?File name not specified
%Error parsing filename (No such file or directory)
Router#dir flash:
Directory of flash:/
1 -rw- 13672808 c1700.bin
33292284 bytes total (19619412 bytes free)
Router#copy flash: tftp
Source filename []? c1700.bin
Address or name of remote host []? 192.168.2.40
Destination filename [c1700.bin]?
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
13672808 bytes copied in 60.828 secs (224778 bytes/sec)
Mode Monitor
El mode monitor de ROM és un estat en que arrenca el Router si no disposa de IOS o existeix algun error que no permet carregar-lo (s'ha cancel·lat la càrrega d'aquest per exemple).
Aquest mode té un conjunt senzill de comandes que permeten recuperar el IOS, establir comunicacions TFTP o canviar el registre del router i restablir contrasenyes per exemple.
Es pot forçar entrar en mode monitor enviant CTRL + BREAK durant la càrrega inicial (CTRL + SHIFT + BREAK + C, al Packet Tracer 5.3).
rommon 1>
Restaurar IOS
Primerament cal configurar la comunicació amb el servidor TFTP per poder descarregar l'arxiu
/* Aquesta és l’adreça que s’assignarà a la interfase del router */
rommon 1> IP_ADDRESS=192.168.1.2
rommon 2> IP_SUBNET_MASK=255.255.255.0
/* Aquesta és la informació del servidor TFTP */
rommon 3> DEFAULT_GATEWAY=192.168.1.10
rommon 4> TFTP_SERVER=192.168.1.10
rommon 5> TFTP_FILE=c1700-y-mz.122-2.XJ.BIN
/* Executa la descàrrega i reinicia*/
rommon 6> tftpdnld
rommon 7> reset
Restaurar contrasenya
Cal modificar el registre del Router (normalment en valors 0x2102 o 0x10) per desactivar la càrrega de la configuració a l'inici ( 0x2142)
rommon 1> confreg 0x2142
rommon 2> reset
Modifica l’arxiu de configuració com has realitzat a les activitats anteriors i torna a posar el valor del registre inicial. Guarda els canvis en la configuració a l’arxiu de configuració inicial
router1# config-register 0x2102
router1# copy running-config startup-config
Restaurar contrasenya (Switch)
En els switchs 2950 Series es pot entrar mode switch: presionant "mode" mentre s'encèn
switch: flash_init
switch: load_helper
switch: delete flash:config.text
switch: boot
(Això no està disponible des del Packet Tracer)
Carregar imatge IOS (Switch)
La càrrega en aquest cas s'ha de fer per la connexió de consola i és molt lenta
switch: flash_init
switch: load_helper
switch: copy xmodem: flash:c2955-i6q4l2-mz.121-13.EA1.bin
Begin the Xmodem or Xmodem-1K transfer now...
CCCCCCC.........................................................................
................................................................................
................................................................................
................................................................................
................................................................................
................................................................................
................................................................................
................................................................................
.............................................................................
File "xmodem:" successfully copied to "flash:c2955-i6q4l2-mz.121-13.EA1.bin"
!--- If the Xmodem file transfer fails for some reason, restart the process.
!--- If the Xmodem file transfer is successful, you return to the
!--- switch: prompt.
switch:
switch: boot flash:c2955-i6q4l2-mz.121-13.EA1.bin
(Això no està disponible des del Packet Tracer)