安装配置 TFTP 服务的大致步骤如下:
(1)安装 tftp-hpa、tftpd-hpa 和 openbsd-inetd 程序;
(2)修改配置文件/etc/inetd.conf;
(3)根据配置文件的路径,建立 tftp 目录,并修改目录权限;
(4)重启 tftp 服务;
(5)本地传输测试。
安装环境为Ubuntu10.04
#!/bin/sh
TFTPDIR=/work/user/tftp
echo install tftp server...
sudo apt-get install tftp-hpa tftpd-hpa
if [ "$?" = "0" ]
then
echo "install tftp-hpa and tftpd-dpa OK !!!"
else
echo "install tftp-hpa and tftpd-dpa error !!!"
# exit 1
fi
sudo apt-get install openbsd-inetd
if [ "$?" = "0" ]
then
echo "install openbsd-inetd OK !!!"
else
echo "install openbsd-inetd error !!!"
# exit 1
fi
echo modify /etc/inted.conf
#拷入以下内容到 /etc/inetd.conf
#tftp dgram udp wait root /usr/sbin/in.tftpd /usr/sbin/in.tftp -c -s /work/work/tftp
sudo gedit /etc/inetd.conf
# 建立tftp目录,并修改目录权限:
echo "creat tftp dir..."
mkdir -p $TFTPDIR
if [ "$?" = "0" ]
then
echo "make tftp dir $TFTPDIR OK !!!"
else
echo "make tftp dir $TFTPDIR error !!!"
# exit 1
fi
sudo chmod 777 $TFTPDIR
#重启tftp sever
sudo /etc/init.d/openbsd-inetd restart
运行以上脚本后就完成了tfpt的安装。
至此Ubuntu tftp服务已经安装完成了,下面可以对其进行一下测试。(假设在当前目录下有一个测试文件test.txt)
$tftp 127.0.0.1
tftp> put test.txt
Sent 1018 bytes in 0.0 seconds
tftp> get test.txt
Received 1018 bytes in 0.1 seconds
tftp> quit
通过get命令,可以把当前目录下的test.txt文件,通过Ubuntu tftp上传到它的服务文件目录。这时,在/tftpboot下面会出现test.txt文件。通过put命令,可以从/tftpboot下,下载test.txt文件。这样就验证了Ubuntu tftp服务配置的正确性。当文件上传与下载结束后,可以通过quit命令或q退出。严格按照以上步骤配置Ubuntu tftp服务,一般都可以成功。如果出现无法get或者put的时候,可以查看一下防火墙是否关闭。