最後更新日期: 2004.12.21

FreeBSD上使用tftpd 備份 cisco 路由器的設定檔

Description :

在 FreeBSD 下,使用 tftpd 保存 cisco 路由器的配置檔及cisco
路由器的 IOS 作業系統, FreeBSD 下配置狀況如下:

Environment :

作業系統: FreeBSD 5.3 Release
假設 FreeBSD Server IP:88.88.88.88

Setp 1.

修改 #vi /etc/inetd.conf 將有 tftp 的這行注解去掉
 
#tftp    dgram   udp     wait    root    /usr/libexec/tftpd      tftpd -l -s /tftpboot
tftp    dgram   udp     wait    root    /usr/libexec/tftpd      tftpd -l -s /tftpboot

Setp 2.

建立 /tftpboot目錄及文件,修改權限,要從 Cisco Router 裡 copy runing-config tftp: 必需於 FreeBSD 上先建立文件檔名,之後修改文件的權限為 -rw-rw-rw-,否則不能建立備份文件。
 
#mkdir /tftpboot
#cd /tftpboot
#touch cisco-config
#touch cisco-is-mz.122-2.T.bin
#chmod 666 cisco-config
#chmod 666 cisco-is-mz.122-2.T.bin

#ls -l cisco-config

-rw-rw-rw- 1 root wheel 0 Dec 1 14:42 cisco-config
-rw-rw-rw- 1 root wheel 0 Dec 1 14:42 cisco-is-mz.122-2.T.bin

Setp 3.

修改 #vi /etc/rc.conf 讓 tftp service 開機自動啟動

inetd_enable="YES"

#/usr/sbin/inetd      #  手動啟動 inetd
# netstat -na |grep LISTEN    
# 查看 tftp 的 service port 8021 有無 runing

tcp4       0      0  *.8021                 *.*                    LISTEN

Setp 4.

CISCO Router 上的操作

cisco#show version     
#  檢視 IOS 的檔名

System image file is "flash:cisco-is-mz.122-2.T.bin"

cisco#copy cisco-is-mz.122-2.T.bin tftp:     
#  備份 IOS
Address or name of remote host []? 88.88.88.88
Destination filename [cisco-is-mz.122-2.T.bin]?
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
6952332 bytes copied in 25.564 secs (278093 bytes/sec)

cisco#copy running-config tftp:     
#  備份 runing-config
Address or name of remote host []? 88.88.88.88
Destination filename [cisco-confg]?
!!
2510 bytes copied in 0.324 secs