请问如何在局域网中的计算机上开启TFTP服务器

请问如何在局域网中的计算机上开启TFTP服务器,第1张

首先下载Cisco TFTP Server(如果你知道路由器的品牌,到路由器的厂商网站应该也会有相应的TFTP服务器软件下载),安装在放置有路由器升级文件的那台机器上(此时要设置好此台机器的IP地址,使之与路由器的局域网IP处于同一网段)。然后启动TFTP服务器软件,在选项设置中(一般在“查看”-“设置”菜单下)设定“TFTP服务器根目录”为你路由器升级文件所在的目录,按下“确定”,TFTP服务器设置完成。 接下来用telnet登录路由器,在路由器的配置模式下用tftp命令升级路由器的软件系统,一般的命令形式为“tftp TFTP服务器IP地址 文件名”,如输入“tftp 19216802 20062b”,表示从IP地址为19216802的TFTP服务器上下载名为20062b的文件升级路由器。具体的命令参数,还需参考路由器的使用说明书或直接查看命令帮助。

FTP和TFTP是我们经常使用的文件传输协议。在Linux中,sftp协议由于其安全性的优点,被作为默认的链接协议。但是,一些场合下,我们依然需要使用ftp和tftp协议进行文件传输。本篇主要介绍配置方法,供有需要的朋友待查。

1、 环境准备

我们选择Linux 26内核进行测试。

[root@SimpleLinuxUp ~]# uname -r
2618-128el5

当前OS运行在level 3模式下。

[root@SimpleLinuxUp ~]# grep init /etc/inittab
# inittab This file describes how the INIT process should set up
# 0 - halt (Do NOT set initdefault to this)
# 6 - reboot (Do NOT set initdefault to this)
id:3:initdefault:
# System initialization
si::sysinit:/etc/rcd/rcsysinit

默认情况下,tftp服务器包是安装上的,而FTP服务器没有安装。

[root@SimpleLinuxUp Server]# rpm -qa | grep ftp
tftp-server-042-31
ftp-017-35el5
lftp-351-2fc6

2、TFTP服务器安装配置

TFTP是一种比较特殊的文件传输协议。相对于FTP和目前经常使用的SFTP,TFTP是基于TCP/IP协议簇,用于进行简单文件传输,提供简单、低开销的传输服务。TFTP的端口设置为69。
相对于常见的FTP,TFTP有两个比较好的优势:
ü TFTP基于UDP协议,如果环境中没有TCP协议,是比较合适的;
ü TFTP执行和代码占用内存量比较小;
默认情况下,Linux内部是安装了tftp服务器包的。但是默认是不启动的。

[root@SimpleLinuxUp ~]# chkconfig --list tftp
tftp off

启用和禁用tftp服务是通过配置文件/etc/xinetdd/tftp,将其中参数设置。

[root@SimpleLinuxUp ~]# vi /etc/xinetdd/tftp

# default: off
# description: The tftp server serves files using the trivial file transfer \
# protocol The tftp protocol is often used to boot diskless \
# workstations, download configuration files to network-aware printers, \
# and to start the installation process for some operating systems
service tftp
{
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/intftpd
server_args = -s /tftpboot -c
disable = no
per_source = 11
cps = 100 2
flags = IPv4
}

配置文件中,将disable默认值从yes改为no。适当修改server_args参数,主要是其中的tftp根目录地址。
Tftp服务是不需要单独启动的,是作为xinetd服务的一个附属对象连带启动。
[root@SimpleLinuxUp ~]# service xinetd status
xinetd (pid 2194) is running
[root@SimpleLinuxUp ~]# cd /
[root@SimpleLinuxUp /]# mkdir /tftpboot
mkdir: cannot create directory `/tftpboot': File exists
[root@SimpleLinuxUp /]# cd /tftpboot/
[root@SimpleLinuxUp tftpboot]# cd
[root@SimpleLinuxUp /]# chmod -R 777 /tftpboot/

由于连接使用UDP端口,我们将防火墙和SELinux配置关闭。

[root@SimpleLinuxUp /]# service iptables stop
[root@SimpleLinuxUp /]# service iptables status
Firewall is stopped

对xinetd服务重启,连带将tftp服务启动。

[root@SimpleLinuxUp /]# service xinetd restart
Stopping xinetd: [ OK ]
Starting xinetd: [ OK ]

[root@SimpleLinuxUp /]# chkconfig --list tftp
tftp on

使用netstat判断UDP端口开启。

[root@SimpleLinuxUp /]# netstat -nlp | grep udp
udp 0 0 0000:772 0000: 1868/rpcstatd
udp 0 0 0000:775 0000: 1868/rpcstatd
udp 0 0 0000:69 0000: 3869/xinetd
(篇幅原因,有省略……)

从远程服务器启动连接,笔者从windows环境客户端启动。TFTP是可以不输入用户名和密码的,所以对于安全文件传输是不满足的。
C:\Documents and Settings\liuzy>tftp
Transfers files to and from a remote computer running the TFTP service
TFTP [-i] host [GET | PUT] source [destination]

-i Specifies binary image transfer mode (also called
octet) In binary image mode the file is moved
literally, byte by byte Use this mode when
transferring binary files
host Specifies the local or remote host
GET Transfers the file destination on the remote host to
the file source on the local host
PUT Transfers the file source on the local host to
the file destination on the remote host
source Specifies the file to transfer
destination Specifies where to transfer the file

测试客户端与服务器根目录之间的文件互相拷贝传输。

C:\Documents and Settings\liuzy>tftp 1921680100 put cogtrwinini
Transfer successful: 536 bytes in 1 second, 536 bytes/s

[root@SimpleLinuxUp tftpboot]# ls -l
total 12
-rw-rw-rw- 1 nobody nobody 507 Jan 28 10:39 cogtrwinini
drwxrwxrwx 4 root root 4096 Dec 26 09:46 linux-install

D:\>tftp 1921680100 get cogtrwinini
Transfer successful: 536 bytes in 1 second, 536 bytes/s

TFTP是一种简单的文件传输解决方案。

3、FTP配置

目前成熟系统设计中,都将FTP协议和传输定性为非安全传输协议。它和telnet登录方式,逐渐为SFTP和SSH协议所取代。在Linux流行版本中,SFTP已经成为默认配置项目。
在Linux发行版的光盘中,已经包括了vsftp服务器安装包,是需要手工安装。


欢迎分享,转载请注明来源:内存溢出

原文地址: https://www.outofmemory.cn/zz/13514448.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-08-23
下一篇 2023-08-23

发表评论

登录后才能评论

评论列表(0条)

保存