BeagleBone Black 之 TFTP 的搭建配置
来源:互联网 发布:淘宝怎么宝贝发布不了 编辑:程序博客网 时间:2024/06/05 19:54
TFTP: Trivial File Transport Protocol
TFTP 是一种简单的文件传输协议,通过UDP(User Datagram Protocol)的端口号69 来实现。TFTP 缺少很多正规的FTP的特征,主要是为小型和易于实现而设计的。TFTP仅仅读写文件到远程服务器,或从远端服务器读写文件。它无法列出目录,且不提供用户授权。因此安全性匮乏,主要用于私人本地文件传输。
xinted: eXtended InterNET Deamon
上图可以看到左图的每个服务都要自己的守护进程,来监听和处理对应端口号进来的请求;右图则有xinetd一个守护进程来监听各种端口的请求,并加载相应的服务进行处理这些请求,起到代理的作用,从而可以有效提高系统的性能;有些例外如,SMTP服务器,用于传递e-mail ,一般要求拥有自己独立的进程。
ubuntu host 端 TFTP服务器搭建:
1. 安装xinetd daemon 、tftp客户端, tftpd服务器
$ sudo apt-get install xinetd tftp tftpd
2. 配置tftp,通过xinetd daemon 来实现监听
$ cd /etc/xinetd.d
$ sudo gedit tftp
写入如下内容,并保存
service tftp { protocol = udp port = 69 socket_type = dgram wait = yes user = nobody server = /usr/sbin/in.tftpd server_args = "-s $tftproot" disable = no}3. 建立tftp的根目录
$ sudo mkdir /tftpboot
$ chmod 777 /tftpboot
4. 重载xinet.d daemon
$ sudo /etc/init.d/xinetd reload
5. 在主机上测试tftp,首先在/tftpboot目录任意建个文件
$ cd /tftpboot
$ touch test
选择要加载目,执行相应操作命令
$ cd ~
$ tftp localhost
$ tftp > get test
配置正确,在“~”目录下就可以找到刚建立的“test”文件了。
BBBlack 客户端操作
1. BBB的angstorm 系统已经装好 BusyBox的tftp命令,以下是命令格式
用法: tftp [OPTIONS] HOST [PORT]
传输文件来(或去)tftp 服务器
Options:
-l FILE 本地文件 -r FILE 远端文件 -g 下载文件 -p 上传文件
2. 在BBB terminal 上,下载文件“test”
# tftp -g -r test 192.168.7.1
也可以这样,加上端口号
# tftp -g -r test 192.168.7.1:69
3. 修改“test”文件,上传
#tftp -p -l test 192.168.7.1
注意:上传的文件仅限制在服务器目录下,具有读写权限的同名文件,否则会如下错误提示
tftp: server error: (2) Access violation
备注:192.168.7.1 为ubuntu host 端的ipaddress;
另附一份shell的安装命令脚本:tftp_setup.sh
#!/bin/bash# author: wiwa# date:20140613# revision:01# The document has referenced TI relative setup files.revision="revison_01"echo "The TFTP setup $revision will be touch now...."packages2install="tftpd xinetd tftp tftpd"cmd="sudo apt-get install"check_status() {status=$?if [ "$status" != "0" ]; thenecho "Sorry Failed setup"exit 1else echo -e "Good Jobs"fi}entry_header() {cat << EOF-------------------------------------------------------------------------------Welcome TFTP server setup Interface:^_^-------------------------------------------------------------------------------EOF}stage2_install() {cat << EOF-------------------------------------------------------------------------------We now step into stage2 phase:^_^-------------------------------------------------------------------------------EOF}exit_footer() {cat << EOF-------------------------------------------------------------------------------OK OK here , see you :^_^-------------------------------------------------------------------------------EOF}# Program startentry_header# check the missing packapgesfor i in $packages2install; dois_installed=`dpkg-query -l $i 2>/dev/null`if [ "$?" != "0" ]; thenneeds_install=`echo $needs_instal`" "$inew_cmd=`echo $cmd`" "$icmd=$new_cmdfidoneif [ "$needs_install" = "" ]; thenecho "System has all required packages"elseecho "The requires packages:$needs_install to be installed"echo "Installation requires administrator priviliges"echo "on your host. Do you wiil authorize it?"# Force the user to answer.may be you want to exitwhile true;do read -p "Type 'y' to continue or 'n' to abort: " yn[ "$yn" == "Y" -o "$yn" == "y" -o "$yn" == "N" -o "$yn" == "n" ] && break; doneif [ "$yn" = 'n' -o "$yn" = 'N' ]; thenecho "Abort now... Thanks"exitfiecho "Performing $cmd"$cmdcheck_statusfi# enter into stage 2stage2_installtftprootdefault="/tftpboot"tftpcfg=/etc/xinetd.d/tftptftp() { echo "service tftp{protocol = udpport = 69socket_type = dgramwait = yesuser = nobodyserver = /usr/sbin/in.tftpd server_args = "-s $tftproot"disable = no}" | sudo tee /etc/xinetd.d/tftp > /dev/null}echo "choose the directory you want to be tftp root directory"read -p "[ $tftprootdefault"] tftprootif [ "" == "$tftproot" ]; thentftproot=$tftprootdefaultfiecho "Now will set up the tftp server in the $tftproot directory."if [ -d $tftproot ]; thenecho echo "The $tftproot exists, quit.."else sudo mkdir -p $tftprootcheck_statussudo chmod 777 $tftprootcheck_statussudo chown nobody $tftprootcheck_statusfiif [ -n "$tftpcfg" ]; then if [ -f $tftpcfg ]; then#Use = instead of == for POSIX and dash shell complianceif [ "`cat $tftpcfg | grep args | cut -d = -f2 | sed 's/^[ ]*//'`" \ = " $tftproot" ]; then echo "$tftproot already exported for TFTP, skipping.."else echo "Copying old $tftpcfg to $tftpcfg.old" sudo cp $tftpcfg $tftpcfg.old check_status tftpfielsetftpfielse exit 1;fiechoecho "reload the tftp server..."echo /etc/init.d/xinetd reloadcheck_statussleep 1echo "Finish the TFTP server configure."# Print the exit statement to the consoleexit_footer
参考资料列表:
wikipedia:Trivial File Transfer Protocol
配置TFTP服务器:Configuring a TFTP Server for Linux
inted 和 xinetd 介绍:http://www.ibm.com/developerworks/aix/library/au-spunix-inetd/index.html
[BusyBox] tftp usage for newbie
- BeagleBone Black 之 TFTP 的搭建配置
- BeagleBone Black 之 NFS 的搭建配置
- BeagleBone Black教程之BeagleBone Black设备的连接
- beaglebone black 的Qt开发环境搭建
- beaglebone black 的Qt开发环境搭建
- BeagleBone Black的Cape之基本概念
- beaglebone black tftp与nfs挂载根文件系统
- beaglebone black tftp与nfs挂载根文件系统
- Beaglebone Black的启动
- Beaglebone black开发环境搭建
- BeagleBone Black教程之BeagleBone Black使用到的Linux基础
- BeagleBone Black与主机共享网络之配置操作
- beaglebone black ftp配置登录
- Beaglebone Black教程Beaglebone Black的引脚分配
- 使用Beaglebone Black的ADC
- 使用Beaglebone Black的SPI
- 使用Beaglebone Black的ADC
- beaglebone black的cape管理
- Eclipse创建一个注释模板
- oracle 60-raw.rules和99-oracle-asmdevices.rules区别
- JQValidate校验参数使用说明
- TFS的常用命令
- android4.0 USB Camera实例(三)UVC
- BeagleBone Black 之 TFTP 的搭建配置
- centos下安装中文输入法
- MyHtmlPageExt分页扩展方法
- Android开发之Animation 4种动画效果
- sql的while
- C# 连接SQL Server数据库的几种方式--server+data source等方式
- JavaScript的原生引用类型
- jquery制作折叠式菜单(Accordion)
- 使用openssl实现md5加密