安装TFTP 服务器

可以在 Linux 发行版上手动安装 tftp rpm。
这可以根据发行版来完成:

在 RedHat 和 CentOS 上,我们可以使用“yum install tftp”,而在 SuSE 发行版上,我们可以使用“zypper install tftp”

成功安装 tftp rpm 后,请按照以下步骤操作

# rpm -qa | grep tftp
tftp-0.48-101.31.27

创建我们计划用于 TFTP 共享的目录

# mkdir /tftpboot

注意:我将我的 tftp 目录的权限更改为 777,因为我将通过上传几个文件来演示我的服务器,这些文件将以“nobody”用户身份完成,因此我需要对我的 tftp 目录进行填充访问。
一般来说,如果你只是打算将它用于 PXE 环境,那么 644 权限就足够了。

# chmod 777 /tftpboot

对 tftp 配置文件进行必要的更改,如下所示

# vi /etc/xinetd.d/tftp
# default: off
# description: tftp service is provided primarily for booting or when a
#       router need an upgrade. Most sites run this only on machines acting as
#       "boot servers".
service tftp
{
        socket_type             = dgram
        protocol                = udp
        wait                    = yes
        flags                   = IPv4  <-- If you also have IPv6 in your network, mention both values (eg. IPv4  IPv6)
        port                    = 69
        user                    = root
        server                  = /usr/sbin/in.tftpd
        server_args             = -c -s /tftpboot  <-- This is the tftp directory which will contain all files which can be picked by client
        disable                 = no  <-- Make sure this is 'no'
}

保存并退出文件。

重启xinetd服务

# /etc/init.d/xinetd restart
Shutting down xinetd: (waiting for all children to terminate)                  done
Starting INET services. (xinetd)                                               done

让我们测试我们的 tftp 服务器。

这里,我们将把HPKnife 片机的 OA 日志上传到 tftp 服务器 (192.169.32.10)

Login to OA CLI using Puttylogin as: HPadmin
----------------------------------------------------------------------------
WARNING: This is a private system.  Do not attempt to login unless you are an
authorized user.  Any authorized or unauthorized access and use may be moni
tored and can result in criminal or civil prosecution under applicable law.
----------------------------------------------------------------------------
Firmware Version: 4.50
Built: 07/24/2014 @ 04:06
OA Bay Number:  1
OA Role:       Active
HPadmin@10.43.21.136's password:
HP BladeSystem Onboard Administrator
(C) Copyright 2006-2014 Hewlett-Packard Development Company, L.P.
Type 'HELP' to display a list of valid commands.
Bangalore1-01-01> upload SUPPORTDUMP tftp://192.169.32.10/log1
Starting background task to collect debug data. Return status will be displayed when it is done. You can continue working during this process or log off.
Bangalore1-01-01>
Successfully uploaded file

如果文件上传成功,让我们检查 tftp 服务器

cc01-nds-ins:/tftpboot # ll
total 624
-rw-rw-rw- 1 nobody nobody 605352 Sep 13 16:16 log1

可以看到上传的文件。配置完成。

如何在 Linux 中配置 TFTP 服务器

Trivial File Transfer Protocol (TFTP) 是一个简单的、锁步的文件传输协议,它允许客户端从远程主机获取文件或者将文件放到远程主机上。
它的主要用途之一是在节点从局域网启动的早期阶段。
TFTP 已用于此应用程序,因为它实现起来非常简单。

如上所述,我们主要使用 TFTP 服务器在网络内的客户端节点上执行 PXE 网络引导。

日期:2020-06-02 22:18:28 来源:oir作者:oir