配置eth0的 IP地址, 同時啟用該裝置。
#ifconfig eth0 192.168.1.10 netmask 255.255.255.0 up
1. Install tftpd and related packages.
$ sudo apt-get install xinetd tftpd tftp
2. Create /etc/xinetd.d/tftp and put this entry:
service tftp
{
disable =no
socket_type =dgram
protocol =udp
wait =yes
user =root
server =/usr/sbin/in.tftpd
server_args =-s /tftpboot
per_source = 11
cps = 1002
flags = IPv4
}
3. Make /tftpboot directory
$ sudo mkdir /tftpboot
$ sudo chmod 777 /tftpboot
把/etc/init.d/atfpd
檔案中的if["$USE_INETD"="true"]中的true改為false
4. Start tftpd through xinetd
$ sudo /etc/init.d/xinetd restart
5. Testing. Tranfering file hda.txt from 192.168.1.100 (Client using tftp) to 192.168.1.100 (Server 192.168.1.100). Get an example file to transfer (eg. hda.txt)
$ touch /tftpboot/hda.txt
$ chmod 777 /tftpboot/hda.txt
$ ls -l /tftpboot/
total 0
-rwxrwxrwx 1 davids davids 0 2006-03-27 23:04 hda.txt
$ tftp 192.168.1.100
tftp> put hda.txt
Sent 722 bytes in 0.0 seconds
tftp> quit
$ ls -l /tftpboot/
total 4
-rwxrwxrwx 1 davids davids 707 2006-03-27 23:07 hda.txt
http://hi.baidu.com/wwwkljoel/blog/item/af42f612ade9905bf919b856.html
[注意事項]
如果從tftp伺服器下載失敗,
要確保伺服器的根目錄有可執行檔許可權。
$ chmod -R 777 tftp
使用中發現能正常下載檔案,
$ tftp 192.168.1.222
tftp> get zImage
Received 1692890 bytes in 0.2 seconds
可是上傳檔案不成功,
提示錯誤:
tftp> put dic.txt
Error code 2: Access violation
求助於google, 得下面一段說明,問題解決。
The tftp man page says:
Because there is no user-login or validation within the TFTP
protocol, the remote site will probably have some sort of
file-access restrictions in place. The exact methods are
specific to each site and therefore dif ficult to document here.
So apparently the site you're trying to get the file from has some
kind of access restrictions in place. Take a look at the tftpd man
page on the remote host. The linux tftpd manual says, in part, "Due to
the lack of authentication information, tftpd will allow only publicly
readable files to be accessed. Files may be written only if they
already exist and are publicly writable."
上面主要意思就是: tftp伺服器缺少必要的身分識別驗證,
所以預設只允許下載檔案,要上傳檔案,必須是伺服器中已存在同名的檔案,
且該檔案許可權允許被覆蓋。
所以首先在服務中建立一個與要上傳的檔案同名的檔案,並更改許可權。
$ touch dic.txt
$ chmod 777 dic.txt
重新上傳,成功。
tftp> put dic.txt
Sent 13770 bytes in 0.0 seconds