linux 下配置tftp服务器

 实例—TFTP服务器的搭建

1.tftp的配置文件
[root@localhost Desktop]# gedit /etc/xinetd.d/tftp
1    # default: off
 2    # description: The tftp server serves files using t he trivial file transfer \
 3    #    protocol.  The tftp protocol is often used to boot diskless \
 4    #    workstations, download configuration files to network-aware printers, \
 5    #    and to start the installation process for some operating systems.
 6    service tftp
 7    {
 8        socket_type        = dgram
 9        protocol        = udp
10        wait            = yes
11        user            = root
12        server            = /usr/sbin/in.tftpd
13        server_args        = -s /tftpboot
14        disable        = no
15        per_source        = 11
16        cps            = 100 2
17        flags            = IPv4
18    }
其中,server_args = -s /tftpboot是tftp服务器运行时的参数。-s /tftpboot表示服务器默认的目录是/tftpboot,当执行put a.txt命令时,文件被放到服务器的路径是/tftpboot/a.txt。
可以执行tftp、get命令下载文件。在嵌入式开发中,多使用下载功能。
可以执行put命令上传文件。上传文件时,需要先把服务器上的/tftpboot目录和这个目录下的文件变成可读可写权限,可以执行如下命令:
[root@localhost Desktop]# chmod -R 666 /tftpboot
默认情况下,只能上传tftp服务器已经存在的文件,例如,在tftp服务器上有/tftpboot/a.txt这个文件,可以执行如下命令:
[root@localhost Desktop]# put a.txt
如果想上传tftp服务器目录中没有的文件,需要修改tftp服务器的配置文件,
将/etc/xinetd.d/tftp文件的第13行改为“server_args = -s /tftpboot -c”即可,然后重启tftp服务器。
2.重启tftp服务器
[root@localhost Desktop]# service xinetd restart
停止 xinetd:                                              [确定]
启动 xinetd:                                              [确定]
[root@localhost Desktop]#
3.测试tftp
[root@localhost Desktop]# netstat -a|grep tftp
udp        0      0 *:tftp                      *:*                                     
[root@localhost Desktop]# netstat -an|grep 69|grep udp
udp        0      0 0.0.0.0:69                  0.0.0.0:*
udp        0      0 :::56996                    :::*                                    
执行上面两条命令中的任何一条,如果有相关的输出,就表明tftp服务器配置成功。
注:tftp服务器使用UDP协议,使用的端口号是69。


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值