实验:搭建TFTP服务
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了实验:搭建TFTP服务相关的知识,希望对你有一定的参考价值。
注意:FTP 使用tcp协议,走的是tcp21端口,20端口或随机端口,共两个,TFTP使用udp协议,TFTP用udp69端口。TFTP是个非独立服务。支持文件下载、共享,TFTP(Trivial File Transfer Protocol,简单文件传输协议)是TCP/IP协议族中的一个用来在客户机与服务器之间进行简单文件传输的协议,提供不复杂、开销不大的文件传输服务,端口号为69。
前期准备:网卡必须在桥接模式下才能连接到外网,下载TFTP服务,所以把网卡修改为172.20网段。
1、[[email protected] ~]# yum install tftp-server
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
development | 3.6 kB 00:00:00
epel | 4.7 kB 00:00:00
(1/2): epel/updateinfo | 956 kB 00:00:00
(2/2): epel/primary_db | 6.6 MB 00:00:00
Resolving Dependencies
--> Running transaction check
---> Package tftp-server.x86_64 0:5.2-22.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=================================================================================
Package Arch Version Repository Size
Installing:
tftp-server x86_64 5.2-22.el7 development 47 k
Transaction Summary
Install 1 Package
Total download size: 47 k
Installed size: 64 k
Is this ok [y/d/N]: y
Downloading packages:
tftp-server-5.2-22.el7.x86_64.rpm | 47 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : tftp-server-5.2-22.el7.x86_64 1/1
Verifying : tftp-server-5.2-22.el7.x86_64 1/1
Installed:
tftp-server.x86_64 0:5.2-22.el7
Complete!
[[email protected] ~]# rpm -ql tftp-server
/etc/xinetd.d/tftp
/usr/lib/systemd/system/tftp.service
/usr/lib/systemd/system/tftp.socket
/usr/sbin/in.tftpd
/usr/share/doc/tftp-server-5.2
/usr/share/doc/tftp-server-5.2/CHANGES
/usr/share/doc/tftp-server-5.2/README
/usr/share/doc/tftp-server-5.2/README.security
/usr/share/man/man8/in.tftpd.8.gz
/usr/share/man/man8/tftpd.8.gz
/var/lib/tftpboot
2、开启TFTP服务,查看端口:
[[email protected] ~]# systemctl start tftp
[[email protected] ~]# ss -ntul
Netid State Recv-Q Send-Q Local Address:Port Peer Address:Port
udp UNCONN 0 0 :5353 :
udp UNCONN 0 0 :49063 :
udp UNCONN 0 0 192.168.122.1:53 :
udp UNCONN 0 0 :67 :
udp UNCONN 0 0 %virbr0:67 :
udp UNCONN 0 0 :68 :
udp UNCONN 0 0 :111 :
udp UNCONN 0 0 :893 :
udp UNCONN 0 0 :::69 :::
udp UNCONN 0 0 :::111 :::
udp UNCONN 0 0 :::893 :::
tcp LISTEN 0 128 :111 :
查看是谁在监听:
[[email protected] ~]# ss -ntulp
Netid State Recv-Q Send-Q Local Address:Port Peer Address:Port
udp UNCONN 0 0 :5353 : users:(("avahi-daemon",pid=6238,fd=12))
udp UNCONN 0 0 :49063 : users:(("avahi-daemon",pid=6238,fd=13))
udp UNCONN 0 0 192.168.122.1:53 : users:(("dnsmasq",pid=7400,fd=5))
udp UNCONN 0 0 :67 : users:(("dhcpd",pid=22547,fd=7))
udp UNCONN 0 0 %virbr0:67 : users:(("dnsmasq",pid=7400,fd=3))
udp UNCONN 0 0 :68 : users:(("dhclient",pid=23857,fd=6))
udp UNCONN 0 0 :111 : users:(("rpcbind",pid=6234,fd=5),("systemd",pid=1,fd=155))
udp UNCONN 0 0 :893 : users:(("rpcbind",pid=6234,fd=10))
udp UNCONN 0 0 :::69 :::* users:(("in.tftpd",pid=24131,fd=0),("systemd",pid=1,fd=24))
udp UNCONN 0 0 :::111 :::*
3、实现确保开机就启动TFTP服务:
[[email protected] ~]# systemctl enable tftp
Created symlink from /etc/systemd/system/sockets.target.wants/tftp.socket to /usr/lib/systemd/system/tftp.socket.
注:笔记:(centos7 1、yum install tftp-server 2、systemctl start tftp 3、systemctl enable tftp)(centos6 1、yum install tftp-server 2、chkconfig tftp on 3、service xinetd restart )
4、我们在客户端安装TFTP
[[email protected] ~]# yum install tftp
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Install Process
Loading mirror speeds from cached hostfile
base | 3.7 kB 00:00
centosplus | 3.4 kB 00:00
contrib | 2.9 kB 00:00
epel | 4.7 kB 00:00
epel/primary_db | 6.0 MB 00:00
extras | 3.4 kB 00:00
updates | 3.4 kB 00:00
updates/primary_db | 3.0 MB 00:00
Resolving Dependencies
--> Running transaction check
---> Package tftp.x86_64 0:0.49-8.el6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=================================================================================
Package Arch Version Repository Size
Installing:
tftp x86_64 0.49-8.el6 base 32 k
Transaction Summary
Install 1 Package(s)
Total download size: 32 k
Installed size: 45 k
Is this ok [y/N]: y
Downloading Packages:
tftp-0.49-8.el6.x86_64.rpm | 32 kB 00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : tftp-0.49-8.el6.x86_64 1/1
Verifying : tftp-0.49-8.el6.x86_64 1/1
Installed:
tftp.x86_64 0:0.49-8.el6
Complete!
[[email protected] ~]# rpm -ql tftp
/usr/bin/tftp
/usr/share/doc/tftp-0.49
/usr/share/doc/tftp-0.49/CHANGES
/usr/share/doc/tftp-0.49/README
/usr/share/doc/tftp-0.49/README.security
/usr/share/doc/tftp-0.49/README.security.tftpboot
/usr/share/man/man1/tftp.1.gz
[[email protected] ~]# chkconfig tftp on
[[email protected] ~]# service xinetd restart
Stopping xinetd: [FAILED]
Starting xinetd: [ OK ]
5、我们找到他的工作目录,里面无东西,拷贝一份文件过来,命名为f1
[[email protected] ~]# cd /var/lib/tftpboot/
[[email protected] tftpboot]# ls
[[email protected] tftpboot]# cp /etc/fstab f1
[[email protected] tftpboot]# ll
total 4
-rw-r--r-- 1 root root 655 Feb 3 11:44 f1
[[email protected] ~]# tftp 192.168.141.130
tftp> get f1
tftp> quit 此时centos6上就可以接收到f1 文件。
至此,tftp服务搭建完成!!
以上是关于实验:搭建TFTP服务的主要内容,如果未能解决你的问题,请参考以下文章
CentOS7 无人值守服务环境搭建(PXE + DHCP+TFTP+ Kickstart+ FTP)
谁知道如何在Ubuntu下搭建tftp服务器(最简单的安装配置)