Chinaunix首页 | 论坛 | 博客
  • 博客访问: 92119820
  • 博文数量: 19283
  • 博客积分: 9968
  • 博客等级: 上将
  • 技术积分: 196062
  • 用 户 组: 普通用户
  • 注册时间: 2007-02-07 14:28
文章分类

全部博文(19283)

文章存档

2011年(1)

2009年(125)

2008年(19094)

2007年(63)

分类: LINUX

2008-05-17 11:00:51

作者: Dssiuet  出自:
TFTP是用来下载远程文件的最简单网络协议,它其于UDP协议而实现。

嵌入式linux的tftp开发环境包括两个方面:

一是linux服务器端的tftp-server支持。

二是嵌入式目标系统的tftp-client支持。

下面就详细介绍一下linux服务器端tftp-server的配置。在redhat as 4.6的第四张光盘中,有tftp-server的安装rpm包。

(1)安装

#mount –t iso9660 /dev/hdc /mnt/cdrom //挂载光盘

#rpm -ivh tftp-server-0.39-2.i386.rpm //安装

#umount /mnt/cdrom //卸载光盘

(2)修改文件在linux下,不管使用的是哪一种super-server,inetd或者xinetd,默认情况下TFTP服务是禁用的,所以要修改文件来开启服务。

根据(1)的安装方法,可以修改文件/etc/xinetd.d/tftp。主要是设置TFTP服务器的根目录,开启服务。

修改后的文件如下:

service tftp {

socket_type =dgram

protocol =udp

wait =yes

user =root

server =/usr/sbin/in.tftpd

server_args =-s /root/router -c

disable =no

per_source =11

cps =100 2

flags =IPv4

}

说明:修改项server_args= -s -c,其中处可以改为你的tftp-server的根目录,参数-s指定chroot,-c指定了可以创建文件。

(3)创建tftp根目录,关闭防火墙,启动tftp-server。

#mkdir /root/router

#chmod o+w /root/router

#/etc/init.d/iptables stop //关闭防火墙

#service xinetd restart //重启 xinetd 服务

重启xinetd服务,因为TFTP服务受控与xinetd, xinetd是管服务的服务,它是不开端口的。

验证一下TFTP是否起来了:

# netstat -nlp

Active Internet connections (only servers)

Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name

tcp 0 0 0.0.0.0:32768 0.0.0.0:* LISTEN 3122/rpc.statd

tcp 0 0 127.0.0.1:32781 0.0.0.0:* LISTEN 4035/xinetd

tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 3103/portmap

tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 3324/httpd

tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 3255/sshd

tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 3213/cupsd

tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 3295/sendmail: acce

tcp 0 0 127.0.0.1:6010 0.0.0.0:* LISTEN 3415/0

tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN 3324/httpd

udp 0 0 0.0.0.0:32768 0.0.0.0:* 3122/rpc.statd

udp 0 0 0.0.0.0:69 0.0.0.0:* 4035/xinetd ;

可以看到69端口已经打开

udp 0 0 0.0.0.0:69 0.0.0.0:* 4012/in.tftpd

udp 0 0 0.0.0.0:111 0.0.0.0:* 3103/portmap

udp 0 0 0.0.0.0:754 0.0.0.0:* 3122/rpc.statd

udp 0 0 0.0.0.0:631 0.0.0.0:* 3213/cupsd

这样,tftp-server就启动了。

你可以登陆本机测试以下,命令如下:

#tftp your-ip-address

tftp>get

tftp>put

tftp>q

#

#telnet 192.168.100.1

telnet 路由器IP

username:******

password:******

即可登录到路由器上。

AKA-SZ-Router>en

Password:******

AKA-SZ-Route#show run

AKA-SZ-Route#copy running-config tftp(把路由器当时运行的配置文件写到TFTP Server上)
Remote host []?
输入:192.168.100.2 (TFTP Server的IP地址或主机名)

Name of configuration file to write [route-config]?

输入:ciscoconf (备份用户配置文件的文件名,此处也可直接回车,即使用缺省的route-config作为用户配置的文件名)

Write file conf-ciscoconf on host 192.168.100.2 [confirm] (让用户确认主机名或主机的IP地址是否正确)

如显示信息正确则直接回车,这时系统开始备份用户配置文件并显示如下信息:

Building configuration...
Writing route-config !!! [OK]

此处需要强调的是,在执行备份的过程中,认真观察路由器的备份过程,必须保证每个包都成功保存,即Writing route-config与[OK]之间必须都是“!”号,否则最好重写一次。另外,在备份结束后,最好用文本编辑软件打开备份文件,确认备份是否成功。

配置恢复的方法与备份的方法基本相同,只是恢复的命令不同,配置恢复的命令如下:

AKA-SZ-Route #copy tftp startup-config
阅读(647) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~