CentOS8 TFTP部署

简单文本传输协议(TFTP)

TFTP是一种基于UDP协议的简单文本传输协议。
特点:

  1. 命令功能不如FTP服务强大,安全性弱于FTP
  2. 采用UDP协议,占用69端口号
  3. 文件传输过程不如FTP协议可靠
  4. 不需要客户端权限认证
  5. 减少无谓的系统和网络贷款消耗,效率更高

TFTP服务部署

安装tftp软件包

[root@MyCentOS ~]# yum install tftp
Repository extras is listed more than once in the configuration
Repository PowerTools is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
上次元数据过期检查:14:15:23 前,执行于 20200812日 星期三 190742秒。
依赖关系解决。
========================================================================================================================================================================================
 软件包                                   架构                                       版本                                           仓库                                           大小
========================================================================================================================================================================================
安装:
 tftp                                     x86_64                                     5.2-24.el8                                     AppStream                                      42 k

事务概要
========================================================================================================================================================================================
安装  1 软件包

总下载:42 k
安装大小:51 k
确定吗?[y/N]: y
下载软件包:
tftp-5.2-24.el8.x86_64.rpm                                                                                                                               61 kB/s |  42 kB     00:00    
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
总计                                                                                                                                                     60 kB/s |  42 kB     00:00     
运行事务检查
事务检查成功。
运行事务测试
事务测试成功。
运行事务
  准备中  :                                                                                                                                                                         1/1 
  安装    : tftp-5.2-24.el8.x86_64                                                                                                                                                  1/1 
  运行脚本: tftp-5.2-24.el8.x86_64                                                                                                                                                  1/1 
  验证    : tftp-5.2-24.el8.x86_64                                                                                                                                                  1/1 
Installed products updated.

已安装:
  tftp-5.2-24.el8.x86_64                                                                                                                                                                

完毕!

关键:还需要安装tftp-server软件包
后面操作的时候才发现还有服务器软件包没有安装

TFTP服务配置

TFTP服务是使用xinetd服务程序来管理的,xinetd服务可以用来管理多种轻量级网络服务,而且具有强大的日志功能。

配置tftp服务

tftp服务通过xinetd程序来管理,在/etc/xinetd.d/路径下配置tftp服务。

[root@MyCentOS ~]# cd /etc/xinetd.d/
[root@MyCentOS xinetd.d]# vim tftp
service tftp
{
        socket_type = dgram
        protocol    = udp
        wait        = yes
        user        = root
        server      = /usr/sbin/in.tftpd
        server_args = -s /var/lib/tftpboot  <<<<<<<<<设置tftp服务的根目录
        disable     = no    <<<<<<<<<开启tftp服务
        per_source  = 11
        cps         = 100 2
        flags       = IPv4
}

如果运行xinetd服务程序提示没有该程序,则应当先安装该程序。

重启xinetd并加入开机自启

略,见前几篇博客

设置防火墙关于tftp规则

[root@MyCentOS ~]# firewall-cmd --permanent  --zone=internal --add-port=69/udp
success
[root@MyCentOS ~]# firewall-cmd --permanent --zone=internal --add-service=tftp
success
[root@MyCentOS ~]# firewall-cmd --reload
success
[root@MyCentOS ~]# firewall-cmd --list-all
internal (active)
  target: default
  icmp-block-inversion: no
  interfaces: ens33
  sources: 
  services: cockpit dhcpv6-client ftp mdns samba-client ssh tftp
  ports: 69/udp
  protocols: 
  masquerade: no
  forward-ports: 
  source-ports: 
  icmp-blocks: 
  rich rules: 

tftp服务的根目录在/var/lib/tftpboot路径下。

坑一、设置SELinux关于tftp的规则

在部署好以上设置后,连接tftp服务器发现还是没能成功,信息提示传输请求被拒绝。经过排查,才发现是因为SELinux关于tftp的规则还没设置。

[root@MyCentOS ~]# getsebool -a | grep tftp
tftp_anon_write --> off
tftp_home_dir --> off
[root@MyCentOS ~]# setsebool -P tftp_home_dir=on
[root@MyCentOS ~]# getsebool -a | grep tftp
tftp_anon_write --> off
tftp_home_dir --> on
[root@MyCentOS ~]# tftp 192.168.10.10
tftp> get tftptest.txt
tftp> quit
[root@MyCentOS ~]# cat tftptest.txt
this is tftp testll!

以上即为tftp部署的初步总结!

  • 3
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 9
    评论
对于CentOS 8的自动化部署,你可以使用Kickstart文件和PXE(Preboot Execution Environment)来实现。下面是一个简单的步骤: 1. 首先,你需要创建一个Kickstart文件,该文件包含了安装过程中的所有配置信息,例如分区、软件包选择、网络设置等。你可以使用文本编辑器创建一个名为`ks.cfg`的文件,并按照你的需求进行配置。一个示例的Kickstart文件如下所示: ``` #platform=x86, AMD64, or Intel EM64T #version=DEVEL # Install OS instead of upgrade install # Use CDROM installation media cdrom # Use graphical install graphical # Run the Setup Agent on first boot firstboot --enable ignoredisk --only-use=sda # Keyboard layouts keyboard --vckeymap=us --xlayouts='us' # System language lang en_US.UTF-8 # Network information network --bootproto=dhcp --device=eth0 --onboot=on # Root password rootpw --iscrypted $6$xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx # System timezone timezone Asia/Shanghai --isUtc # System bootloader configuration bootloader --append=" crashkernel=auto" --location=mbr --boot-drive=sda # Partition clearing information clearpart --all --initlabel # Disk partitioning information part /boot --fstype="xfs" --size=500 part / --fstype="xfs" --grow --size=1 %packages @^minimal @core %end %addon com_redhat_kdump --disable --reserve-mb='auto' %end ``` 2. 将创建的Kickstart文件复制到一个可访问的位置,例如Web服务器上的公共目录。 3. 配置PXE服务器,使其能够提供网络引导服务。这可以在你的PXE服务器上通过DHCP和TFTP服务来实现。确保PXE服务器上已经正确配置了DHCP和TFTP服务,并且可以提供CentOS 8的安装镜像文件。 4. 在PXE服务器上创建一个名为`default`的文件,并添加以下内容: ``` default menu.c32 prompt 0 timeout 300 menu title ########## PXE Boot Menu ########## label 1 menu label ^1) Install CentOS 8 kernel centos8/vmlinuz append initrd=centos8/initrd.img inst.ks=http://your-web-server/ks.cfg menu end ``` 确保将`your-web-server`替换为你实际使用的Web服务器的地址。 5. 确保PXE服务器上已经准备好了CentOS 8的安装镜像文件,并将其放置在一个可供TFTP服务器访问的目录中。 6. 启动目标系统,并在BIOS设置中将网络引导(PXE)设置为首选项。 7. 当目标系统启动时,它将从PXE服务器获取引导信息,并显示PXE引导菜单。选择安装CentOS 8的选项。 8. 安装程序将自动下载Kickstart文件,并根据其中的配置信息自动化执行安装过程。 请注意,这只是一个基本的示例,你可以根据自己的需求和环境进行更详细的配置。在实际部署之前,请确保你已经仔细测试和验证了整个自动化部署过程。
评论 9
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值