先在freebsd8.0上建立tftp服务器
#!/bin/sh
#code by scpman
#http://scpman.blog.51cto.com
echo 'inetd_enable="YES"' >> /etc/rc.conf
mkdir /tftp_bak
#echo 'tftp dgram udp wait root /usr/libexec/tftpd tftpd -l -s /tftpd_bak ' >> /etc/inetd.conf
#用这句,-w参数允许客户端直接传不用在服务端先创建文件
echo 'tftp dgram udp wait root /usr/libexec/tftpd tftpd -s /usr/backup_app/company_inside/router -w'>>/etc/inetd.conf
/etc/rc.d/inetd reload
lsof -i:69
if [ $? = 0 ]
then
echo TFTP server is ok
fi
然后登录路由:
telnet 192.168.1.1
Password:
Router>en
Router>
Router#copy running-config tftp:
Address or name of remote host []? 172.17.14.200
Destination filename [router-confg]?
TFTP: error code 0 received - 20079
%Error opening tftp://192.168.1.200/router-config (Undefined error)##默认tftp不可以写,在tftp上建立出对应文件名
在192.168.1.200#touch /tftp_bak/router-config
#chmod 666 /tftp_bak/router-config #要是666权限
再来一次:
Router#copy running-config tftp:
Address or name of remote host []? 192.168.1.200
Destination filename [router-confg]? router-config
!!!!!
16318 bytes copied in 1.416 secs (11524 bytes/sec)
#搞定!
垃圾的很啊,每次都要先建立出来??
当然不是了,加-w参数,允许客户端直接写文件tftp服务器。已经修改在脚本中了